upgrade and fimrware upgrade working on IP0X
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 28 Jan 2010 08:19:38 +0000 (08:19 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 28 Jan 2010 08:19:38 +0000 (08:19 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@134 01035d8c-6547-0410-b346-abe4f91aad63

mini-asterisk-gui/README.txt
mini-asterisk-gui/cgi-bin/admin.sh
mini-asterisk-gui/cgi-bin/tooltips.html

index b16fc3ba19faa22b090caf6a0d727ffb17dc049d..64f3859a9c7d374aa023257e253318afebc63692 100644 (file)
@@ -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
+
index c89a30b8f028c28902147de225a974b2f80745bb..00a4d0aaf76672ca5e4a9c42a713c6c70edaa52c 100644 (file)
@@ -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 <<EOF
+       <html>
+       <head>
+       <title>Mini Asterisk - Upgrade</title>
+       </head>
+       <body>
+       Sorry upgrade only supported on IP0X at this time
+       </body>
+       </head>
+       </html>
+EOF
+    fi
+
     cat <<EOF
     <html>
     <head>
@@ -67,6 +84,7 @@ if [ $? -eq 0 ]; then
     <body>
     <h2>Upgrading...</h2>
 EOF
+
     rev_before=`grep -oe "Revision: [0-9]*" /www/about.sh`
     echo "<strong>Current $rev_before</strong><br>"
     echo "<strong>Removing $ver_before</strong><br>"
@@ -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 "<html>Sorry Firmware Upgreade only supported on IP04</html>"
+    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 <<EOF
@@ -156,7 +196,7 @@ cat <<EOF
       <form action="admin.sh" method="get">
       <tr onMouseOver="popUp(event,'admin_firmware')" onmouseout="popUp(event,'admin_firmware')">
           <td>Firmware URL:</td>
-          <td><input type="text" name="firmwareurl" ></td>
+          <td><input type="text" size="45" name="firmwareurl" ></td>
           <td><input type="submit" value="Install"></td>
       </tr>
       </form>
index 2f5c46d276bbe04e9d3f2c9aa2ba044112d60da4..76373109b0ee67ba8c7ee1e0b85a27f9a33181db 100644 (file)
                         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.</div>
+                       firmware requires an Internet connection.  the
+                       full URL Must be entered,
+                       e.g. http://rowetel.com/ucasterisk/mini/test.sh</div>