git-svn-id: https://svn.code.sf.net/p/freetel/code@525 01035d8c-6547-0410-b346-abe4f9...
authorhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 31 May 2012 06:48:57 +0000 (06:48 +0000)
committerhorse69 <horse69@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 31 May 2012 06:48:57 +0000 (06:48 +0000)
mini-asterisk-gui2/cgi-bin/install.cgi [new file with mode: 0755]
mini-asterisk-gui2/cgi-bin/reset.cgi [new file with mode: 0755]
mini-asterisk-gui2/cgi-bin/setpassword.cgi [new file with mode: 0755]
mini-asterisk-gui2/cgi-bin/upgrade.cgi [new file with mode: 0755]

diff --git a/mini-asterisk-gui2/cgi-bin/install.cgi b/mini-asterisk-gui2/cgi-bin/install.cgi
new file mode 100755 (executable)
index 0000000..29b936e
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+# install.cgi
+# Ian Roberts 31 May 2012
+#
+# CGI to install new firmware....
+# runs a shellscript as root
+
+cat <<EOF
+Content-type: text/html
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="-1"></head></head>
+<body>
+EOF
+
+
+# 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
+
+
+
+if [ $mach != "ip0x" ] ; then
+       echo "<html>Sorry, only supported on the IP0X</html>"
+       exit
+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
+
+cat <<EOF
+</body>
+</html>
+EOF
diff --git a/mini-asterisk-gui2/cgi-bin/reset.cgi b/mini-asterisk-gui2/cgi-bin/reset.cgi
new file mode 100755 (executable)
index 0000000..984bb49
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/sh
+# reset.cgi
+# Ian Roberts 31 May 2012
+#
+# CGI to reset ipox
+
+cat <<EOF
+Content-type: text/html
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="-1"></head></head>
+<body>
+EOF
+
+
+# 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
+
+
+
+if [ $mach != "ip0x" ] ; then
+       echo "Sorry, only supported on the IP0X"
+cat <<EOF
+</body>
+</html>
+EOF
+       exit
+fi
+
+# reset the dialplan files
+cp /etc/asterisk/extensions.conf.def /etc/asterisk/extensions.conf
+cp /etc/asterisk/sip.conf.def /etc/asterisk/sip.conf
+# reload the dialplans in asterisk
+asterisk -rx "sip reload" 2>/dev/null 1 > /dev/null
+asterisk -rx "dialplan reload" 2>/dev/null 1 > /dev/null
+
+
+cat <<EOF
+</body>
+</html>
+EOF
diff --git a/mini-asterisk-gui2/cgi-bin/setpassword.cgi b/mini-asterisk-gui2/cgi-bin/setpassword.cgi
new file mode 100755 (executable)
index 0000000..b0765e5
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+# setpassword.cgi
+# Ian Roberts 31 May 2012
+#
+# CGI to set password on ipox
+
+cat <<EOF
+Content-type: text/html
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="-1"></head></head>
+<body>
+EOF
+
+
+# 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
+
+
+
+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
+
+
+cat <<EOF
+</body>
+</html>
+EOF
diff --git a/mini-asterisk-gui2/cgi-bin/upgrade.cgi b/mini-asterisk-gui2/cgi-bin/upgrade.cgi
new file mode 100755 (executable)
index 0000000..e22f5d2
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+# upgrade.cgi
+# Ian Roberts 31 May 2012
+#
+# CGI to upgrade mini-asterisk-gui
+
+cat <<EOF
+Content-type: text/html
+
+<html>
+<head>
+<meta http-equiv="cache-control" content="no-cache">
+<meta http-equiv="pragma" content="no-cache">
+<meta http-equiv="expires" content="-1"></head></head>
+<body>
+EOF
+
+
+# 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
+
+
+
+if [ $mach != "ip0x" ] ; then
+       echo "Sorry, only supported on the IP0X"
+cat <<EOF
+</body>
+</html>
+EOF
+       exit
+fi
+
+# remove, update and install mini-asterisk-gui
+
+rev_before=`grep -oe "Revision: [0-9]*" /www/about.sh`
+echo "<strong>Current $rev_before</strong><br>"
+echo "<strong>Removing $ver_before</strong><br>"
+ipkg remove mini-asterisk-gui | tr '\n' '#' | sed -n 's/\#/<br>/pg'
+echo "<strong>Installing...</strong><br>"
+ipkg update | tr '\n' '#' | sed -n 's/\#/<br>/pg'
+ipkg install mini-asterisk-gui | tr '\n' '#' | sed -n 's/\#/<br>/pg'
+
+
+cat <<EOF
+</body>
+</html>
+EOF