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;
#!/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
-<html>
-EOF
-env
-cat <<EOF
-</html>
-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
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
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 <<EOF
+<html>
+<head>
+<title>set_network.sh</title>
+<meta http-equiv="REFRESH" content="0;url=http:test.sh">
+</head>
+</html>
+
+EOF
\ No newline at end of file
<td><input type="radio" id="static" name="dhcp" value="no" onClick="doStatic()">Static</td>
<td><input type="radio" id="dhcp" name="dhcp" value="yes" onClick="doDHCP()">DHCP</td>
</tr>
- <tr><td>IP Address:</td><td><input type="text" name="ipaddress" id="ipaddress" onBlur="isIP(this)" disabled=1></td></tr>
- <tr><td>Netmask:</td><td><input type="text" name="netmask" id="netmask" onBlur="isIP(this)" disabled=1></td></tr>
- <tr><td>Gateway:</td><td><input type="text" name="gateway" id="gateway" onBlur="isIP(this)" disabled=1></td></tr>
- <tr><td>DNS:</td><td><input type="text" name="dns" id="dns" onBlur="isIP(this)" disabled=1></td></tr>
+ <tr><td>IP Address:</td><td><input type="text" name="ipaddress" id="ipaddress" onBlur="isIP(this)"></td></tr>
+ <tr><td>Netmask:</td><td><input type="text" name="netmask" id="netmask" onBlur="isIP(this)"></td></tr>
+ <tr><td>Gateway:</td><td><input type="text" name="gateway" id="gateway" onBlur="isIP(this)"></td></tr>
+ <tr><td>DNS:</td><td><input type="text" name="dns" id="dns" onBlur="isIP(this)"></td></tr>
<tr><td><input id="networkapply" type="submit" value="Apply"></td></tr>
</tr>
</table>