From: drowe67 Date: Thu, 28 Jan 2010 08:19:38 +0000 (+0000) Subject: upgrade and fimrware upgrade working on IP0X X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=5628ccc36c43ed38b6285990eacb6cba422282bb;p=freetel-svn-tracking.git upgrade and fimrware upgrade working on IP0X git-svn-id: https://svn.code.sf.net/p/freetel/code@134 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/mini-asterisk-gui/README.txt b/mini-asterisk-gui/README.txt index b16fc3ba..64f3859a 100644 --- a/mini-asterisk-gui/README.txt +++ b/mini-asterisk-gui/README.txt @@ -127,6 +127,11 @@ For Auto-detection of Zap ports Mini Asterisk looks at /etc/zapata.conf, so you may need this set up correctly for your analog hardware. On the IP0X this happens automatically. +The scripts need to run as root to run asterisk commands. This is +probably OK an on IP0X but not a good idea on an x86. I am not happy +with this security model and would appreciate any suggestions on how +to improve it. + [[install]] Installation ------------ @@ -225,3 +230,32 @@ Check Out: $ svn co https://freetel.svn.sourceforge.net/svnroot/freetel/mini-asterisk-gui +[[test]] +Testing and debugging scripts +----------------------------- + +. To download all the GUi scripts to an IP0X machine with the host name "ip04": + + [david@bunny mini-asterisk-gui]$ make HOST=ip04 test + +. A simple cookie is used to indicate logged in status, so to run + scripts for each screen from the command line (for example to spot + script syntax errors): + +IP0X: + + root:/www> export HTTP_COOKIE="loggedin=1" ; sh admin.sh + + If you encounter a syntax error when testing a script on an IP0X + then running the same script on an x86 can be useful as it has much + better error reporting: + +x86: + + [david@host cgi-bin]$ export HTTP_COOKIE="loggedin=1" ; sh admin.sh + +. The -x option at the stop of any sheel script can be useful to watch + execution on an IP0X: + + #!/bin/sh -x + diff --git a/mini-asterisk-gui/cgi-bin/admin.sh b/mini-asterisk-gui/cgi-bin/admin.sh index c89a30b8..00a4d0aa 100644 --- a/mini-asterisk-gui/cgi-bin/admin.sh +++ b/mini-asterisk-gui/cgi-bin/admin.sh @@ -59,6 +59,23 @@ fi echo "$QUERY_STRING" | grep -oe "upgrade=1" > /dev/null 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 + fi + cat < @@ -67,6 +84,7 @@ if [ $? -eq 0 ]; then

Upgrading...

EOF + rev_before=`grep -oe "Revision: [0-9]*" /www/about.sh` echo "Current $rev_before
" echo "Removing $ver_before
" @@ -84,6 +102,28 @@ EOF exit fi +# Install New Firmware CGI ---------------------------------------------------- +# this is just a nasty option to run an arbitrary script as root! +# not a good idea on x86 platforms...but a nice way of upgrading IP0X + +echo "$QUERY_STRING" | grep -oe "firmwareurl=" > /dev/null +if [ $? -eq 0 ]; then + + h=`hostname` + if [ ! $h == "ip04" ]; then + echo "Sorry Firmware Upgreade only supported on IP04" + fi + + firmwareurl=`echo "$QUERY_STRING" | grep -oe "firmwareurl=[^&?]*" | sed -n "s/firmwareurl=//p"` + # convert URL encoded string, this can just handle : and / so be careful + # with script names + firmwareurl=`echo $firmwareurl | sed -e "s/%3A/:/" -e "s_%2F_/_g"` + wget $firmwareurl + filename=`echo $firmwareurl | sed 's_^.*/__'` + sh $filename + exit +fi + # Construct the web page ------------------------------- cat < Firmware URL: - + diff --git a/mini-asterisk-gui/cgi-bin/tooltips.html b/mini-asterisk-gui/cgi-bin/tooltips.html index 2f5c46d2..76373109 100644 --- a/mini-asterisk-gui/cgi-bin/tooltips.html +++ b/mini-asterisk-gui/cgi-bin/tooltips.html @@ -144,6 +144,7 @@ Enter the URL of a firmware update script. This option can be used to install new firmware on your Phone System. Installing new - firmware requires an Internet - connection. + firmware requires an Internet connection. the + full URL Must be entered, + e.g. http://rowetel.com/ucasterisk/mini/test.sh