# make TESTIP=boris test
test:
- rcp voiplines.js 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 restart.sh voiplines.js 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
exit
fi
+# set password CGI
+
+echo "$QUERY_STRING" | grep -oe "pass=" > /dev/null
+if [ $? -eq 0 ]; then
+ pass=`echo "$QUERY_STRING" | grep -oe "pass=[^&?]*" | sed -n "s/pass=//p"`
+ passwd_cmdline $pass
+fi
+
+# restart CGI
+
+echo "$QUERY_STRING" | grep -oe "restart=1" > /dev/null
+if [ $? -eq 0 ]; then
+
+# kill cookie to log out. This ensures hitting refresh wont run
+# the restart process again
+
+cat <<EOF
+Content-type: text/html
+Set-Cookie: loggedin=1; expires=Thursday, 01-Jan-98 12:00:00 GMT
+
+<head>
+<title>Easy Asterisk - Restart</title>
+</head>
+<body>
+<h2>Restarting...come back in 1 minute</h2>
+</body>
+EOF
+reboot
+fi
+
# Construct the web page -------------------------------
cat <<EOF
<tr><td> </td></tr>
<tr><td colspan="2"><h3>Change Phone System Password</h2></td></tr>
- <tr><td>User:</td><td><input type="text" name="user" ></td></tr>
- <tr><td>Current Password:</td><td><input type="password" name="oldpass" ></td></tr>
- <tr><td>New Password:</td><td><input type="password" name="newpass" ></td></tr>
+ <tr><td>New Password:</td><td><input type="password" name="pass" ></td></tr>
<tr><td> </td></tr>
- <tr><td></td><td>Default user/password is root/uClinux</td>
+ <tr><td></td><td>Default password is uClinux</td>
<tr><td><input type="submit" value="Set Password"></td></tr>
</form>
<tr><td> </td></tr>
- <tr><td colspan="2"><h3>Restart Phone System</h2></td></tr>
- <form action="admin.sh?reboot=1" method="get">
- <tr><td><input type="submit" value="Restart"></td></tr>
+ <tr><td colspan="2"><h3>Restart Phone System</h2></td></tr>
+ <form action="admin.sh" method="get">
+ <tr><td><input type="hidden" name="restart" value="1"></td></tr>
+ <tr><td onMouseOver="popUp(event,'admin_restart')" onmouseout="popUp(event,'admin_restart')">
+ <input type="submit" value="Restart"></td></tr>
</form>
<tr><td> </td></tr>
# David Rowe 4 Jan 2010
# CGI for Easy Asterisk login GUI
-user=`echo "$QUERY_STRING" | grep -oe "user=[^&?]*" | sed -n "s/user=//p"`
pass=`echo "$QUERY_STRING" | grep -oe "pass=[^&?]*" | sed -n "s/pass=//p"`
-echo $QUERY_STRING | grep user > /dev/null
+echo $QUERY_STRING | grep pass > /dev/null
if [ $? -eq 1 ]; then
# Display form -------------------------------
<table align="center" width=600>
<tr><td colspan="2" align="left"><h2>Login</h2></td>
<tr>
- <tr><td>User:</td><td><input type="text" name="user" ></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" ></td></tr>
<tr><td><input type="submit" value="Login"></td></tr>
</tr>
- <tr><td></td><td>Default user/password is root/uClinux</td>
+ <tr><td></td><td>Default password is uClinux</td>
</table>
</form>
</html>
EOF
else
- testuser $user $pass
+ testuser root $pass
if [ $? -eq 0 ]; then
# login sucessful
echo "<head>"
echo "<title>Easy Asterisk - Login</title>"
echo '<meta http-equiv="REFRESH" content="0;url=http:phones.sh">'
+ echo "</head>"
echo "<body>"
echo "Please wait a few seconds....."
echo "</body>"
- echo "</head>"
else
# login failed
cat <<EOF
close EXT;
+# work out which IP phones are registered -----------------------------------
+
my %sip = (); # SIP IP phone status keyed on sip.conf names (6011,6012 etc)
# if no entry we can't see IP phone device
-my %voip = (); # SIP trunks status keyed on sip.conf names
- # if no entry we can't see SIP trunk
my %ipad = (); # IP address of SIP device keyed on sip.conf names
open SIP, "sipshowpeers.txt";
#print "'$1'\n";
}
}
- if (/^(voip[0-9]*)[\s\/].*(OK)/) {
- $voip{$1} = $2;
- #print "'$1' '$2' $voip{$1}\n";
+
+ if (/^(.*)\/.*(OK)/) {
+ #$sip{$1} = $2;
+ #print "'$1' '$2' $sip{$1}\n";
$e = $1;
if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) {
$ipad{$e} = $1;
close SIP;
-# start phones ringing form
+# Determine if Asterisk can see current voip line (SIP trunk)
+# sipshowpeers.txt needs to be generated before calling this perl
+# script
+
+my %voip = (); # SIP trunks status keyed on sip.conf stanza name/username
+ # if no entry we can't see SIP trunk
+
+open SIP, "sipshowregistry.txt";
+while (<SIP>) {
+ if (/^(.*):.*(Registered)/) {
+ $voip{$1} = $2;
+ #print "'$1' '$2' $voip{$1}\n";
+ }
+}
+
+close SIP;
+
+# start phones ringing form -------------------------------------------
print '<form action="set_ring.sh?" method="get">';
$tooltip_voipline_prefix = "onMouseOver=\"popUp(event,'phone_voipline_prefix')\" onmouseout=\"popUp(event,'phone_voipline_prefix')\"";
foreach $s (sort keys %voip) {
- if ($voip{$s} eq "OK") {
+ if ($voip{$s} eq "Registered") {
$icon = "<img src=\"tick.png\" alt=\"VOIP Line OK\" />";
print "<tr><td $tooltip_voipline_prefix>1</td><td $tooltip_voipline>VOIP Line</td><td $tooltip_voipline_ip>$ipad{$s}</td><td></td><td>$icon</td></tr>\n";
}
--- /dev/null
+#!/bin/sh
+# restart.sh
+# David Rowe 15 Jan 2010
+# Restart script for Easy Asterisk GUI
+
+cat <<EOF
+<html>
+<title>Easy Asterisk - Restart</title>
+<meta http-equiv="REFRESH" content="2;url=http:login.sh"
+<h2>Restarting...come back in 1 minute</h2>
+</html>
+EOF
+reboot
+
Internet Telephony Service Provider. Refresh
your browser to update.</div>
+<div id="admin_restart" class="tip">
+ Press this button to restart your phone
+ system. This is the same as turning the power
+ off and back on. </div>
+
while (<SIP>) {
if (/^(.*):.*(Registered)/) {
$voip{$1} = $2;
- print "'$1' '$2' $voip{$1}\n";
+ #print "'$1' '$2' $voip{$1}\n";
}
}
print "<tr $tt_pass><td>Password:</td><td><input type=\"password\" name=\"pass\" id=\"pass\" value=\"$pass{$provider_current}\"></td></tr>\n";
print "<tr $tt_host><td>Host:</td><td><input type=\"text\" name=\"host\" id=\"host\" value=\"$host{$provider_current}\"></td></tr>\n";
-print "\nXXX $provider_current $stanza{$provider_current} $voip{$stanza{$provider_current}}\n";
+#print "\nXXX $provider_current $stanza{$provider_current} $voip{$stanza{$provider_current}}\n";
if ($voip{$stanza{$provider_current}} eq "Registered") {
$icon = "<img src=\"tick.png\" alt=\"OK\" />";