From b372c942694046b4f994ee894808615953107226 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 4 Jul 2014 09:47:37 +0000 Subject: [PATCH] Work on registration provision and reboot so that it works with the Cisco SPA, Yealink, Grandstream phones. --- app/registrations/cmd.php | 7 ++--- .../status_registrations_inc.php | 6 ++--- .../scripts/app/event_notify/index.lua | 26 ++++++++++++------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/registrations/cmd.php b/app/registrations/cmd.php index e015c85e10..2ebed0614e 100644 --- a/app/registrations/cmd.php +++ b/app/registrations/cmd.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2013 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): @@ -45,6 +45,7 @@ else { $rdr = check_str($_GET['rdr']); $profile = check_str($_GET['profile']); $domain = check_str($_GET['domain']); + $show = check_str($_GET['show']); $user = check_str($_GET['user']); $agent = check_str($_GET['agent']); @@ -79,7 +80,7 @@ else { $command = "sofia profile ".$profile." flush_inbound_reg ".$user." reboot"; } else { - $command = "lua app.lua event_notify ".$cmd." ".$profile." ".$user." ".$vendor; + $command = "lua app.lua event_notify ".$profile." ".$cmd." ".$user." ".$vendor; //if ($cmd == "check_sync") { // $command = "sofia profile ".$profile." check_sync ".$user; @@ -100,7 +101,7 @@ else { echo $response; } else { - header("Location: status_registrations.php?profile=internal"); + header("Location: status_registrations.php?profile=".$profile."&show=".$show); } ?> \ No newline at end of file diff --git a/app/registrations/status_registrations_inc.php b/app/registrations/status_registrations_inc.php index 4134ce00c1..94dd4fc888 100644 --- a/app/registrations/status_registrations_inc.php +++ b/app/registrations/status_registrations_inc.php @@ -173,9 +173,9 @@ require_once "resources/check_auth.php"; echo " ".$row['network-port']." \n"; echo " ".$row['status']." \n"; echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; echo " \n"; echo "\n"; if ($c==0) { $c=1; } else { $c=0; } diff --git a/resources/install/scripts/app/event_notify/index.lua b/resources/install/scripts/app/event_notify/index.lua index fbd70aad09..acfac42df9 100644 --- a/resources/install/scripts/app/event_notify/index.lua +++ b/resources/install/scripts/app/event_notify/index.lua @@ -23,7 +23,7 @@ -- Mark J Crane --define explode - function explode ( seperator, str ) + function explode ( seperator, str ) local pos, arr = 0, {} for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider @@ -34,14 +34,20 @@ end --usage - --luarun app.lua event_notify reboot 1003@domain.fusionpbx.com yealink + --luarun app.lua event_notify internal reboot 1003@domain.fusionpbx.com yealink --set the args as variables - command = argv[2]; - profile = argv[3]; + profile = argv[2]; + command = argv[3]; user = argv[4]; vendor = argv[5]; +--log the args + --freeswitch.consoleLog("notice", "[event_notify] profile "..profile.."\n"); + --freeswitch.consoleLog("notice", "[event_notify] command "..command.."\n"); + --freeswitch.consoleLog("notice", "[event_notify] user "..user.."\n"); + --freeswitch.consoleLog("notice", "[event_notify] vendor "..vendor.."\n"); + --get the user and domain name from the user argv user@domain user_table = explode("@",user); user = user_table[1]; @@ -62,14 +68,14 @@ event:addHeader('event-string', 'reboot=true'); end if (command == "check_sync") then - event:addHeader('event-string', 'check-sync;reboot=false'); + event:addHeader('event-string', 'reboot=true'); end end --grandstream if (vendor == "grandstream") then if (command == "reboot") then - event:addHeader('event-string', 'reboot=true'); + event:addHeader('event-string', 'check-sync;reboot=true'); end if (command == "check_sync") then event:addHeader('event-string', 'check-sync;reboot=false'); @@ -79,7 +85,7 @@ --polycom if (vendor == "polycom") then if (command == "reboot") then - event:addHeader('event-string', 'reboot=true'); + event:addHeader('event-string', 'check-sync;reboot=true'); end if (command == "check_sync") then event:addHeader('event-string', 'check-sync;reboot=false'); @@ -89,7 +95,7 @@ --yealink if (vendor == "yealink") then if (command == "reboot") then - event:addHeader('event-string', 'reboot=true'); + event:addHeader('event-string', 'check-sync;reboot=true'); end if (command == "check_sync") then event:addHeader('event-string', 'check-sync;reboot=false'); @@ -98,7 +104,7 @@ --snom if (vendor == "snom") then if (command == "reboot") then - event:addHeader('event-string', 'reboot=true'); + event:addHeader('event-string', 'check-sync;reboot=true'); end if (command == "check_sync") then event:addHeader('event-string', 'check-sync;reboot=false'); @@ -109,4 +115,4 @@ event:fire(); --log the event - freeswitch.consoleLog("notice", "[event_notify] command "..command.." "..user.."@"..domain.." vendor "..tostring(vendor).."\n"); \ No newline at end of file + freeswitch.consoleLog("notice", "[event_notify] command "..command.." "..user.."@"..domain.." vendor "..tostring(vendor).."\n");