2014-01-08 10:15:35 +01:00
|
|
|
--
|
|
|
|
|
-- event_notify
|
|
|
|
|
-- Version: MPL 1.1
|
|
|
|
|
--
|
|
|
|
|
-- The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
-- 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
-- the License. You may obtain a copy of the License at
|
|
|
|
|
-- http://www.mozilla.org/MPL/
|
|
|
|
|
--
|
|
|
|
|
-- Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
-- for the specific language governing rights and limitations under the
|
|
|
|
|
-- License.
|
|
|
|
|
--
|
|
|
|
|
-- The Original Code is FusionPBX - event_notify
|
|
|
|
|
--
|
|
|
|
|
-- The Initial Developer of the Original Code is
|
|
|
|
|
-- Mark J Crane <markjcrane@fusionpbx.com>
|
2018-06-25 18:35:47 +02:00
|
|
|
-- Copyright (C) 2013 - 2018
|
2014-01-08 10:15:35 +01:00
|
|
|
-- the Initial Developer. All Rights Reserved.
|
|
|
|
|
--
|
|
|
|
|
-- Contributor(s):
|
|
|
|
|
-- Mark J Crane <markjcrane@fusionpbx.com>
|
2015-03-22 09:04:03 +01:00
|
|
|
-- Errol Samuels <voiptology@gmail.com>
|
2014-01-08 10:15:35 +01:00
|
|
|
|
2015-08-11 04:06:33 +02:00
|
|
|
--define the explode function
|
|
|
|
|
require "resources.functions.explode";
|
2014-06-10 05:23:02 +02:00
|
|
|
|
2014-01-08 10:15:35 +01:00
|
|
|
--usage
|
2014-07-04 11:47:37 +02:00
|
|
|
--luarun app.lua event_notify internal reboot 1003@domain.fusionpbx.com yealink
|
2014-01-08 10:15:35 +01:00
|
|
|
|
|
|
|
|
--set the args as variables
|
2014-07-04 11:47:37 +02:00
|
|
|
profile = argv[2];
|
|
|
|
|
command = argv[3];
|
2014-06-10 05:23:02 +02:00
|
|
|
user = argv[4];
|
2014-01-08 10:15:35 +01:00
|
|
|
vendor = argv[5];
|
|
|
|
|
|
2014-07-04 11:47:37 +02:00
|
|
|
--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");
|
|
|
|
|
|
2014-06-10 05:23:02 +02:00
|
|
|
--get the user and domain name from the user argv user@domain
|
|
|
|
|
user_table = explode("@",user);
|
|
|
|
|
user = user_table[1];
|
|
|
|
|
domain = user_table[2];
|
|
|
|
|
|
2014-01-08 10:15:35 +01:00
|
|
|
--create the event notify object
|
|
|
|
|
local event = freeswitch.Event('NOTIFY');
|
|
|
|
|
|
|
|
|
|
--add the headers
|
2014-06-10 05:23:02 +02:00
|
|
|
event:addHeader('profile', profile);
|
2014-01-08 10:15:35 +01:00
|
|
|
event:addHeader('user', user);
|
|
|
|
|
event:addHeader('host', domain);
|
|
|
|
|
event:addHeader('content-type', 'application/simple-message-summary');
|
|
|
|
|
|
2015-03-22 09:04:03 +01:00
|
|
|
--aastra
|
|
|
|
|
if (vendor == "aastra") then
|
|
|
|
|
if (command == "reboot") then
|
|
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
|
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
|
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-01-08 10:15:35 +01:00
|
|
|
--cisco
|
|
|
|
|
if (vendor == "cisco") then
|
2015-12-02 05:12:52 +01:00
|
|
|
if (command == "reboot") then
|
|
|
|
|
event:addHeader('event-string', 'check-sync');
|
|
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
|
|
|
|
event:addHeader('event-string', 'check-sync');
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--cisco-spa
|
|
|
|
|
if (vendor == "cisco-spa") then
|
2014-01-08 10:15:35 +01:00
|
|
|
if (command == "reboot") then
|
|
|
|
|
event:addHeader('event-string', 'reboot=true');
|
|
|
|
|
end
|
2014-06-10 05:23:02 +02:00
|
|
|
if (command == "check_sync") then
|
2014-07-04 11:47:37 +02:00
|
|
|
event:addHeader('event-string', 'reboot=true');
|
2014-06-10 05:23:02 +02:00
|
|
|
end
|
2014-01-08 10:15:35 +01:00
|
|
|
end
|
|
|
|
|
|
2018-04-10 00:15:52 +02:00
|
|
|
--fanvil
|
|
|
|
|
if (vendor == "fanvil") then
|
|
|
|
|
if (command == "reboot") then
|
|
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
|
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
|
|
|
|
event:addHeader('event-string', 'resync');
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-04-09 23:26:25 +02:00
|
|
|
--grandstream
|
|
|
|
|
if (vendor == "grandstream") then
|
2018-04-09 18:40:05 +02:00
|
|
|
if (command == "reboot") then
|
|
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
|
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
|
|
|
|
event:addHeader('event-string', 'resync');
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-04-09 23:26:25 +02:00
|
|
|
--htek
|
|
|
|
|
if (vendor == "htek") then
|
2014-01-08 10:15:35 +01:00
|
|
|
if (command == "reboot") then
|
2014-07-04 11:47:37 +02:00
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
2014-06-10 05:23:02 +02:00
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
2018-03-07 21:51:22 +01:00
|
|
|
event:addHeader('event-string', 'resync');
|
2014-01-08 10:15:35 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-06-25 18:35:47 +02:00
|
|
|
--sangoma
|
|
|
|
|
if (vendor == "sangoma") then
|
|
|
|
|
if (command == "reboot") then
|
|
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
|
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
|
|
|
|
event:addHeader('event-string', 'resync');
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-12-02 04:48:47 +01:00
|
|
|
--linksys
|
|
|
|
|
if (vendor == "linksys") then
|
|
|
|
|
if (command == "reboot") then
|
|
|
|
|
event:addHeader('event-string', 'reboot=true');
|
|
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
|
|
|
|
event:addHeader('event-string', 'reboot=true');
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-04-09 18:40:05 +02:00
|
|
|
--panasonic
|
|
|
|
|
if (vendor == "panasonic") then
|
2014-01-08 10:15:35 +01:00
|
|
|
if (command == "reboot") then
|
2018-04-09 18:40:05 +02:00
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
2014-06-10 05:23:02 +02:00
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
2018-04-09 18:40:05 +02:00
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
2014-01-08 10:15:35 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2018-04-09 18:40:05 +02:00
|
|
|
--polycom
|
|
|
|
|
if (vendor == "polycom") then
|
2014-01-08 10:15:35 +01:00
|
|
|
if (command == "reboot") then
|
2018-04-09 18:40:05 +02:00
|
|
|
event:addHeader('event-string', 'check-sync');
|
2014-06-10 05:23:02 +02:00
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
2018-04-09 18:40:05 +02:00
|
|
|
event:addHeader('event-string', 'check-sync');
|
2014-01-08 10:15:35 +01:00
|
|
|
end
|
|
|
|
|
end
|
2017-01-31 08:35:24 +01:00
|
|
|
|
2014-01-22 22:39:27 +01:00
|
|
|
--snom
|
|
|
|
|
if (vendor == "snom") then
|
|
|
|
|
if (command == "reboot") then
|
2014-07-04 11:47:37 +02:00
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
2014-06-10 05:23:02 +02:00
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
2018-06-26 19:45:12 +02:00
|
|
|
event:addHeader('event-string', 'check-sync;reboot=false');
|
2014-01-22 22:39:27 +01:00
|
|
|
end
|
|
|
|
|
end
|
2014-01-08 10:15:35 +01:00
|
|
|
|
2018-04-09 18:40:05 +02:00
|
|
|
--yealink
|
|
|
|
|
if (vendor == "yealink") then
|
2017-01-31 08:35:24 +01:00
|
|
|
if (command == "reboot") then
|
|
|
|
|
event:addHeader('event-string', 'check-sync;reboot=true');
|
|
|
|
|
end
|
|
|
|
|
if (command == "check_sync") then
|
2018-04-09 18:40:05 +02:00
|
|
|
event:addHeader('event-string', 'check-sync;reboot=false');
|
2017-01-31 08:35:24 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-01-08 10:15:35 +01:00
|
|
|
--send the event
|
|
|
|
|
event:fire();
|
|
|
|
|
|
|
|
|
|
--log the event
|
2014-07-04 11:47:37 +02:00
|
|
|
freeswitch.consoleLog("notice", "[event_notify] command "..command.." "..user.."@"..domain.." vendor "..tostring(vendor).."\n");
|