# make TESTIP=boris test
test:
- rcp 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 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
echo '<meta http-equiv="REFRESH" content="0;url=http:login.sh">'
echo "</head>"
echo "</html>"
-# exit
+ exit
fi
# extract extensions to ring and reload extensions.conf
--- /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
--- /dev/null
+#!/sbin/microperl
+# set_voiplines.pl
+# David Rowe 12 Jan 2010
+#
+# Replaces fields in sip.conf, outputs new sip.conf contents to stdout
+
+$user = $ARGV[0];
+$pass = $ARGV[1];
+$host = $ARGV[2];
+
+# slurp up voip trunk details --------------------------------
+
+open SIP, "/etc/asterisk/sip.conf";
+$state = "looking for [voip]";
+
+while (<SIP>) {
+ $next_state = $state;
+
+ if ($state eq "looking for [voip]") {
+
+ if (/^\[voip\]/) {
+ $next_state="inside [voip]";
+ #print "$state $next_state\n";
+ }
+
+ print $_;
+ }
+
+ if ($state eq "inside [voip]") {
+
+ if (/^\[/) {
+ $next_state = "finished";
+ }
+
+ if (/user=/) {
+ print "user=$user\n";
+ }
+ elsif (/secret=/) {
+ print "secret=$pass\n";
+ }
+ elsif (/host=/) {
+ print "host=$host\n";
+ }
+ else {
+ print $_;
+ }
+ }
+
+ if ($state eq "finished") {
+ print $_;
+ }
+
+ $state = $next_state;
+}
+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
-# voipline.sh
-# David Rowe 12 Jan 2010
-# VOIP Line screen for Easy Asterisk GUI
-
-# 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
-
-# Construct the web page -------------------------------
-
-cat <<EOF
-<script src="prototype.js"></script>
-<link href="astman.css" media="all" rel="Stylesheet" type="text/css" />
-<script type="text/javascript" src="tooltip.js"></script>
-<link rel="stylesheet" href="tooltip.css" type="text/css" />
-EOF
-
-cat << EOF
-<html>
-<title>Easy Asterisk - VOIP Line</title>
-EOF
-
-cat tooltips.html
-echo '<table align="center" width=800>'
-cat banner.html
-echo " <tr>"
-cat menu.html
-cat <<EOF
-
- <td valign="top">
-
- <table align="right" width=600>
- <tr><td> </td></tr>
- <form action="voipline.sh" method="get">
- <tr><td align="left" valign="top"><h2>VOIP Line</h2></td></tr>
-
- <tr><td> </td></tr>
-EOF
-./voipline.pl
-
-cat <<EOF
- <tr><td> </td></tr>
- <tr><td><input type="submit" value="OK"></td></tr>
-
- </form>
-
- </table>
- </form>
-
- </td>
-
- </tr>
-
-</table>
-</body>
-</html>
-EOF
-
$state = "looking for [voip]";
while (<SIP>) {
+ $next_state = $state;
+
if ($state eq "looking for [voip]") {
if (/^\[voip\]/) {
- $state="inside [voip]";
+ $next_state="inside [voip]";
+ #print "$state $next_state\n";
}
}
- if (($state eq "inside [voip]") {
+ if ($state eq "inside [voip]") {
+ #print $_;
if (/^\[/) {
- $state = "finished";
+ $next_state = "finished";
+ #print "$next_state\n";
}
if (/user=(.*)/) {
$host = $1;
}
}
+
+ $state = $next_state;
}
close SIP;
-# generate form ---------------------------------------------
+# 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>";
+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
+# voiplines.sh
+# David Rowe 12 Jan 2010
+# VOIP Line screen for Easy Asterisk GUI
+
+# 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
+
+# Construct the web page -------------------------------
+
+cat <<EOF
+<script src="prototype.js"></script>
+<link href="astman.css" media="all" rel="Stylesheet" type="text/css" />
+<script type="text/javascript" src="tooltip.js"></script>
+<link rel="stylesheet" href="tooltip.css" type="text/css" />
+EOF
+
+cat << EOF
+<html>
+<title>Easy Asterisk - VOIP Line</title>
+EOF
+
+cat tooltips.html
+echo '<table align="center" width=800>'
+cat banner.html
+echo " <tr>"
+cat menu.html
+cat <<EOF
+
+ <td valign="top">
+
+ <table align="right" width=600>
+ <tr><td> </td></tr>
+ <form action="set_voiplines.sh" method="get">
+ <tr><td align="left" valign="top"><h2>VOIP Line</h2></td></tr>
+
+ <tr><td> </td></tr>
+EOF
+
+./voiplines.pl
+
+cat <<EOF
+ <tr><td> </td></tr>
+ <tr><td><input type="submit" value="OK"></td></tr>
+
+ </form>
+
+ </table>
+ </form>
+
+ </td>
+
+ </tr>
+
+</table>
+</body>
+</html>
+EOF
+