From da8a9488e040eb523f7ab7deb147e7bd145370e0 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Wed, 3 Feb 2010 05:38:35 +0000 Subject: [PATCH] clean up for first attempt at running on x86 git-svn-id: https://svn.code.sf.net/p/freetel/code@137 01035d8c-6547-0410-b346-abe4f91aad63 --- mini-asterisk-gui/README.txt | 95 ++++++++++++++++------ mini-asterisk-gui/cgi-bin/about.sh | 2 +- mini-asterisk-gui/cgi-bin/admin.sh | 43 ++++++---- mini-asterisk-gui/cgi-bin/faq.html | 24 ++++-- mini-asterisk-gui/cgi-bin/ipphones.sh | 2 +- mini-asterisk-gui/cgi-bin/network.sh | 17 +++- mini-asterisk-gui/cgi-bin/phones.sh | 10 +-- mini-asterisk-gui/cgi-bin/set_network.sh | 4 +- mini-asterisk-gui/cgi-bin/set_voiplines.sh | 5 ++ 9 files changed, 141 insertions(+), 61 deletions(-) diff --git a/mini-asterisk-gui/README.txt b/mini-asterisk-gui/README.txt index a6b9c660..59f91609 100644 --- a/mini-asterisk-gui/README.txt +++ b/mini-asterisk-gui/README.txt @@ -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 (default: don't care) +#server.username = "wwwrun" -. I use lighttpd as the web server, the /etc/lighttpd.conf lines -required are: +## change uid to (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". diff --git a/mini-asterisk-gui/cgi-bin/about.sh b/mini-asterisk-gui/cgi-bin/about.sh index 9cf948d8..8c4b6f00 100644 --- a/mini-asterisk-gui/cgi-bin/about.sh +++ b/mini-asterisk-gui/cgi-bin/about.sh @@ -40,7 +40,7 @@ cat <

About

EOF -echo ' Mini Asterisk Revision: 132 ' +echo ' Mini Asterisk Revision: 134 ' echo '  ' echo ' Brought to you by the Free Telephony Project' echo ' ' diff --git a/mini-asterisk-gui/cgi-bin/admin.sh b/mini-asterisk-gui/cgi-bin/admin.sh index 00a4d0aa..82fd9c9a 100644 --- a/mini-asterisk-gui/cgi-bin/admin.sh +++ b/mini-asterisk-gui/cgi-bin/admin.sh @@ -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 "Sorry, only supported on the IP0X" + 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 "Sorry, only supported on the IP0X" + 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 < - - Mini Asterisk - Upgrade - - - Sorry upgrade only supported on IP0X at this time - - - -EOF + echo "Sorry, only supported on the IP0X" + exit fi cat <Sorry Firmware Upgreade only supported on IP04" + if [ $mach != "ip0x" ] ; then + echo "Sorry, only supported on IP0X" + exit fi firmwareurl=`echo "$QUERY_STRING" | grep -oe "firmwareurl=[^&?]*" | sed -n "s/firmwareurl=//p"` diff --git a/mini-asterisk-gui/cgi-bin/faq.html b/mini-asterisk-gui/cgi-bin/faq.html index dd6258e5..bbe162ac 100644 --- a/mini-asterisk-gui/cgi-bin/faq.html +++ b/mini-asterisk-gui/cgi-bin/faq.html @@ -1,12 +1,24 @@
    -
  1. Transfer a Call +
  2. Where can I get Support: You can try the + Free Telephony Project Mailing List. -
  3. Answer a call on another ringing phone: 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. +
  4. Answer a call on another ringing phone: 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. + +
  5. Put a call on hold/transfer: 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. + +
  6. Why another Asterisk GUI I had some specific + needs for a light weight, very easy to use GUI for + the IP0X + line of products. So I scratched the itch. More + information here.
diff --git a/mini-asterisk-gui/cgi-bin/ipphones.sh b/mini-asterisk-gui/cgi-bin/ipphones.sh index f0733243..eef21023 100644 --- a/mini-asterisk-gui/cgi-bin/ipphones.sh +++ b/mini-asterisk-gui/cgi-bin/ipphones.sh @@ -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 ------------------------------- diff --git a/mini-asterisk-gui/cgi-bin/network.sh b/mini-asterisk-gui/cgi-bin/network.sh index 268425ba..26931b7a 100644 --- a/mini-asterisk-gui/cgi-bin/network.sh +++ b/mini-asterisk-gui/cgi-bin/network.sh @@ -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 "Sorry, Network configuration is only supported on the IP0X" + 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 diff --git a/mini-asterisk-gui/cgi-bin/phones.sh b/mini-asterisk-gui/cgi-bin/phones.sh index 77dd9569..06d3b92c 100644 --- a/mini-asterisk-gui/cgi-bin/phones.sh +++ b/mini-asterisk-gui/cgi-bin/phones.sh @@ -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 ------------------------------- diff --git a/mini-asterisk-gui/cgi-bin/set_network.sh b/mini-asterisk-gui/cgi-bin/set_network.sh index 5f65bf67..6c2d126e 100644 --- a/mini-asterisk-gui/cgi-bin/set_network.sh +++ b/mini-asterisk-gui/cgi-bin/set_network.sh @@ -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 diff --git a/mini-asterisk-gui/cgi-bin/set_voiplines.sh b/mini-asterisk-gui/cgi-bin/set_voiplines.sh index 68d50ed9..18c339df 100644 --- a/mini-asterisk-gui/cgi-bin/set_voiplines.sh +++ b/mini-asterisk-gui/cgi-bin/set_voiplines.sh @@ -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 -- 2.25.1