first commit
commit
ab842c0f20
@ -0,0 +1,14 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=Web UI for smstools3
|
||||
LUCI_DEPENDS:=+smstools3 +iconv +luci-compat
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_VERSION:=0.0.8-2
|
||||
|
||||
define Package/luci-app-smstools3/postrm
|
||||
rm -f /etc/config/smstools3
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
@ -0,0 +1,18 @@
|
||||
# luci-app-smstools3
|
||||
|
||||
Web UI smstools3 for OpenWrt LuCI.
|
||||
|
||||
Note: If you use this app with modemmanager, please move or remove /etc/hotplug.d/tty/25-modemmanager-tty
|
||||
|
||||
<details>
|
||||
<summary>Screenshots</summary>
|
||||
|
||||
![](https://raw.githubusercontent.com/koshev-msk/modemfeed/master/luci/applications/luci-app-smstools3/screenshots/incoming.png)
|
||||
|
||||
![](https://raw.githubusercontent.com/koshev-msk/modemfeed/master/luci/applications/luci-app-smstools3/screenshots/outcoming.png)
|
||||
|
||||
![](https://raw.githubusercontent.com/koshev-msk/modemfeed/master/luci/applications/luci-app-smstools3/screenshots/push.png)
|
||||
|
||||
![](https://raw.githubusercontent.com/koshev-msk/modemfeed/master/luci/applications/luci-app-smstools3/screenshots/setup.png)
|
||||
|
||||
</details>
|
@ -0,0 +1,41 @@
|
||||
local nixio = require "nixio"
|
||||
|
||||
module("luci.controller.modem.smstools3", package.seeall)
|
||||
|
||||
local utl = require "luci.util"
|
||||
|
||||
function index()
|
||||
entry({"admin", "modem"}, firstchild(), "Modem", 45).acl_depends={"unauthenticated"}
|
||||
entry({"admin", "modem", "sms"}, alias ("admin", "modem", "sms", "in_sms"), translate("Smstools3 SMS"), 11).acl_depends={"unauthenticated"}
|
||||
entry({"admin", "modem", "sms", "in_sms"}, template("modem/sms/in"), translate("Incoming"), 22).acl_depends={"unauthenticated"}
|
||||
entry({"admin", "modem", "sms", "out_sms"}, template("modem/sms/out"), translate("Outcoming"),23).acl_depends={"unauthenticated"}
|
||||
entry({"admin", "modem", "sms", "send_sms"}, template("modem/sms/send"), translate("Push"), 24).acl_depends={"unauthenticated"}
|
||||
entry({"admin", "modem", "sms", "sms_command"}, cbi("modem/smscommand"), translate("Command"), 25).acl_depends={"unauthenticated"}
|
||||
entry({"admin", "modem", "sms", "setup_sms"}, cbi("modem/smstools3"), translate("Setup"), 26).acl_depends={"unauthenticated"}
|
||||
entry({"admin", "modem", "sms", "event"}, form("modem/smsevent"), translate("User Script"), 27).acl_depends={"unauthenticated"}
|
||||
entry({"admin", "modem", "push_sms"}, call("action_send_sms"))
|
||||
entry({"admin", "modem", "erase_in_sms"}, call("action_in_erase_sms"))
|
||||
entry({"admin", "modem", "erase_out_sms"}, call("action_out_erase_sms"))
|
||||
end
|
||||
|
||||
|
||||
function action_send_sms()
|
||||
local set = luci.http.formvalue("set")
|
||||
number = string.gsub((string.sub(set, 1, 20)), "[%p%c%s]", '')
|
||||
message = string.gsub((string.sub(set, 21)), "\n", " ")
|
||||
if number:len() <= 5 then
|
||||
os.execute("/usr/bin/sendsms s"..number.." '"..message.."'")
|
||||
else
|
||||
os.execute("/usr/bin/sendsms "..number.." '"..message.."'")
|
||||
end
|
||||
end
|
||||
|
||||
function action_in_erase_sms()
|
||||
local set = luci.http.formvalue("erase_in_sms")
|
||||
os.execute("rm -f /var/spool/sms/incoming/*")
|
||||
end
|
||||
|
||||
function action_out_erase_sms()
|
||||
local set = luci.http.formvalue("erase_out_sms")
|
||||
os.execute("rm -f /var/spool/sms/sent/*")
|
||||
end
|
@ -0,0 +1,34 @@
|
||||
-- Copyright 2023 Konstantine Shevlyakov <shevlakov@132lan.ru>
|
||||
-- Licensed to the GNU General Public License v3.0.
|
||||
|
||||
require("nixio.fs")
|
||||
|
||||
local m, d, s
|
||||
|
||||
local m = Map("smstools3", translate("Smstools3: command list interface."))
|
||||
|
||||
local f = m:section(TypedSection, "root_phone", "<p> </p>" .. translate("Root Phone numbers"))
|
||||
f.anonymous = true
|
||||
f.rmempty = true
|
||||
data = f:option(DynamicList, "phone", translate("Phone number"),
|
||||
translate("List phone numbers without +"))
|
||||
|
||||
|
||||
l = m:section(TypedSection, "root_phone", "<p> </p>" .. translate("Command List"))
|
||||
l.anonymous = true
|
||||
|
||||
local s = m:section(TypedSection, "command")
|
||||
desc = s:option(Value, "desc", translate("Description"))
|
||||
sms = s:option(Value, "command", translate("SMS command"))
|
||||
exec = s:option(Value, "exec", translate("Execute"))
|
||||
delay_en = s:option(Flag, "delay_en", translate("Delay"))
|
||||
delay = s:option(Value, "delay", translate("Delay in sec."))
|
||||
answ_en = s:option(Flag, "answer_en", translate("Answer"))
|
||||
answ = s:option(Value, "answer", translate("Answer MSG"))
|
||||
delay:depends("delay_en", 1)
|
||||
answ:depends("answer_en", 1)
|
||||
s.addremove = true;
|
||||
s.rmempty = true;
|
||||
s.anonymous = true;
|
||||
|
||||
return m
|
@ -0,0 +1,27 @@
|
||||
local m6, s6, frm
|
||||
local filename = "/etc/smstools3.user"
|
||||
local fs = require "nixio.fs"
|
||||
local ut = require "luci.util"
|
||||
|
||||
m6 = SimpleForm("editing", nil)
|
||||
|
||||
m6.submit = translate("Save")
|
||||
m6.reset = false
|
||||
|
||||
s6 = m6:section(SimpleSection, "", translate("Edit smstools3 user script.<br />Add user's actions for incoming and outcoming messages.<br />Is shell script for smstools3 scenario.<br/>See <a href=\"http://smstools3.kekekasvi.com/index.php?p=eventhandler\">smstools3 manual page</a> for more details."))
|
||||
|
||||
frm = s6:option(TextValue, "data")
|
||||
frm.datatype = "string"
|
||||
frm.rows = 10
|
||||
|
||||
|
||||
function frm.cfgvalue()
|
||||
return fs.readfile(filename) or ""
|
||||
end
|
||||
|
||||
|
||||
function frm.write(self, section, data)
|
||||
return fs.writefile(filename, ut.trim(data:gsub("\r\n", "\n")))
|
||||
end
|
||||
|
||||
return m6
|
@ -0,0 +1,98 @@
|
||||
-- Copyright 2008 Yanira <forum-2008@email.de>
|
||||
-- Licensed to the public under the Apache License 2.0.
|
||||
|
||||
require("nixio.fs")
|
||||
|
||||
local m
|
||||
local s
|
||||
local try_devices = nixio.fs.glob("/dev/tty[A-Z][A-Z]*")
|
||||
local try_leds = nixio.fs.glob("/sys/class/leds/*")
|
||||
|
||||
m = Map("smstools3", translate("Setup smstools3"),
|
||||
translate("Configure smstools3 daemon."))
|
||||
|
||||
s = m:section(TypedSection, "sms")
|
||||
s.anonymous = true
|
||||
|
||||
utf8 = s:option(Flag, "decode_utf", translate("Decode SMS"),
|
||||
translate("Decode Incoming messages to UTF-8 codepage."))
|
||||
utf8.rmempty = true
|
||||
ui = s:option(Flag, "ui", translate("Unexepted Input"),
|
||||
translate("Enable Unexpected input from COM port."))
|
||||
ui.rmempty = true
|
||||
dt = s:option(Value, "delay", translate("Delay time"),
|
||||
translate("Default value: 10<br />Smsd sleep so many seconds when it has nothing to do."))
|
||||
dt.rmempty = true
|
||||
|
||||
memory = s:option(ListValue, "storage", translate("SMS Storage"),
|
||||
translate("Select storage to save SMS."))
|
||||
memory:value("temporary", translate("Temporary"))
|
||||
memory:value("persistent", translate("Persistent"))
|
||||
memory.default = "temporary"
|
||||
memory.rmempty = true
|
||||
|
||||
dev = s:option(ListValue, "device", translate("Device"),
|
||||
translate("Select COM port."))
|
||||
if try_devices then
|
||||
local node
|
||||
for node in try_devices do
|
||||
dev:value(node, node)
|
||||
end
|
||||
end
|
||||
|
||||
init = s:option(ListValue, "init", translate("Init string"),
|
||||
translate("Initialise modem for more vendors"))
|
||||
init:value("huawei", "Huawei")
|
||||
init:value("intel", "Intel XMM")
|
||||
init:value("zte", "ZTE or more")
|
||||
init:value("", "Qualcomm or more")
|
||||
init.default = ""
|
||||
init.rempty = true
|
||||
|
||||
pin = s:option(Value, "pin", translate("PIN Code"),
|
||||
translate("Default value: not in use.<br />Specifies the PIN number of the SIM card inside the modem."))
|
||||
pin.rmempty = true
|
||||
|
||||
net = s:option(ListValue, "net_check", translate("Check network"),
|
||||
translate("Setup network checking. Some modems incorrect test network."))
|
||||
net:value("0", translate("Ignore check"))
|
||||
net:value("1", translate("Always check"))
|
||||
net:value("2", translate("Check prepare message"))
|
||||
|
||||
sig = s:option(Flag, "sig_check", translate("Ignore signal level"),
|
||||
translate("Some devices do not support Bit Error Rate"))
|
||||
|
||||
log = s:option(ListValue, "loglevel", translate("Loglevel"),
|
||||
translate("Verbose logging output."))
|
||||
log:value("1", "Emergency")
|
||||
log:value("2", "Alert")
|
||||
log:value("3", "Critical")
|
||||
log:value("4", "Error")
|
||||
log:value("5", "Warning")
|
||||
log:value("6", "Notice")
|
||||
log:value("7", "Info")
|
||||
log:value("8", "Debug")
|
||||
log.default = "5"
|
||||
|
||||
led_enable = s:option(Flag, "led_enable", translate("LED"),
|
||||
translate("Enable LED indication incoming messages."))
|
||||
|
||||
led = s:option(ListValue, "led", translate("Select LED"),
|
||||
translate("LED indicate to Incoming messages."))
|
||||
|
||||
led:depends("led_enable", 1)
|
||||
if try_leds then
|
||||
local flash
|
||||
local status
|
||||
for flash in try_leds do
|
||||
local status = flash
|
||||
local flash = string.sub (status, 17)
|
||||
led:value(flash,flash)
|
||||
end
|
||||
end
|
||||
|
||||
function m.on_after_commit(Map)
|
||||
luci.sys.call("/usr/bin/luci-app-smstools3")
|
||||
end
|
||||
|
||||
return m
|
@ -0,0 +1,108 @@
|
||||
<%#
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
<%
|
||||
|
||||
local fs = require("nixio.fs")
|
||||
local http = require("luci.http")
|
||||
local util = require("luci.util")
|
||||
local sys = require("luci.sys")
|
||||
|
||||
local dir = '/var/spool/sms/incoming/'
|
||||
msg = {}
|
||||
|
||||
function directory(dir)
|
||||
local p = io.popen('find "'..dir..'" -type f -iname [0-9]* | sort -r')
|
||||
for file in p:lines() do
|
||||
table.insert(msg, file)
|
||||
msg[#msg + 1] = sms
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
start_string = '<div class="td left" width="25%">'
|
||||
end_string = '</div>'
|
||||
foot = '</div>'
|
||||
button = [[
|
||||
<input class="cbi-button cbi-button-remove" type="submit" value="Remove" />
|
||||
]]
|
||||
|
||||
function exist(dir)
|
||||
directory(dir)
|
||||
for k,v in pairs(msg) do
|
||||
msg[k] = v
|
||||
if (k%2==0) then
|
||||
head = '<div class="tr cbi-rowstyle-2">'
|
||||
else
|
||||
head = '<div class="tr cbi-rowstyle-1">'
|
||||
end
|
||||
local f = io.open(v, "rb")
|
||||
if f then
|
||||
f:close()
|
||||
end
|
||||
lines = {}
|
||||
for r in io.lines(v) do
|
||||
lines[#lines + 1] = r
|
||||
end
|
||||
if (lines[1] ~= nil) then
|
||||
for fr in lines[1]:gmatch("%w+") do
|
||||
if (tonumber(fr)) and (#fr >= 7 ) then
|
||||
fromto = fr
|
||||
fromto = ('+'..fromto..'')
|
||||
else
|
||||
fromto = fr
|
||||
end
|
||||
end
|
||||
send = {}
|
||||
for sn in lines[4]:gmatch("%S+") do
|
||||
send[#send + 1] = sn
|
||||
end
|
||||
recieved ={}
|
||||
for res in lines[5]:gmatch("%S+") do
|
||||
recieved[#recieved + 1] = res
|
||||
end
|
||||
text = {}
|
||||
for t in table.concat(lines,"<br />",14,r):gmatch("%S+") do
|
||||
text[#text + 1] = t
|
||||
end
|
||||
print(head, start_string, fromto,
|
||||
end_string, start_string,
|
||||
send[2], send[3], end_string,
|
||||
start_string, recieved[2], recieved[3],
|
||||
end_string, start_string,
|
||||
table.concat(text, " "), end_string, foot)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function erase_in_sms(){
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "erase_in_sms")%>');
|
||||
alert("<%:Delete all incoming messages!%>");
|
||||
location.reload();
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
<%+header%>
|
||||
<h2 name="content"><%:Smstools3: Incoming Messages%></h2>
|
||||
<fieldset class="cbi-section">
|
||||
<div class="table" width="100%">
|
||||
<div class="tr cbi-rowstyle-2">
|
||||
<div class="td left" width="25%"><b><%:From%></b></div>
|
||||
<div class="td left" width="25%"><b><%:Send%></b></div>
|
||||
<div class="td left" width="25%"><b><%:Recieve%></b></div>
|
||||
<div class="td left" width="25%"><b><%:Message%></b></div>
|
||||
</div>
|
||||
<% exist(dir)
|
||||
luci.sys.exec('/usr/share/luci-app-smstools3/led.sh off') %>
|
||||
</div>
|
||||
<div class="table" width="100%">
|
||||
<div class="td left" width="100%"><input class="cbi-button cbi-button-remove" type="submit" value="<%:Remove All%>" title="<%:Delete All incoming Messages%>" onclick="return erase_in_sms()"/></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<%+footer%>
|
@ -0,0 +1,99 @@
|
||||
<%#
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
<%
|
||||
local fs = require("nixio.fs")
|
||||
local http = require("luci.http")
|
||||
local util = require("luci.util")
|
||||
local sys = require("luci.sys")
|
||||
|
||||
local dir = '/var/spool/sms/sent/'
|
||||
msg = {}
|
||||
|
||||
function directory(dir)
|
||||
local p = io.popen('find "'..dir..'" -type f')
|
||||
for file in p:lines() do
|
||||
table.insert(msg, file)
|
||||
msg[#msg + 1] = sms
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
start_string = '<div class="td left" width="25%">'
|
||||
end_string = '</b></div>'
|
||||
foot = '</div>'
|
||||
|
||||
function exist(dir)
|
||||
directory(dir)
|
||||
for k,v in pairs(msg) do
|
||||
msg[k] = v
|
||||
--print(v)
|
||||
if (k%2==0) then
|
||||
head = '<div class="tr cbi-rowstyle-2">'
|
||||
else
|
||||
head = '<div class="tr cbi-rowstyle-1">'
|
||||
end
|
||||
local f = io.open(v, "rb")
|
||||
if f then
|
||||
f:close()
|
||||
end
|
||||
lines = {}
|
||||
for r in io.lines(v) do
|
||||
lines[#lines + 1] = r
|
||||
end
|
||||
if (lines[1] ~= nil) then
|
||||
for fr in lines[1]:gmatch("%w+") do
|
||||
if (tonumber(fr)) and (#fr >= 7 ) then
|
||||
fromto = fr
|
||||
fromto = ('+'..fromto..'')
|
||||
elseif string.sub(fr, 1, 1) == "s" then
|
||||
fromto = string.gsub(fr, "s", "")
|
||||
else
|
||||
fromto = fr
|
||||
end
|
||||
end
|
||||
send = {}
|
||||
for sn in lines[4]:gmatch("%S+") do
|
||||
send[#send + 1] = sn
|
||||
end
|
||||
recieved ={}
|
||||
for res in lines[5]:gmatch("%S+") do
|
||||
recieved[#recieved + 1] = res
|
||||
end
|
||||
local utf8str = luci.sys.exec('cat '..v..' | tail -1')
|
||||
if (utf8str ~= "[Aa-Zz]") then
|
||||
utf8str = luci.sys.exec('cat '..v..' | tail -1 | iconv -t UTF-8 -f UCS-2')
|
||||
end
|
||||
print(head, start_string, fromto, end_string, start_string, send[2], send[3], end_string, start_string, recieved[2], end_string, start_string, utf8str, end_string, foot)
|
||||
end
|
||||
end
|
||||
end
|
||||
%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function erase_out_sms(){
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "erase_out_sms")%>');
|
||||
alert("<%:All outgoing messages are deleted!%>");
|
||||
location.reload();
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
<%+header%>
|
||||
<h2 name="content"><%:Smstools3: Outcoming Messages%></h2>
|
||||
<fieldset class="cbi-section">
|
||||
<div class="table" width="100%">
|
||||
<div class="tr cbi-rowstyle-2">
|
||||
<div class="td left" width="25%"><b><%:To%></b></div>
|
||||
<div class="td left" width="25%"><b><%:Send%></b></div>
|
||||
<div class="td left" width="25%"><b><%:Send Time%></b></div>
|
||||
<div class="td left" width="25%"><b><%:Message%></b></div>
|
||||
</div>
|
||||
<% exist(dir) %>
|
||||
</div>
|
||||
<div class="table" width="100%">
|
||||
<div class="td left" width="100%"><input class="cbi-button cbi-button-remove" type="submit" value="<%:Remove All%>" title="<%:Delete All Sent Messages%>" onclick="return erase_out_sms()"/></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<%+footer%>
|
@ -0,0 +1,86 @@
|
||||
<%+header%>
|
||||
<h2 name="content"><%:Smstools3: Send Message%></h2>
|
||||
<script type="text/javascript" src="<%=resource%>/xhr.js?v=git-20.294.76110-ad9a60a"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
reading = 0;
|
||||
function sendsms()
|
||||
{
|
||||
if ( reading > 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var s = document.getElementById("sendto").value;
|
||||
//document.getElementById('rding').innerHTML=s.length;
|
||||
if ( s.length == 0 )
|
||||
{
|
||||
alert("<%:You must enter a phone number!%>");
|
||||
return false;
|
||||
}
|
||||
s = s.trim();
|
||||
if ( isNaN(s) == true )
|
||||
{
|
||||
alert("<%:Invalid phone number!%>");
|
||||
return false;
|
||||
}
|
||||
var num = s.concat(" ");
|
||||
num = num.substr(0, 20);
|
||||
var t = document.getElementById("txtmessage").value;
|
||||
<% tl =%> t
|
||||
if ( t.length == 0 )
|
||||
{
|
||||
alert("<%:Message is blank!%>");
|
||||
return false;
|
||||
}
|
||||
if ( t.length > 160 )
|
||||
{
|
||||
t = t.substr(0, 160);
|
||||
}
|
||||
num = num.concat(t);
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "push_sms")%>',
|
||||
{ set: num },
|
||||
function()
|
||||
{
|
||||
alert("<%:Message sent.%>");
|
||||
}
|
||||
);
|
||||
}
|
||||
function newsms()
|
||||
{
|
||||
if ( reading > 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
document.getElementById('sendmsg').style.display="table";
|
||||
document.getElementById('sendtxt').style.display="table";
|
||||
document.getElementById('sendbtn').style.display="table";
|
||||
document.getElementById("sendto").value="";
|
||||
document.getElementById("txtmessage").value="";
|
||||
return false;
|
||||
}
|
||||
//]]></script>
|
||||
<fieldset class="cbi-section">
|
||||
<table id="sendmsg" width="600" border="0" style="display:table;">
|
||||
<tr>
|
||||
<td width="15%"><div align="left"><strong><%:Send To%> :</strong></div></td>
|
||||
<td width="70%"><input type="number" name="sendto" id="sendto" maxlength="20"></input></td>
|
||||
<td width="15%"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<table id="sendtxt" width="700" border="0" style="display:table;">
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<textarea type="message" name="txtmessage" id="txtmessage" rows="6" style="width: 600px;" maxlength="160"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table id="sendbtn" width="550" border="0" style="display:table;">
|
||||
<tr>
|
||||
<td width="17%"><br /><input type="button" id="sendbtn" class="cbi-button cbi-button-apply" value="<%:Push%>" onclick="return sendsms()" /></td>
|
||||
<td width="13%"> </td>
|
||||
<td width="70%"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
<%+footer%>
|
@ -0,0 +1,296 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Language: ru\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Last-Translator: Konstantine Shevlyakov <shevlakov@132lan.ru>\n"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/controller/smstools3.lua:9
|
||||
msgid "Smstools3 SMS"
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/controller/smstools3.lua:10
|
||||
msgid "Incoming"
|
||||
msgstr "Входяшие"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/controller/smstools3.lua:11
|
||||
msgid "Outcoming"
|
||||
msgstr "Исходящие"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/controller/smstools3.lua:12
|
||||
msgid "Push"
|
||||
msgstr "Отправить"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/controller/smstools3.lua:13
|
||||
msgid "Command"
|
||||
msgstr "Команды"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/controller/smstools3.lua:14
|
||||
msgid "Setup"
|
||||
msgstr "Настройки"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/controller/smstools3.lua:15
|
||||
msgid "User Script"
|
||||
msgid "Скрипт"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/in.htm:76
|
||||
msgid "Delete all incoming messages!"
|
||||
msgstr "Входящие сообщения удалены!"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/in.htm:83
|
||||
msgid "Smstools3: Incoming Messages"
|
||||
msgstr "Smstools3: Входящие сообщения"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/in.htm:87
|
||||
msgid "From"
|
||||
msgstr "От"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/in.htm:88
|
||||
msgid "Send"
|
||||
msgstr "Отправлено"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/in.htm:89
|
||||
msgid "Recieve"
|
||||
msgstr "Принято"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/in.htm:90
|
||||
msgid "Message"
|
||||
msgstr "Текст сообщения"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/in.htm:96
|
||||
msgid "Remove All"
|
||||
msgstr "Удалить все"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/in.htm:96
|
||||
msgid "Delete All incoming Messages"
|
||||
msgstr "Удалить все входящие сообщения"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/out.htm:74
|
||||
msgid "All outgoing messages are deleted!"
|
||||
msgstr "Исходящие сообщения удалены!"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/out.htm:82
|
||||
msgid "Smstools3: Outcoming Messages"
|
||||
msgstr "Smstools3: Исходящие сообщения"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/out.htm:86
|
||||
msgid "To"
|
||||
msgstr "Кому"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/out.htm:87
|
||||
msgid "Send"
|
||||
msgstr "Отправлено"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/out.htm:88
|
||||
msgid "Send Time"
|
||||
msgstr "Время отправки (сек)"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/out.htm:89
|
||||
msgid "Message"
|
||||
msgstr "Текст сообщения"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/out.htm:94
|
||||
msgid "Remove All"
|
||||
msgstr "Удалить все"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/out.htm:94
|
||||
msgid "Delete All Sent Messages"
|
||||
msgstr "Удалить все исходящие сообщения"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/send.htm:2
|
||||
msgid "Smstools3: Send Message"
|
||||
msgstr "Smstools3: Написать сообщение"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/send.htm:16
|
||||
msgid "You must enter a phone number!"
|
||||
msgstr "Введите номер телефона!"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/send.htm:22
|
||||
msgid "Invalid phone number!"
|
||||
msgstr "Это не номер телефона!"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/send.htm:31
|
||||
msgid "Message is blank!"
|
||||
msgstr "Пустое сообщение!"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/send.htm:43
|
||||
msgid "Message sent."
|
||||
msgstr "Сообщение отправлено."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/send.htm:64
|
||||
msgid "Send To"
|
||||
msgstr "Номер телефона"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/view/modem/sms/send.htm:80
|
||||
msgid "Push"
|
||||
msgstr "Отправить"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:11
|
||||
msgid "Setup smstools3"
|
||||
msgstr "Настройки smstools3"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:12
|
||||
msgid "Configure smstools3 daemon."
|
||||
msgstr "Конфигурация службы smstools3."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:17
|
||||
msgid "Decode SMS"
|
||||
msgstr "Декодировать SMS"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:18
|
||||
msgid "Decode Incoming messages to UTF-8 codepage."
|
||||
msgstr "Преобразовать входящие сообщения в UTF-8."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:20
|
||||
msgid "Unexepted Input"
|
||||
msgstr "Нештатные команды"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:21
|
||||
msgid "Enable Unexpected input from COM port."
|
||||
msgstr "Принимать команды, не предназначенные для службы на COM-порт."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:23
|
||||
msgid "Delay time"
|
||||
msgstr "Активное время"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:23
|
||||
msgid "Default value: 10<br />Smsd sleep so many seconds when it has nothing to do."
|
||||
msgstr "По-умолчанию: 10<br />Время активной работы smsd после после принятия или отправки сообщений."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:27
|
||||
msgid "SMS Storage"
|
||||
msgstr "Хранилище SMS"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:28
|
||||
msgid "Select storage to save SMS."
|
||||
msgstr "Выберите тип храниния SMS сообщений."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:29
|
||||
msgid "Temporary"
|
||||
msgstr "Временное"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:30
|
||||
msgid "Persistent"
|
||||
msgstr "Постоянное"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:34
|
||||
msgid "Device"
|
||||
msgstr "COM-порт"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:34
|
||||
msgid "Select COM port."
|
||||
msgstr "Выберите порт."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:43
|
||||
msgid "PIN Code"
|
||||
msgstr "ПИН-код"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:44
|
||||
msgid "Default value: not in use.<br />Specifies the PIN number of the SIM card inside the modem."
|
||||
msgstr "По-умолчанию не используется.<br />Укажите PIN-код симкарты."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:47
|
||||
msgid "Loglevel"
|
||||
msgstr "Журнал"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:48
|
||||
msgid "Verbose logging output."
|
||||
msgstr "Подробный вывод журнала."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:60
|
||||
msgid "Enable LED indication incoming messages."
|
||||
msgstr "Включить индикацию LED для входящих сообщений."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:61
|
||||
msgid "Check network"
|
||||
msgstr "Тест сети"
|
||||
|
||||
msgid "Setup network checking. Some modems incorrect test network."
|
||||
msgstr "Настроить проверку наличия сети. Некторые модемы неверно проверяют сеть."
|
||||
|
||||
msgid "Ignore check"
|
||||
msgstr "Всегда игнорировать"
|
||||
|
||||
msgid "Always check"
|
||||
msgstr "Всегда проверять"
|
||||
|
||||
msgid "Check prepare message"
|
||||
msgstr "При обработке сообщений"
|
||||
|
||||
msgid "Ignore signal level"
|
||||
msgstr "Игнорировать уровень сигнала"
|
||||
|
||||
msgid "Some devices do not support Bit Error Rate"
|
||||
msgstr "Некоторые устройства не поддерживают уровень сигнала"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:62
|
||||
msgid "Select LED"
|
||||
msgstr "Выбрать светодиод"
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smstools3.lua:63
|
||||
msgid "LED indicate to Incoming messages."
|
||||
msgstr "Светодиод для индикации входящих сообщений."
|
||||
|
||||
#: applications/luci-app-smstools3/luasrc/model/cbi/modem/smsevent.lua:11
|
||||
msgid "Edit smstools3 user script.<br />Add user's actions for incoming and outcoming messages.<br />Is shell script for smstools3 scenario.<br/>See <a href=\"http://smstools3.kekekasvi.com/index.php?p=eventhandler\">smstools3 manual page</a> for more details."
|
||||
msgstr "Пользовательский скрипт оболочки ash для smstools3.<br />Действия для входящих и исходящих сообщений.<br/>Подробности смотрите в <a href=\"http://smstools3.kekekasvi.com/index.php?p=eventhandler\">руководстве к smstools3</a>."
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:8
|
||||
msgid "Smstools3: command list interface."
|
||||
msgstr "Smstools3: интерфейс команд."
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:10
|
||||
msgid "Root Phone numbers"
|
||||
msgstr "Номера управления"
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:13
|
||||
msgid "Phone number"
|
||||
msgstr "Номер телефона"
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:14
|
||||
msgid "List phone numbers without +"
|
||||
msgstr "Список телефонных номеров без +"
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:17
|
||||
msgid "Command List"
|
||||
msgstr "Список команд"
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:21
|
||||
msgid "Description"
|
||||
msgstr "Описание"
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:22
|
||||
msgid "SMS command"
|
||||
msgstr "Команда SMS"
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:23
|
||||
msgid "Execute"
|
||||
msgstr "Выполнить"
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:24
|
||||
msgid "Delay"
|
||||
msgstr "Задержка"
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:25
|
||||
msgid "Delay in sec."
|
||||
msgstr "Задержка в сек."
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:26
|
||||
msgid "Answer"
|
||||
msgstr "Ответ"
|
||||
|
||||
#: /applications/luci-app-smstools3/luasrc/model/cbi/modem/smscommand.lua:26
|
||||
msgid "Answer MSG"
|
||||
msgstr "Сообщение"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
start(){
|
||||
/usr/bin/luci-app-smstools3
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
#!/bin/sh -x
|
||||
|
||||
if [ "$PKG_UPGRADE" != "1" ]; then
|
||||
touch /etc/config/smstools3
|
||||
uci set smstools3.@sms[0]=sms
|
||||
uci set smstools3.@root_phone[0]=root_phone
|
||||
uci set smstools3.@command[0]=command
|
||||
fi
|
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
sleep 10 && \
|
||||
/usr/share/luci-app-smstools3/event.sh > /tmp/smsd.conf && \
|
||||
rm -f /etc/smsd.conf && ln -s /tmp/smsd.conf /etc && \
|
||||
/etc/init.d/smstools3 stop && \
|
||||
sleep 3 && \
|
||||
/etc/init.d/smstools3 start && \
|
||||
/etc/init.d/led restart &
|
||||
|
@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
|
||||
killall smsd
|
||||
|
||||
DECODE=$(uci -q get smstools3.@sms[0].decode_utf)
|
||||
UI=$(uci -q get smstools3.@sms[0].ui)
|
||||
STORAGE=$(uci -q get smstools3.@sms[0].storage)
|
||||
DEVICE=$(uci -q get smstools3.@sms[0].device)
|
||||
LOG=$(uci -q get smstools3.@sms[0].loglevel)
|
||||
PIN=$(uci -q get smstools3.@sms[0].pin)
|
||||
LED_EN=$(uci -q get smstools3.@sms[0].led_enable)
|
||||
INIT_=$(uci -q get smstools3.@sms[0].init)
|
||||
NET_CHECK=$(uci -q get smstools3.@sms[0].net_check)
|
||||
SIG_CHECK=$(uci -q get smstools3.@sms[0].sig_check)
|
||||
|
||||
if [ ! -d /root/sms ]; then
|
||||
mkdir /root/sms
|
||||
for d in checked failed incoming outgoing sent; do
|
||||
mkdir /root/sms/${d}
|
||||
done
|
||||
fi
|
||||
|
||||
case $STORAGE in
|
||||
persistent)
|
||||
if [ -d /var/spool/sms ]; then
|
||||
mv /var/spool/sms /var/spool/sms_tmp
|
||||
ln -s /root/sms /var/spool/sms
|
||||
fi
|
||||
;;
|
||||
temporary)
|
||||
if [ -d /var/spool/sms_tmp ]; then
|
||||
rm -f /var/spool/sms
|
||||
mv /var/spool/sms_tmp /var/spool/sms
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# template config
|
||||
echo -e "devices = GSM1\nincoming = /var/spool/sms/incoming\noutgoing = /var/spool/sms/outgoing"
|
||||
echo -e "checked = /var/spool/sms/checked\nfailed = /var/spool/sms/failed\nsent = /var/spool/sms/sent"
|
||||
echo -e "receive_before_send = no\ndate_filename = 1\ndate_filename_format = %s"
|
||||
echo "eventhandler = /usr/share/luci-app-smstools3/led.sh"
|
||||
|
||||
if [ "$DECODE" ]; then
|
||||
echo "decode_unicode_text = yes"
|
||||
echo "incoming_utf8 = yes"
|
||||
fi
|
||||
echo -e "receive_before_send = no\nautosplit = 3"
|
||||
if [ "$LOG" ]; then
|
||||
echo "loglevel = $LOG"
|
||||
fi
|
||||
echo ""
|
||||
echo "[GSM1]"
|
||||
case $INIT_ in
|
||||
huawei) INIT_STRING="init = AT+CPMS=\"SM\";+CNMI=2,0,0,2,1" ;;
|
||||
intel) INIT_STRING="init = AT+CPMS=\"SM\"" ;;
|
||||
zte) INIT_STRING="init = AT+CPMS=\"SM\",\"SM\",\"SM\"" ;;
|
||||
*)INIT_STRING="init = AT+CPMS=\"ME\",\"ME\",\"ME\"" ;;
|
||||
esac
|
||||
echo $INIT_STRING
|
||||
echo "device = $DEVICE"
|
||||
case $SIG_CHECK in
|
||||
1) echo "signal_quality_ber_ignore = yes" ;;
|
||||
esac
|
||||
case $NET_CHECK in
|
||||
0) echo "check_network = 0" ;;
|
||||
1) echo "check_network = 1" ;;
|
||||
2) echo "check_network = 2" ;;
|
||||
esac
|
||||
if [ ! "$UI" ]; then
|
||||
echo -e "detect_unexpected_input = no"
|
||||
fi
|
||||
echo "incoming = yes"
|
||||
case $PIN in
|
||||
''|*[!0-9]*) logger -t luci-app-smstools3 "invalid pin" ;;
|
||||
*)
|
||||
if [ "$(echo "$PIN" | awk '{print length}')" -lt "4" ] || [ "$(echo "$PIN" | awk '{print length}')" -gt "4" ]; then
|
||||
logger -t luci-app-smstools3 "invalid pin"
|
||||
else
|
||||
echo "pin = $PIN"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo "baudrate = 115200"
|
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
LED_EN=$(uci -q get smstools3.@sms[0].led_enable)
|
||||
LED=$(uci -q get smstools3.@sms[0].led)
|
||||
|
||||
case $1 in
|
||||
off)
|
||||
if [ $LED_EN ]; then
|
||||
echo none > /sys/class/leds/${LED}/trigger
|
||||
/etc/init.d/led restart
|
||||
fi
|
||||
;;
|
||||
RECEIVED)
|
||||
if [ $LED_EN ]; then
|
||||
echo timer > /sys/class/leds/${LED}/trigger
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -r /usr/share/luci-app-smstools3/smscommand.sh ]; then
|
||||
. /usr/share/luci-app-smstools3/smscommand.sh
|
||||
fi
|
||||
|
||||
if [ -r /etc/smstools3.user ]; then
|
||||
. /etc/smstools3.user
|
||||
fi
|
||||
|
||||
NUM=$(ls -1 /var/spool/sms/incoming/ | wc -l)
|
||||
BODY=$(echo $2 | awk -F [\/] '{print $NF}')
|
||||
|
||||
if [ $NUM -ge 100 ] && [ $NUM -lt 1000 ]; then
|
||||
NUM=0$NUM
|
||||
elif [ $NUM -ge 10 ] && [ $NUM -lt 100 ]; then
|
||||
NUM=00$NUM
|
||||
elif [ $NUM -ge 0 ] && [ $NUM -lt 10 ]; then
|
||||
NUM=000$NUM
|
||||
fi
|
||||
|
||||
|
||||
case $1 in
|
||||
RECEIVED)
|
||||
mv $2 /var/spool/sms/incoming/${NUM}_${BODY}
|
||||
rm -f /var/spool/sms/incoming/*concat*
|
||||
;;
|
||||
esac
|
@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
|
||||
SECTIONS=$(uci show smstools3 | awk -F [\]\[\@=] '/=command/{print $3}')
|
||||
PHONE=$(uci -q get smstools3.@root_phone[0].phone)
|
||||
|
||||
|
||||
# smscommand function
|
||||
smscmd(){
|
||||
for s in $SECTIONS; do
|
||||
CMD="$(uci -q get smstools3.@command[$s].command)"
|
||||
MSG="$(echo $content)"
|
||||
case $CMD in
|
||||
*${MSG}*)
|
||||
ANSWER=$(uci -q get smstools3.@command[$s].answer)
|
||||
if [ "$ANSWER" ]; then
|
||||
/usr/bin/sendsms $PHONE "$ANSWER"
|
||||
fi
|
||||
EXEC=$(uci -q get smstools3.@command[$s].exec)
|
||||
DELAY=$(uci -q get smstools3.@command[$s].delay)
|
||||
if [ $DELAY ]; then
|
||||
sleep $DELAY && $EXEC &
|
||||
else
|
||||
$EXEC
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# parse incoming message
|
||||
if [ "$1" == "RECEIVED" ]; then
|
||||
from=`grep "From:" $2 | awk -F ': ' '{printf $2}'`
|
||||
content=$(sed -e '1,/^$/ d' < "$2")
|
||||
# check ROOT messages
|
||||
for n in ${PHONE}; do
|
||||
if [ "$from" -eq "$n" ]; then
|
||||
PHONE=$n
|
||||
smscmd
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
@ -0,0 +1,176 @@
|
||||
#!/bin/sh
|
||||
|
||||
# example script to manage router
|
||||
# and resend messages to telegram
|
||||
# copy script to /etc
|
||||
|
||||
# root phone numbers to manage device
|
||||
FNUMBER=""
|
||||
# target host respone to change anser channel
|
||||
TARGET=ya.ru
|
||||
|
||||
ROUTER=$(uci -q get system.@system[0].hostname)
|
||||
chat_id=$(uci -q get telegrambot.config.chat_id)
|
||||
token=$(uci -q get telegrambot.config.bot_token)
|
||||
|
||||
# check link to send channel answer
|
||||
function link_(){
|
||||
if $(ping -c4 ${TARGET} > /dev/null 2>&1); then
|
||||
LINK=ON
|
||||
else
|
||||
LINK=OFF
|
||||
fi
|
||||
}
|
||||
|
||||
# generate messages
|
||||
function msg_(){
|
||||
# answer setup file
|
||||
if [ -f /tmp/smstools3.answer ]; then
|
||||
STATE=$(cat /tmp/smstools3.answer)
|
||||
case $STATE in
|
||||
0) LINK=OFF ;;
|
||||
1) LINK=ON ;;
|
||||
esac
|
||||
fi
|
||||
# select channel to send answers
|
||||
case $LINK in
|
||||
OFF)
|
||||
if [ $FNUMBER ]; then
|
||||
/usr/bin/sendsms ${FNUMBER} "${TXT}"
|
||||
fi
|
||||
;;
|
||||
ON)
|
||||
if [ x$chat_id != x ] && [ x$token != x ]; then
|
||||
/usr/bin/curl -d "chat_id=$chat_id&text=${TXT}" -X POST https://api.telegram.org/bot"$token"/sendMessage
|
||||
else
|
||||
if [ $FNUMBER ]; then
|
||||
/usr/bin/sendsms ${FNUMBER} "${TXT}"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# parse incoming message
|
||||
if [ "$1" == "RECEIVED" ]; then
|
||||
from=`grep "From:" $2 | awk -F ': ' '{printf $2}'`
|
||||
content=$(sed -e '1,/^$/ d' < "$2")
|
||||
ROOTN=0
|
||||
# check ROOT messages
|
||||
for n in ${FNUMBER}; do
|
||||
if [ "$from" -eq "$n" ]; then
|
||||
ROOTN=1
|
||||
FNUMBER=$n
|
||||
fi
|
||||
done
|
||||
if [ $ROOTN -eq 1 ]; then
|
||||
COMMAND=$(echo $content | awk '{print $1}')
|
||||
case $COMMAND in
|
||||
# reboot device
|
||||
reboot)
|
||||
TXT="$ROUTER will be rebooted"
|
||||
link_
|
||||
sleep 5
|
||||
msg_
|
||||
sleep 10
|
||||
reboot
|
||||
;;
|
||||
# restart router interface
|
||||
restart)
|
||||
RIFACE=$(echo $content | awk '{print $2}')
|
||||
if [ $RIFACE ]; then
|
||||
ifdown $RIFACE
|
||||
sleep 3
|
||||
ifup $RIFACE
|
||||
sleep 20
|
||||
link_
|
||||
TXT="$ROUTER. Interfcae \"$RIFACE\" reload. LINK $LINK."
|
||||
|
||||
else
|
||||
TXT="$ROUTER. Usage restart \"logical interface\""
|
||||
fi
|
||||
link_
|
||||
msg_
|
||||
;;
|
||||
# manage device services
|
||||
service)
|
||||
SERVICE=$(echo $content | awk '{print $2}')
|
||||
ACTION=$(echo $content | awk '{print $3}')
|
||||
case $ACTION in
|
||||
start|stop|restart|enable|disable)
|
||||
/etc/init.d/${SERVICE} ${ACTION}
|
||||
TXT="$ROUTER. Service ${SERVICE} ${ACTION}"
|
||||
;;
|
||||
*) TXT="$ROUTER. Usage: service ${SERVICE} start|stop|restart|enable|disable" ;;
|
||||
esac
|
||||
link_
|
||||
msg_
|
||||
;;
|
||||
# manage wireless radio
|
||||
wifi)
|
||||
ACTION=$(echo $content | awk '{print $2}')
|
||||
case $ACTION in
|
||||
up)
|
||||
/sbin/wifi $ACTION
|
||||
TXT="$ROUTER. Wireless enabled. OK"
|
||||
;;
|
||||
down)
|
||||
/sbin/wifi $ACTION
|
||||
TXT="$ROUTER. Wireless disabled. OK"
|
||||
;;
|
||||
|
||||
*) TXT="$ROUTER. Usage: $COMMAND [up|down]"
|
||||
;;
|
||||
esac
|
||||
link_
|
||||
msg_
|
||||
;;
|
||||
# manage answers channel
|
||||
answer)
|
||||
ACTION=$(echo $content | awk '{print $2}')
|
||||
case $ACTION in
|
||||
sms)
|
||||
echo 0 > /tmp/smstools3.answer
|
||||
TXT="$ROUTER. Answers sended via SMS. OK"
|
||||
msg_
|
||||
;;
|
||||
tel)
|
||||
echo 1 > /tmp/smstools3.answer
|
||||
TXT="$ROUTER. Answers sended via Telegram. OK"
|
||||
msg_
|
||||
;;
|
||||
auto)
|
||||
rm /tmp/smstools3.answer
|
||||
TXT="$ROUTER. Answers sended automatic channel alive."
|
||||
link_
|
||||
msg_
|
||||
;;
|
||||
*)
|
||||
TXT="$ROUTER. Usage: answer [sms|tel|auto]"
|
||||
msg_
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
# print help
|
||||
help)
|
||||
TXT="$ROUTER. Usage: reboot|restart|service|wifi|answer help for more info."
|
||||
link_
|
||||
msg_
|
||||
;;
|
||||
*)
|
||||
TXT="$ROUTER. Send message with text \"help\" for more info."
|
||||
link_
|
||||
msg_
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# resent incoming messages to telegram
|
||||
text=$(cat <<EOF
|
||||
Hostname: $ROUTER
|
||||
$content
|
||||
From $from
|
||||
EOF
|
||||
)
|
||||
/usr/bin/curl -d "chat_id=$chat_id&text=$text" -X POST https://api.telegram.org/bot"$token"/sendMessage
|
||||
fi
|
||||
fi
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-smstools3": {
|
||||
"description": "Grant UCI access for luci-app-smstools3",
|
||||
"read": {
|
||||
"uci": [ "smstools3" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "smstools3" ]
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
Loading…
Reference in New Issue