2 Copyright 2011 Iordan Iordanov <iiordanov (AT) gmail.com>
4 This file is part of luci-pbx.
6 luci-pbx is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 luci-pbx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with luci-pbx. If not, see <http://www.gnu.org/licenses/>.
20 if nixio.fs.access("/etc/init.d/asterisk") then
22 elseif nixio.fs.access("/etc/init.d/freeswitch") then
30 function mysplit(inputstr, sep)
35 for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
42 function format_two_indices(string, ind1, ind2)
43 lines=mysplit(string, "\n")
46 for index,value in ipairs(lines) do
47 words[index]=mysplit(value)
51 for index,value in ipairs(words) do
52 if value[ind1] ~= nil and value[ind2] ~= nil then
53 output = output .. string.format("%-40s \t %-20s\n", value[ind1], value[ind2])
59 function format_one_index(string, ind1)
60 lines=mysplit(string, "\n")
63 for index,value in ipairs(lines) do
64 words[index]=mysplit(value)
68 for index,value in ipairs(words) do
69 if value[ind1] ~= nil then
70 output = output .. string.format("%-40s\n", value[ind1])
76 m = Map (modulename, translate("PBX Main Page"),
77 translate("This configuration page allows you to configure a phone system (PBX) service which\
78 permits making phone calls with, and sharing multiple Google and SIP (like Sipgate,\
79 SipSorcery, and Betamax) accounts among many SIP devices. Note that Google\
80 accounts, SIP accounts, and local user accounts are configured in the\
81 \"Google Accounts\", \"SIP Accounts\", and \"User Accounts\" sub-sections.\
82 You must configure at least one local SIP account\
83 on this PBX, to make and receive calls with your Google/SIP accounts.\
84 Configuring multiple users will allow you to make free calls between users, and share the configured\
85 Google and SIP accounts. If you have more than one Google and SIP accounts set up,\
86 you should probably configure how calls to and from them are routed in the \"Call Routing\" page.\
87 If you're interested in using your own PBX from anywhere in the world,\
88 then visit the \"Remote Usage\" section in the \"Advanced Settings\" page."))
90 ----------------------------------------------------------------------------------------------------
91 s = m:section(NamedSection, "connection_status", "main", translate("Service Control and Connection Status"))
94 s:option (DummyValue, "status", translate("Service Status"))
96 sts = s:option(DummyValue, "_sts")
97 sts.template = "cbi/tvalue"
100 function sts.cfgvalue(self, section)
102 if server == "asterisk" then
103 reg = luci.sys.exec("asterisk -rx 'sip show registry' | sed 's/peer-//'")
104 jab = luci.sys.exec("asterisk -rx 'jabber show connections' | grep onnected")
105 usrs = luci.sys.exec("asterisk -rx 'sip show users'")
106 chan = luci.sys.exec("asterisk -rx 'core show channels'")
107 return format_two_indices(reg, 1, 5) .. format_two_indices(jab, 2, 4) .. "\n"
108 .. format_one_index(usrs,1) .. "\n" .. chan
109 elseif server == "freeswitch" then
110 return "Freeswitch is not supported yet.\n"
112 return "Neither Asterisk nor FreeSwitch discovered, please install Asterisk, as Freeswitch is not supported yet.\n"