clean up for first attempt at running on x86
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 3 Feb 2010 05:38:35 +0000 (05:38 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 3 Feb 2010 05:38:35 +0000 (05:38 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@137 01035d8c-6547-0410-b346-abe4f91aad63

mini-asterisk-gui/README.txt
mini-asterisk-gui/cgi-bin/about.sh
mini-asterisk-gui/cgi-bin/admin.sh
mini-asterisk-gui/cgi-bin/faq.html
mini-asterisk-gui/cgi-bin/ipphones.sh
mini-asterisk-gui/cgi-bin/network.sh
mini-asterisk-gui/cgi-bin/phones.sh
mini-asterisk-gui/cgi-bin/set_network.sh
mini-asterisk-gui/cgi-bin/set_voiplines.sh

index a6b9c660efce27fed73d87536a6f9b169349d31a..59f9160920d411ef2fadc4a58e4f74c1c4e90be3 100644 (file)
@@ -28,11 +28,10 @@ installations fast and simple, for example:
   file format.
 
 * A small office that already has an old analog phone system.  You
-  want to keep your current analog lines for incoming calls, but
-  install 8 IP Phones and use VOIP for outgoing calls.  You know
-  enough to set up a DSL router but don't want to rely on "the Phone
-  Guy" or "The Computer Guy" at $100/hr to maintain your phone
-  system.
+  want to keep your current analog lines for incoming calls, but use
+  IP Phones for handsets and VOIP for outgoing calls.  You know enough
+  to set up a DSL router and don't want to rely on "the Phone Guy" or
+  "The Computer Guy" at $100/hr to maintain your phone system.
 
 * You are a "Phone Guy" who doesn't understand Linux and Asterisk but
   you want to install IP-PBXes.
@@ -45,7 +44,7 @@ There are http://www.voip-info.org/wiki/view/Asterisk+GUI[a lot of
 Asterisk GUIs] out there already.  So why do we need another one?
 
 Well I needed an Asterisk GUI that was very easy to use for the
-link:ip04.html[IP0X devices] I sell.  Something that would lower the
+link:ip04.html[IP0X] family.  Something that would lower the
 technical skill required to install and maintain an Asterisk Phone
 system.  Something my wife and kids could use.
 
@@ -63,7 +62,7 @@ view!
 
 * Light weight so it can run on embedded boxes like the IP0X family.
   No SQL database or PHP or LAMP.  Only a basic web server and a very
-  basic perl are required (e.g. microperl - no CPAN libraries).
+  basic perl are required (microperl - no CPAN libraries).
 
 * Works directly on extensions.conf and sip.conf, but honors any edits
   you make to these files.  So all the powerful Asterisk features are
@@ -77,7 +76,7 @@ view!
   have to understand what a dial-plan is, much less understand how to
   code one.  Plain English terms are used instead, for example "Phones
   and Phone lines".  Terms like Asterisk, Linux, SIP, Zap/1 don't even
-  get a mention.
+  get mentioned.
 
 * Extensive tool tip documentation.  No manual.
 
@@ -91,8 +90,8 @@ view!
 * Extensive pre-configuration of extensions.conf and sip.conf,
   pre-selected phone numbers, SIP trunks are selected from a pull-down
   menu (except they are called VOIP lines).  Analog ports are auto
-  detected, at least on the IP0X.  This makes adding IP phones very
-  fast and simple.
+  detected, at least on the IP0X.  This makes adding phones fast and
+  simple.
 
 [[status]]
 Status
@@ -101,13 +100,14 @@ Status
 Alpha:
 
 * Works on IP0X.
-* Not tested on x86. Several IP0X features are n/a for x86 and should be
-  disabled when the x86 (or non-IP0X) platform is detected.
+* Works on x86 but many features (like upgrades) disabled in the
+  interests of security. These need to be implemented in a safe way.
 * Needs feedback from real users to see how useful the concept is and what
   (un)features need to be added.
 * Need a few more (un)features to be added, and Voip Line screen
   populated with more ITSPs.
-* But quite useable as it stands.
+* But quite useable as it stands, especially as a starting point for
+  IP0X.
 
 [[notes]]
 Implementation Notes
@@ -176,28 +176,62 @@ Remember to backup your existing extensions.conf & sip.conf in
 -------------------------------------------------------------------
 # cd ~ 
 # svn co https://freetel.svn.sourceforge.net/svnroot/freetel/mini-asterisk-gui
+# cd mini-asterisk-gui
 # ./update_revision.sh
-# cp mini-asterisk-gui/etc/asterisk/* /etc/asterisk 
-# cp mini-asterisk-gui/cgi-bin/* /www
+# cp etc/asterisk/* /etc/asterisk 
+# cp cgi-bin/* /var/www
 # cd /etc/asterisk
 # cp extensions.conf extensions.conf.def
 # cp sip.conf sip.conf.def
-# mv etc/asterisk/users.conf etc/asterisk/users.conf.bak
--------------------------------------------------------------------
+# mv users.conf users.conf.bak
 +
-The final step above may not be required on your machine if you don't
-have a users.conf.  The .def copies are required by the "reset
-defaults" feature on the admin screen.
+The .def copies are required by the "reset defaults" feature on the
+admin screen.
 
-. Switch off the internal Asterisk web server by editing
+. It's a good idea to switch off the internal Asterisk web server by editing
 /etc/asterisk.httpd.conf.  Make sure the enabled line reads like this:
 
    enabled=no
 +
 Then stop and restart Asterisk.
++
+-------------------------------------------------------------------
+# /etc/init.d/asterisk restart
+-------------------------------------------------------------------
++
+. I use lighttpd as the web server.  On my x86 box I needed to install
+a sym-link and edit the 10-cgi.conf file:
++
+-------------------------------------------------------------------
+# cd /etc/lighttpd/conf-enabled
+# ln -s ../conf-available/10-cgi.conf .
+-------------------------------------------------------------------
++
+I then modified 10-cgi-conf to enable perl and shell scripts:
++
+-------------------------------------------------------------------
+cgi.assign      = (
+       ".pl"  => "/usr/bin/perl",
+       ".sh"  => "/bin/sh",
+)
+-------------------------------------------------------------------
++
+Make sure lighttpd runs as root, as we need to run Asterisk etc from
+shell script CGIs:
++
+## change uid to <uid> (default: don't care)
+#server.username            = "wwwrun"
 
-. I use lighttpd as the web server, the /etc/lighttpd.conf lines
-required are:
+## change uid to <uid> (default: don't care)
+#server.groupname           = "wwwrun"
++
+Restart lighttpd after all the changes:
++
+--------------------------------------------------------------------
+# /etc/init.d/lighttpd restart
+------------------------------------------------------------------
++
+For comparison on the IP04 I just modified /etc/lighttpd.conf:
 +
 -------------------------------------------------------------------
 cgi.assign = ( ".sh" => "/bin/sh",".pl" => "/usr/bin/perl" )
@@ -207,16 +241,20 @@ cgi.assign = ( ".sh" => "/bin/sh",".pl" => "/usr/bin/perl" )
 Contributions
 -------------
 
-I welcome sip.conf entries for your favourite ITSP (VOIP service) to
-help populate the Provider field of the
+I especially welcome sip.conf entries for your favourite ITSP (VOIP
+service) to help populate the Provider field of the
 link:mini/voiplines.sh.html[Voip Line Screen].
 
+Suggestions and patches for new features are also very welcome.
+
 [[support]]
 Support
 -------
 
 Comments, features request, bugs please let me know using Free
-Telephony Project http://www.rowetel.com/ucasterisk/#support[Support].
+Telephony Project
+https://lists.sourceforge.net/lists/listinfo/freetel-discuss[Mailing
+List]
 
 [[source]]
 Source Code
@@ -268,3 +306,8 @@ x86:
 setting up the CGI QUERY_STRING environment variable:
 
   [david@host cgi-bin]$ export QUERY_STRING="pass=uClinux" ; sh login.sh
+
+. When editing on an x86 host and testing on an IP0X Emacs has a nice
+  feature M-! that lets you execute a shell command.  I use this to
+  download the shell fuile I am working on, e.g. "scp admin.sh
+  root@ip04".
index 9cf948d8bb27b0f62c16f46766989bed251d9c27..8c4b6f00f02dee1a64b5485c0a046ad6629ef94f 100644 (file)
@@ -40,7 +40,7 @@ cat <<EOF
     <table align="right" width=600>
       <tr><td align="left" valign="top"><h2>About</h2></td></tr>
 EOF
-echo '      <tr><td><a href="http://rowetel.com/ucasterisk/mini.html">Mini Asterisk</a> Revision: 132 </td></tr> '
+echo '      <tr><td><a href="http://rowetel.com/ucasterisk/mini.html">Mini Asterisk</a> Revision: 134 </td></tr> '
 echo '      <tr><td>&nbsp;</td></tr>'
 echo '      <tr><td>Brought to you by the <a href="http://rowetel.com/ucasterisk/index.html">Free Telephony Project</a></td></tr>'
 echo '      <tr><td><a href="http://rowetel.com/ucasterisk/ip04.html"><img src="http://rowetel.com/images/ip04/ip04_case.jpg" border="0" /></a></td></tr>'
index 00a4d0aaf76672ca5e4a9c42a713c6c70edaa52c..82fd9c9a6b71f2fdabf07dff7532f46ff96e9d5b 100644 (file)
@@ -3,7 +3,7 @@
 # David Rowe 7 Jan 2010
 # Admin screen for Mini Asterisk GUI
 
-# check we are logged in
+# check we are logged in ----------------------------------------
 
 echo $HTTP_COOKIE | grep "loggedin" > /dev/null
 if [ $? -eq 1 ]; then
@@ -15,10 +15,25 @@ if [ $? -eq 1 ]; then
     exit
 fi
 
+# check what sort of machine we are running on.  Many operations
+# outlawed for x86
+
+cat /proc/cpuinfo | grep "CPU:.*ADSP" > /dev/null
+if [ $? -eq 0 ]; then
+    mach="ip0x"
+else
+    mach="x86"
+fi
+
 # set password CGI -----------------------------------------------
 
 echo "$QUERY_STRING" | grep -oe "pass=" > /dev/null
 if [ $? -eq 0 ]; then
+    if [ $mach != "ip0x" ] ; then
+       echo "<html>Sorry, only supported on the IP0X</html>"
+       exit
+    fi
+
     pass=`echo "$QUERY_STRING" | grep -oe "pass=[^&?]*" | sed -n "s/pass=//p"`
     passwd_cmdline $pass
 fi
@@ -28,6 +43,11 @@ fi
 echo "$QUERY_STRING" | grep -oe "restart=1" > /dev/null
 if [ $? -eq 0 ]; then
 
+    if [ $mach != "ip0x" ] ; then
+       echo "<html>Sorry, only supported on the IP0X</html>"
+       exit
+    fi
+
 # kill cookie to log out.  This ensures hitting refresh wont run
 # the restart process again
 
@@ -55,7 +75,7 @@ if [ $? -eq 0 ]; then
     asterisk -rx "dialplan reload" 2>/dev/null 1 > /dev/null
 fi
 
-# Upgrade Mini Asterisk CGI ----------------------------------------------------
+# Upgrade Mini Asterisk CGI -------------------------------------------
 
 echo "$QUERY_STRING" | grep -oe "upgrade=1" > /dev/null
 if [ $? -eq 0 ]; then
@@ -63,17 +83,8 @@ if [ $? -eq 0 ]; then
     # test if we are running on an IP0X
     which ipkg >> /dev/null
     if [ $? -eq 1 ]; then
-       cat <<EOF
-       <html>
-       <head>
-       <title>Mini Asterisk - Upgrade</title>
-       </head>
-       <body>
-       Sorry upgrade only supported on IP0X at this time
-       </body>
-       </head>
-       </html>
-EOF
+       echo "<html>Sorry, only supported on the IP0X</html>"
+        exit
     fi
 
     cat <<EOF
@@ -109,9 +120,9 @@ fi
 echo "$QUERY_STRING" | grep -oe "firmwareurl=" > /dev/null
 if [ $? -eq 0 ]; then
 
-    h=`hostname`
-    if [ ! $h == "ip04" ]; then
-       echo "<html>Sorry Firmware Upgreade only supported on IP04</html>"
+    if [ $mach != "ip0x" ] ; then
+       echo "<html>Sorry, only supported on IP0X</html>"
+       exit
     fi
 
     firmwareurl=`echo "$QUERY_STRING" | grep -oe "firmwareurl=[^&?]*" | sed -n "s/firmwareurl=//p"`
index dd6258e5493daa0b6abf23a7f8ac233fcb59ef86..bbe162ac946d873291b3f48d654f38268c363cf9 100644 (file)
@@ -1,12 +1,24 @@
 <ol>
 
-<li><strong>Transfer a Call</strong>
+<li><strong>Where can I get Support:</strong> You can try the
+    <a href="https://lists.sourceforge.net/lists/listinfo/freetel-discuss">Free Telephony Project</a> Mailing List.
 
-<li><strong>Answer a call on another ringing phone</strong>:  If you hear another phone ringing and
-want to answer the call on your phone, just pick up your phone and
-dial *8.  Note an IP phone can pick up a call on a ringing IP phone
-but not an Analog phone.  An Analog pohone can pick up another
-ringing Analog phone but not an IP phone.
+<li><strong>Answer a call on another ringing phone</strong>: If you
+    hear another phone ringing and want to answer the call on your
+    phone, just pick up your phone and dial *8.  Note an IP phone can
+    pick up a call on a ringing IP phone but not an Analog phone.  An
+    Analog pohone can pick up another ringing Analog phone but not an
+    IP phone.
+
+<li><strong>Put a call on hold/transfer:</strong> On an IP Phone try
+    the recall or transfer button.  On an Analog Phone hold down the
+    hook button for 1 second then dial the new number.
+
+<li><strong>Why another Asterisk GUI</strong> I had some specific
+    needs for a light weight, very easy to use GUI for
+    the <a href="http://www.rowetel.com/ucasterisk/ip04.html">IP0X</a>
+    line of products.  So I scratched the itch.  More
+    information <a href="http://www.rowetel.com/ucasterisk/mini.html#why">here</a>.
 
 </ol>
 
index f073324356a78956d0513d7936a66f4b33fa49bc..eef2102382433d949db1583052bfa50b2c16f1c3 100644 (file)
@@ -16,7 +16,7 @@ if [ $? -eq 1 ]; then
 fi
 
 more=`echo "$QUERY_STRING" | grep -oe "more=[^&?]*" | sed -n "s/more=//p"`
-ipaddress=`ifconfig eth0 | sed -n 's/.*inet addr:\(.*\)  Bcast.*/\1/p'`
+ipaddress=`ifconfig | sed -n 's/.*inet addr:\(.*\)  Bcast.*/\1/p' | head -n 1`
 
 # Construct the web page -------------------------------
 
index 268425ba456d68c4aaee06705a870c330ac1a97c..26931b7ac7a5f78d8cc72a6449795cedecbcd518 100644 (file)
@@ -15,6 +15,15 @@ if [ $? -eq 1 ]; then
     exit
 fi
 
+# check what sort of machine we are running on.  We only support this screen for
+# IP0X
+
+cat /proc/cpuinfo | grep "CPU:.*ADSP" > /dev/null
+if [ ! $? -eq 0 ]; then
+    echo "<html>Sorry, Network configuration is only supported on the IP0X</html>"
+    exit
+fi
+
 grok_network=0
 
 if [ -f /etc/rc.d/S10network ]; then
@@ -72,11 +81,11 @@ fi
 
 # See if we have Internet connectivity, first check dns as time outs can be very slow
 
-dns_packet_loss=`ping $dns -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
+dns_packet_loss=`ping $dns -c 1 -q | sed -n 's/.*received, \(.*\)%.*/\1/p'`
 internet="no";
-if [ $dns_packet_loss == "0" ]; then
-  packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
-  if [ $packet_loss == "0" ]; then
+if [ $dns_packet_loss = "0" ]; then
+  packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)%.*/\1/p'`
+  if [ $packet_loss = "0" ]; then
     internet="yes";
   fi
 fi
index 77dd9569654428d5722cb5a089d9ad7e75fc0abb..06d3b92cd5dc30cf092c69dd4e18174b442d0b6d 100644 (file)
@@ -18,16 +18,16 @@ fi
 # See if we have Internet connectivity, first check dns as time outs can be very slow
 
 dns=`cat /etc/resolv.conf | awk '/^nameserver/ {print $2}'`
-dns_packet_loss=`ping $dns -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
+dns_packet_loss=`ping $dns -c 1 -q | sed -n 's/.*received, \(.*\)%.*/\1/p'`
 internet="no";
-if [ $dns_packet_loss == "0" ]; then
-  packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)% packet loss/\1/p'`
-  if [ $packet_loss == "0" ]; then
+if [ $dns_packet_loss = "0" ]; then
+  packet_loss=`ping google.com -c 1 -q | sed -n 's/.*received, \(.*\)%.*/\1/p'`
+  if [ $packet_loss = "0" ]; then
     internet="yes";
   fi
 fi
 
-ipaddress=`ifconfig eth0 | sed -n 's/.*inet addr:\(.*\)  Bcast.*/\1/p'`
+ipaddress=`ifconfig | sed -n 's/.*inet addr:\(.*\)  Bcast.*/\1/p' | head -n 1`
 
 # Construct the web page -------------------------------
 
index 5f65bf67bca8efed188e82a511947efa6264aca1..6c2d126e8bc9046f7303d7e25b428f183514197d 100644 (file)
@@ -22,7 +22,7 @@ gateway=`echo "$QUERY_STRING" | grep -oe "gateway=[^&?]*" | sed -n "s/gateway=//
 dns=`echo "$QUERY_STRING" | grep -oe "dns=[^&?]*" | sed -n "s/dns=//p"`
 backdoor=`echo "$QUERY_STRING" | grep -oe "backdoor=[^&?]*" | sed -n "s/backdoor=//p"`
 
-if [ $dhcp == "yes" ]; then
+if [ $dhcp = "yes" ]; then
 
   # DHCP
 
@@ -38,7 +38,7 @@ if [ $dhcp == "yes" ]; then
   fi
 fi
 
-if [ $dhcp == "no" ]; then
+if [ $dhcp = "no" ]; then
   
   # Static IP
 
index 68d50ed9e418a29d4eebd68c81dd716a3fd69ab3..18c339dfb24aaffbd3a326b02717e279912d73ff 100644 (file)
@@ -28,6 +28,11 @@ perl set_voiplines.pl $user $pass $host $stanza > /etc/asterisk/sip.conf.new
 mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.bak
 mv /etc/asterisk/sip.conf.new /etc/asterisk/sip.conf
 
+# modify extensions.conf for new provider
+
+sed -i "s#_1.,1,Dial(.*)#_1.,1,Dial(SIP/$stanza/\${EXTEN:1})#" /etc/asterisk/extensions.conf
+asterisk -rx "dialplan reload" 2>/dev/null 1 > /dev/null
+
 # get asterisk to load changes
 
 asterisk -rx "sip reload" 2>/dev/null 1 > /dev/null