restart works
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 15 Jan 2010 21:36:25 +0000 (21:36 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 15 Jan 2010 21:36:25 +0000 (21:36 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@116 01035d8c-6547-0410-b346-abe4f91aad63

easy-asterisk-gui/Makefile
easy-asterisk-gui/admin.sh
easy-asterisk-gui/login.sh
easy-asterisk-gui/phones.pl
easy-asterisk-gui/restart.sh [new file with mode: 0644]
easy-asterisk-gui/tooltips.html
easy-asterisk-gui/voiplines.pl

index bc6998afd38162ef4f12858a42afdea599dceadc..9f77282ec49c45159535f017999e9fe0a181e43e 100644 (file)
@@ -8,5 +8,5 @@
 #        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
index b15373e0ae234c79dd090a71d7edb4b9ee3e026f..f5c2fddd77e511cb7c55ad13c1aa9654b6e7caf3 100644 (file)
@@ -15,6 +15,36 @@ if [ $? -eq 1 ]; then
     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
@@ -45,18 +75,18 @@ cat <<EOF
 
       <tr><td>&nbsp</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>&nbsp</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>&nbsp</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>&nbsp</td></tr>
index db792eeaa79f4a7d2913510b7b458e6df9e0713b..f195f8da5bbc188923d2657b1e904831be9669e2 100644 (file)
@@ -3,10 +3,9 @@
 # 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 -------------------------------
 
@@ -23,17 +22,16 @@ EOF
     <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
@@ -43,10 +41,10 @@ else
        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
index b96d334c24b33a34379e219e46ab25eb64cc32e8..98db525f354458a321d378703043673c863c2cb1 100755 (executable)
@@ -80,10 +80,10 @@ while (<EXT>) {
 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";
@@ -97,9 +97,10 @@ while (<SIP>) {
            #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;
@@ -110,7 +111,24 @@ while (<SIP>) {
 
 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">';
 
@@ -187,7 +205,7 @@ $tooltip_voipline_ip = "onMouseOver=\"popUp(event,'phone_voipline_ip')\" onmouse
 $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";
     }
diff --git a/easy-asterisk-gui/restart.sh b/easy-asterisk-gui/restart.sh
new file mode 100644 (file)
index 0000000..027dcf2
--- /dev/null
@@ -0,0 +1,14 @@
+#!/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
+
index b28082e832ea0c9eaa6dbb9918b5ff2e282009c5..dab4bffbc5b464ce60e8904b03815bcfe9bb18cb 100644 (file)
                         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>
+
index 78c6f81e60510547cea507843be366d833965146..64b5a2cca55f5c7254efa4479aa2e87126097b21 100755 (executable)
@@ -76,7 +76,7 @@ open SIP, "sipshowregistry.txt";
 while (<SIP>) { 
     if (/^(.*):.*(Registered)/) {
         $voip{$1} = $2;
-       print "'$1' '$2' $voip{$1}\n";
+       #print "'$1' '$2' $voip{$1}\n";
     }
 }
 
@@ -121,7 +121,7 @@ print "<tr $tt_user><td>User:</td><td><input type=\"text\" name=\"user\" id=\"us
 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\" />";