From: drowe67 Date: Sun, 3 Jan 2010 22:59:50 +0000 (+0000) Subject: set_network working, needs more testing X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=33e8bd2e0fadda31c957cfe311a1f46f8528d8fc;p=freetel-svn-tracking.git set_network working, needs more testing git-svn-id: https://svn.code.sf.net/p/freetel/code@85 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/easy-asterisk-gui/easy.js b/easy-asterisk-gui/easy.js index 6f9690d0..26200581 100644 --- a/easy-asterisk-gui/easy.js +++ b/easy-asterisk-gui/easy.js @@ -37,20 +37,14 @@ function isIP(obj) { return ip; } -function validateForm(thisForm) { - var valid = true; - - with (thisForm) { - valid = isISP(ipaddress); - } - - return !valid; -} - function localInit() { if (init_dhcp == "yes") { $('dhcp').checked = true; + $('ipaddress').disabled = 1; + $('netmask').disabled = 1; + $('gateway').disabled = 1; + $('dns').disabled = 1; } else { $('static').checked = true; diff --git a/easy-asterisk-gui/set_network.sh b/easy-asterisk-gui/set_network.sh index 95a6b761..01163034 100755 --- a/easy-asterisk-gui/set_network.sh +++ b/easy-asterisk-gui/set_network.sh @@ -1,24 +1,17 @@ #!/bin/sh # set_network.sh # -# A system call from AJAM/Asterisk sets the network parameters of an IP0X using -# this script -# -# ./set_network yes|no [ipaddress] [netmask] [gateway] [dns] - -echo `date` " set_network.sh $1 $2 $3 $4 $5" >> /tmp/easy_gui.log +# CGI to set network parameters of an IP0X. -cat << EOF - -EOF -env -cat < -EOF +dhcp=`echo "$QUERY_STRING" | grep -oe "dhcp=[^&]*" | sed -n "s/dhcp=//p"` +ipaddress=`echo "$QUERY_STRING" | grep -oe "ipaddress=[^&]*" | sed -n "s/ipaddress=//p"` +netmask=`echo "$QUERY_STRING" | grep -oe "netmask=[^&]*" | sed -n "s/netmask=//p"` +gateway=`echo "$QUERY_STRING" | grep -oe "gateway=[^&]*" | sed -n "s/gateway=//p"` +dns=`echo "$QUERY_STRING" | grep -oe "dns=[^&]*" | sed -n "s/dns=//p"` -exit +echo `date` " set_network.sh $dhcp $ipaddress $netmask $gateway $dns" >> /tmp/easy_gui.log -if [ $1 == "yes" ]; then +if [ $dhcp == "yes" ]; then # DHCP @@ -34,16 +27,10 @@ if [ $1 == "yes" ]; then fi fi -if [ $1 == "no" ]; then +if [ $dhcp == "no" ]; then # Static IP - # check correct number of arguments - - if [ $# -le 4 ]; then - exit - fi - if [ -f /etc/rc.d/S10network ]; then /etc/init.d/network stop /etc/init.d/network disable @@ -51,12 +38,20 @@ if [ $1 == "no" ]; then fi sed -i "s/DHCPD=.*/DHCPD=no/g" /etc/init.d/network-static - sed -i "s/IPADDRESS=.*/IPADDRESS=\"$2\"/g" /etc/init.d/network-static - sed -i "s/NETMASK=.*/NETMASK=\"$3\"/g" /etc/init.d/network-static - sed -i "s/GATEWAY=.*/GATEWAY=\"$4\"/g" /etc/init.d/network-static - sed -i "s/DNS=.*/DNS=\"$5\"/g" /etc/init.d/network-static + sed -i "s/IPADDRESS=.*/IPADDRESS=\"$ipaddress\"/g" /etc/init.d/network-static + sed -i "s/NETMASK=.*/NETMASK=\"$netmask\"/g" /etc/init.d/network-static + sed -i "s/GATEWAY=.*/GATEWAY=\"$gateway\"/g" /etc/init.d/network-static + sed -i "s/DNS=.*/DNS=\"$dns\"/g" /etc/init.d/network-static /etc/init.d/network-static stop /etc/init.d/network-static start - exit fi +cat < + +set_network.sh + + + + +EOF \ No newline at end of file diff --git a/easy-asterisk-gui/test.sh b/easy-asterisk-gui/test.sh index 7a63348b..bed3e7ae 100644 --- a/easy-asterisk-gui/test.sh +++ b/easy-asterisk-gui/test.sh @@ -43,10 +43,10 @@ cat << EOF Static DHCP - IP Address: - Netmask: - Gateway: - DNS: + IP Address: + Netmask: + Gateway: + DNS: