# make TESTIP=boris test
test:
- rcp set_voiplines.pl voiplines.sh voiplines.pl set_ring.sh prototype.js admin.sh index.html faq.sh faq.html about.sh at-530.html ipphones.pl ipphones.sh ipphones.js voipline.jpg anphone.png phoneline.jpg ipphone.png phones.pl tooltips.html phones.sh phones.js tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www
+ rcp set_voiplines.pl set_voiplines.sh voiplines.sh voiplines.pl set_ring.sh prototype.js admin.sh index.html faq.sh faq.html about.sh at-530.html ipphones.pl ipphones.sh ipphones.js voipline.jpg anphone.png phoneline.jpg ipphone.png phones.pl tooltips.html phones.sh phones.js tick.png cross.png banner.html menu.html check_loggedin.sh logout.sh login.sh network.sh network.js set_network.sh tooltip.js tooltip.css root@$(TESTIP):/www
rcp sip.conf extensions.conf root@$(TESTIP):/etc/asterisk
+++ /dev/null
-#!/bin/sh
-# set_voipline.sh
-# # David Rowe 12 Jan 2010
-#
-# CGI to set voip line parameters in sip.conf.
-
-cat <<EOF
-<html>
-<head>
-<title>set_network.sh</title>
-<meta http-equiv="REFRESH" content="0;url=http:network.sh">
-<body>
-Please wait a few seconds.....
-</body>
-</head>
-</html>
-EOF
-
-user=`echo "$QUERY_STRING" | grep -oe "user=[^&?]*" | sed -n "s/user=//p"`
-pass=`echo "$QUERY_STRING" | grep -oe "pass=[^&?]*" | sed -n "s/pass=//p"`
-host=`echo "$QUERY_STRING" | grep -oe "host=[^&?]*" | sed -n "s/host=//p"`
-
-./set_voipline.pl $user $pass $host > /etc/asterisk/sip.conf
-
-cat <<EOF
-<html>
-<head>
-<title>set_voiplines.sh</title>
-<meta http-equiv="REFRESH" content="0;url=http:voiplines.sh">
-<body>
-Please wait a few seconds.....
-</body>
-</head>
-</html>
-EOF
\ No newline at end of file
}
close SIP;
-# generate form fields -------------------------------------------
-
-print "<tr><td>User:</td><td><input type=\"text\" name=\"user\" value=\"$user\"></td></tr>\n";
-print "<tr><td>Password:</td><td><input type=\"password\" name=\"pass\" value=\"$pass\"></td></tr>";
-print "<tr><td>Host:</td><td><input type=\"text\" name=\"host\" value=\"$host\"></td></tr>";
--- /dev/null
+#!/bin/sh
+# set_voipline.sh
+# # David Rowe 12 Jan 2010
+#
+# CGI to set voip line parameters in sip.conf.
+
+# check we are logged in
+
+echo $HTTP_COOKIE | grep "loggedin" > /dev/null
+if [ $? -eq 1 ]; then
+ echo "<html>"
+ echo "<head>"
+ echo '<meta http-equiv="REFRESH" content="0;url=http:login.sh">'
+ echo "</head>"
+ echo "</html>"
+ exit
+fi
+
+user=`echo "$QUERY_STRING" | grep -oe "user=[^&?]*" | sed -n "s/user=//p"`
+pass=`echo "$QUERY_STRING" | grep -oe "pass=[^&?]*" | sed -n "s/pass=//p"`
+host=`echo "$QUERY_STRING" | grep -oe "host=[^&?]*" | sed -n "s/host=//p"`
+
+./set_voiplines.pl $user $pass $host > /etc/asterisk/sip.conf.new
+mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.bak
+mv /etc/asterisk/sip.conf.new /etc/asterisk/sip.conf
+asterisk -rx "sip reload" 2>/dev/null 1 > /dev/null
+
+cat <<EOF
+<html>
+<head>
+<title>set_voiplines.sh</title>
+<meta http-equiv="REFRESH" content="0;url=http:voiplines.sh">
+<body>
+Please wait a few seconds.....
+</body>
+</head>
+</html>
+EOF
+