diff options
Diffstat (limited to 'applications/luci-app-wifischedule')
6 files changed, 490 insertions, 62 deletions
diff --git a/applications/luci-app-wifischedule/luasrc/controller/wifischedule/wifi_schedule.lua b/applications/luci-app-wifischedule/luasrc/controller/wifischedule/wifi_schedule.lua index a33c7aab9a..261cf36d0f 100644 --- a/applications/luci-app-wifischedule/luasrc/controller/wifischedule/wifi_schedule.lua +++ b/applications/luci-app-wifischedule/luasrc/controller/wifischedule/wifi_schedule.lua @@ -12,21 +12,31 @@ -- -- Author: Nils Koenig <openwrt@newk.it> -module("luci.controller.wifischedule.wifi_schedule", package.seeall) +module("luci.controller.wifischedule.wifi_schedule", package.seeall) + +local fs = require "nixio.fs" +local sys = require "luci.sys" +local template = require "luci.template" +local i18n = require "luci.i18n" function index() - entry({"admin", "wifi_schedule"}, firstchild(), "Wifi Schedule", 60).dependent=false - entry({"admin", "wifi_schedule", "tab_from_cbi"}, cbi("wifischedule/wifi_schedule"), "Schedule", 1) - entry({"admin", "wifi_schedule", "wifi_schedule"}, call("wifi_schedule_log"), "View Logfile", 2) - entry({"admin", "wifi_schedule", "cronjob"}, call("view_crontab"), "View Cron Jobs", 3) + if not nixio.fs.access("/etc/config/wifi_schedule") then + return + end + entry({"admin", "services", "wifi_schedule"}, firstchild(), _("Wifi Schedule"), 60).dependent=false + entry({"admin", "services", "wifi_schedule", "tab_from_cbi"}, cbi("wifischedule/wifi_schedule"), _("Schedule"), 1) + entry({"admin", "services", "wifi_schedule", "wifi_schedule"}, call("wifi_schedule_log"), _("View Logfile"), 2) + entry({"admin", "services", "wifi_schedule", "cronjob"}, call("view_crontab"), _("View Cron Jobs"), 3) end function wifi_schedule_log() - local logfile = luci.sys.exec("cat /tmp/log/wifi_schedule.log") - luci.template.render("wifischedule/file_viewer", {title="Wifi Schedule Logfile", content=logfile}) + local logfile = fs.readfile("/tmp/log/wifi_schedule.log") or "" + template.render("wifischedule/file_viewer", + {title = i18n.translate("Wifi Schedule Logfile"), content = logfile}) end function view_crontab() - local crontab = luci.sys.exec("cat /etc/crontabs/root") - luci.template.render("wifischedule/file_viewer", {title="Cron Jobs", content=crontab}) + local crontab = fs.readfile("/etc/crontabs/root") or "" + template.render("wifischedule/file_viewer", + {title = i18n.translate("Cron Jobs"), content = crontab}) end diff --git a/applications/luci-app-wifischedule/luasrc/model/cbi/wifischedule/wifi_schedule.lua b/applications/luci-app-wifischedule/luasrc/model/cbi/wifischedule/wifi_schedule.lua index 2cca476b4f..1d301219a8 100644 --- a/applications/luci-app-wifischedule/luasrc/model/cbi/wifischedule/wifi_schedule.lua +++ b/applications/luci-app-wifischedule/luasrc/model/cbi/wifischedule/wifi_schedule.lua @@ -12,15 +12,11 @@ -- -- Author: Nils Koenig <openwrt@newk.it> -function file_exists(name) - local f=io.open(name,"r") - if f~=nil then io.close(f) return true else return false end -end - +local fs = require "nixio.fs" +local sys = require "luci.sys" function time_validator(self, value, desc) if value ~= nil then - h_str, m_str = string.match(value, "^(%d%d?):(%d%d?)$") h = tonumber(h_str) m = tonumber(m_str) @@ -32,21 +28,21 @@ function time_validator(self, value, desc) m <= 59) then return value end - end - return nil, translate("The value '" .. desc .. "' is invalid") + end + return nil, translatef("The value %s is invalid", desc) end -- ------------------------------------------------------------------------------------------------- -- BEGIN Map -m = Map("wifi_schedule", translate("Wifi Schedule"), translate("Defines a schedule when to turn on and off wifi.")) +m = Map("wifi_schedule", translate("Wifi Schedule"), translate("Defines a schedule when to turn on and off wifi.")) function m.on_commit(self) - luci.sys.exec("/usr/bin/wifi_schedule.sh cron") + sys.exec("/usr/bin/wifi_schedule.sh cron") end -- END Map -- BEGIN Global Section -global_section = m:section(TypedSection, "global", "Global Settings") +global_section = m:section(TypedSection, "global", translate("Global Settings")) global_section.optional = false global_section.rmempty = false global_section.anonymous = true @@ -54,13 +50,13 @@ global_section.anonymous = true -- BEGIN Global Enable Checkbox global_enable = global_section:option(Flag, "enabled", translate("Enable Wifi Schedule")) -global_enable.optional=false; -global_enable.rmempty = false; +global_enable.optional = false +global_enable.rmempty = false function global_enable.validate(self, value, global_section) if value == "1" then - if ( file_exists("/sbin/wifi") and - file_exists("/usr/bin/wifi_schedule.sh") )then + if ( fs.access("/sbin/wifi") and + fs.access("/usr/bin/wifi_schedule.sh") )then return value else return nil, translate("Could not find required /usr/bin/wifi_schedule.sh or /sbin/wifi") @@ -71,39 +67,38 @@ function global_enable.validate(self, value, global_section) end -- END Global Enable Checkbox - -- BEGIN Global Logging Checkbox global_logging = global_section:option(Flag, "logging", translate("Enable logging")) -global_logging.optional=false; -global_logging.rmempty = false; +global_logging.optional = false +global_logging.rmempty = false global_logging.default = 0 -- END Global Enable Checkbox -- BEGIN Global Activate WiFi Button enable_wifi = global_section:option(Button, "enable_wifi", translate("Activate wifi")) function enable_wifi.write() - luci.sys.exec("/usr/bin/wifi_schedule.sh start manual") + sys.exec("/usr/bin/wifi_schedule.sh start manual") end -- END Global Activate Wifi Button -- BEGIN Global Disable WiFi Gracefully Button disable_wifi_gracefully = global_section:option(Button, "disable_wifi_gracefully", translate("Disable wifi gracefully")) function disable_wifi_gracefully.write() - luci.sys.exec("/usr/bin/wifi_schedule.sh stop manual") + sys.exec("/usr/bin/wifi_schedule.sh stop manual") end --- END Global Disable Wifi Gracefully Button +-- END Global Disable Wifi Gracefully Button -- BEGIN Disable WiFi Forced Button disable_wifi_forced = global_section:option(Button, "disable_wifi_forced", translate("Disabled wifi forced")) function disable_wifi_forced.write() - luci.sys.exec("/usr/bin/wifi_schedule.sh forcestop manual") + sys.exec("/usr/bin/wifi_schedule.sh forcestop manual") end -- END Global Disable WiFi Forced Button -- BEGIN Global Unload Modules Checkbox global_unload_modules = global_section:option(Flag, "unload_modules", translate("Unload Modules (experimental; saves more power)")) -global_unload_modules.optional = false; -global_unload_modules.rmempty = false; +global_unload_modules.optional = false +global_unload_modules.rmempty = false global_unload_modules.default = 0 -- END Global Unload Modules Checkbox @@ -111,13 +106,13 @@ global_unload_modules.default = 0 -- BEGIN Modules modules = global_section:option(TextValue, "modules", "") modules:depends("unload_modules", global_unload_modules.enabled); -modules.wrap = "off" -modules.rows = 10 +modules.wrap = "off" +modules.rows = 10 function modules.cfgvalue(self, section) - mod=uci.get("wifi_schedule", section, "modules") + mod = uci.get("wifi_schedule", section, "modules") if mod == nil then - mod="" + mod = "" end return mod:gsub(" ", "\r\n") end @@ -131,45 +126,44 @@ function modules.write(self, section, value) end -- END Modules --- BEGIN Determine Modules +-- BEGIN Determine Modules determine_modules = global_section:option(Button, "determine_modules", translate("Determine Modules Automatically")) determine_modules:depends("unload_modules", global_unload_modules.enabled); function determine_modules.write(self, section) - output = luci.sys.exec("/usr/bin/wifi_schedule.sh getmodules") + output = sys.exec("/usr/bin/wifi_schedule.sh getmodules") modules:write(section, output) end -- END Determine Modules - -- BEGIN Section -d = m:section(TypedSection, "entry", "Schedule events") -d.addremove = true +d = m:section(TypedSection, "entry", translate("Schedule events")) +d.addremove = true --d.anonymous = true -- END Section -- BEGIN Enable Checkbox c = d:option(Flag, "enabled", translate("Enable")) -c.optional=false; c.rmempty = false; +c.optional = false +c.rmempty = false -- END Enable Checkbox - -- BEGIN Day(s) of Week dow = d:option(MultiValue, "daysofweek", translate("Day(s) of Week")) dow.optional = false dow.rmempty = false -dow:value("Monday") -dow:value("Tuesday") -dow:value("Wednesday") -dow:value("Thursday") -dow:value("Friday") -dow:value("Saturday") -dow:value("Sunday") +dow:value("Monday", translate("Monday")) +dow:value("Tuesday", translate("Tuesday")) +dow:value("Wednesday", translate("Wednesday")) +dow:value("Thursday", translate("Thursday")) +dow:value("Friday", translate("Friday")) +dow:value("Saturday", translate("Saturday")) +dow:value("Sunday", translate("Sunday")) -- END Day(s) of Weel -- BEGIN Start Wifi Dropdown starttime = d:option(Value, "starttime", translate("Start WiFi")) -starttime.optional=false; -starttime.rmempty = false; +starttime.optional = false +starttime.rmempty = false starttime:value("00:00") starttime:value("01:00") starttime:value("02:00") @@ -198,14 +192,12 @@ starttime:value("23:00") function starttime.validate(self, value, d) return time_validator(self, value, translate("Start Time")) end - -- END Start Wifi Dropdown - -- BEGIN Stop Wifi Dropdown -stoptime = d:option(Value, "stoptime", translate("Stop WiFi")) -stoptime.optional=false; -stoptime.rmempty = false; +stoptime = d:option(Value, "stoptime", translate("Stop WiFi")) +stoptime.optional = false +stoptime.rmempty = false stoptime:value("00:00") stoptime:value("01:00") stoptime:value("02:00") @@ -236,15 +228,14 @@ function stoptime.validate(self, value, d) end -- END Stop Wifi Dropdown - -- BEGIN Force Wifi Stop Checkbox force_wifi = d:option(Flag, "forcewifidown", translate("Force disabling wifi even if stations associated")) force_wifi.default = false -force_wifi.rmempty = false; +force_wifi.rmempty = false function force_wifi.validate(self, value, d) if value == "0" then - if file_exists("/usr/bin/iwinfo") then + if fs.access("/usr/bin/iwinfo") then return value else return nil, translate("Could not find required programm /usr/bin/iwinfo") @@ -255,5 +246,4 @@ function force_wifi.validate(self, value, d) end -- END Force Wifi Checkbox - return m diff --git a/applications/luci-app-wifischedule/po/ja/wifischedule.po b/applications/luci-app-wifischedule/po/ja/wifischedule.po new file mode 100644 index 0000000000..3bc7864ad7 --- /dev/null +++ b/applications/luci-app-wifischedule/po/ja/wifischedule.po @@ -0,0 +1,112 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: INAGAKI Hiroshi <musashino.open@gmail.com>\n" +"Language-Team: \n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.11\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgid "Activate wifi" +msgstr "WiFiのアクティブ化" + +msgid "Could not find required /usr/bin/wifi_schedule.sh or /sbin/wifi" +msgstr "必須の /usr/bin/wifi_schedule.sh または /sbin/wifi が見つかりませんでした。" + +msgid "Could not find required programm /usr/bin/iwinfo" +msgstr "必須のプログラム /usr/bin/iwinfo が見つかりませんでした。" + +msgid "Cron Jobs" +msgstr "Cronジョブ" + +msgid "Day(s) of Week" +msgstr "曜日" + +msgid "Defines a schedule when to turn on and off wifi." +msgstr "WiFiのオンとオフを切り替えるスケジュールを設定します。" + +msgid "Determine Modules Automatically" +msgstr "モジュールを自動的に決定する" + +msgid "Disable wifi gracefully" +msgstr "WiFiの通常終了" + +msgid "Disabled wifi forced" +msgstr "WiFiの強制終了" + +msgid "Enable" +msgstr "有効" + +msgid "Enable Wifi Schedule" +msgstr "WiFi スケジュールの有効化" + +msgid "Enable logging" +msgstr "ログの有効化" + +msgid "Force disabling wifi even if stations associated" +msgstr "ステーションが関連付けられていてもWiFiを強制終了する" + +msgid "Friday" +msgstr "金曜日" + +msgid "Global Settings" +msgstr "全体設定" + +msgid "Monday" +msgstr "月曜日" + +msgid "Saturday" +msgstr "土曜日" + +msgid "Schedule" +msgstr "スケジュール" + +msgid "Schedule events" +msgstr "実行スケジュール" + +msgid "Start Time" +msgstr "開始時刻" + +msgid "Start WiFi" +msgstr "WiFiの開始" + +msgid "Stop Time" +msgstr "停止時刻" + +msgid "Stop WiFi" +msgstr "WiFiの停止" + +msgid "Sunday" +msgstr "日曜日" + +msgid "The value %s is invalid" +msgstr "%s の値が無効です" + +msgid "Thursday" +msgstr "木曜日" + +msgid "Tuesday" +msgstr "火曜日" + +msgid "Unload Modules (experimental; saves more power)" +msgstr "モジュールのアンロード(実験的、より省電力)" + +msgid "View Cron Jobs" +msgstr "Cronジョブの確認" + +msgid "View Logfile" +msgstr "ログファイルの確認" + +msgid "Wednesday" +msgstr "水曜日" + +msgid "Wifi Schedule" +msgstr "WiFi スケジュール" + +msgid "Wifi Schedule Logfile" +msgstr "WiFiスケジュール ログファイル" diff --git a/applications/luci-app-wifischedule/po/pt-br/wifischedule.po b/applications/luci-app-wifischedule/po/pt-br/wifischedule.po new file mode 100644 index 0000000000..19e31b54ca --- /dev/null +++ b/applications/luci-app-wifischedule/po/pt-br/wifischedule.po @@ -0,0 +1,114 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.11\n" +"Last-Translator: Luiz Angelo Daros de Luca <luizluca@gmail.com>\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Language: pt_BR\n" + +msgid "Activate wifi" +msgstr "Ativar a WiFi" + +msgid "Could not find required /usr/bin/wifi_schedule.sh or /sbin/wifi" +msgstr "" +"Não foi possível localizar os programas necessários '/usr/bin/wifi_schedule." +"sh' ou '/sbin/wifi'." + +msgid "Could not find required programm /usr/bin/iwinfo" +msgstr "Não foi possível localizar o programa necessário '/usr/bin/iwinfo'" + +msgid "Cron Jobs" +msgstr "Tarefas da Cron" + +msgid "Day(s) of Week" +msgstr "Dia(s) da semana" + +msgid "Defines a schedule when to turn on and off wifi." +msgstr "Define um agendamento para quando ligar ou desligar a WiFi." + +msgid "Determine Modules Automatically" +msgstr "Determinar os Módulos Automaticamente" + +msgid "Disable wifi gracefully" +msgstr "Desabilitar a WiFi amistosamente" + +msgid "Disabled wifi forced" +msgstr "WiFi foi desabilitada de forma forçada." + +msgid "Enable" +msgstr "Habilitar" + +msgid "Enable Wifi Schedule" +msgstr "Habilitar o agendamento da WiFi" + +msgid "Enable logging" +msgstr "Habilite os registros (log)" + +msgid "Force disabling wifi even if stations associated" +msgstr "Force a desativação da WiFi mesmo se existirem estações associadas " + +msgid "Friday" +msgstr "Sexta-feira" + +msgid "Global Settings" +msgstr "Configurações Globais" + +msgid "Monday" +msgstr "Segunda-Feira" + +msgid "Saturday" +msgstr "Sábado" + +msgid "Schedule" +msgstr "Agendamento" + +msgid "Schedule events" +msgstr "Eventos do agendamento" + +msgid "Start Time" +msgstr "Hora Inicial" + +msgid "Start WiFi" +msgstr "Iniciar WiFi" + +msgid "Stop Time" +msgstr "Hora Final" + +msgid "Stop WiFi" +msgstr "Parar WiFi" + +msgid "Sunday" +msgstr "Domingo" + +msgid "The value %s is invalid" +msgstr "O valor %s é inválido" + +msgid "Thursday" +msgstr "Quita-feira" + +msgid "Tuesday" +msgstr "Terça-feira" + +msgid "Unload Modules (experimental; saves more power)" +msgstr "Descarregar Módulos (experimental, poupa mais energia)" + +msgid "View Cron Jobs" +msgstr "Visualizar Tarefas da Cron" + +msgid "View Logfile" +msgstr "Visualizar o Arquivo de Registros (log)" + +msgid "Wednesday" +msgstr "Quarta-feira" + +msgid "Wifi Schedule" +msgstr "Agendamento da Wifi" + +msgid "Wifi Schedule Logfile" +msgstr "Arquivo de Registros (log) do Agendamento da Wifi" diff --git a/applications/luci-app-wifischedule/po/templates/wifischedule.pot b/applications/luci-app-wifischedule/po/templates/wifischedule.pot new file mode 100644 index 0000000000..639c432e5e --- /dev/null +++ b/applications/luci-app-wifischedule/po/templates/wifischedule.pot @@ -0,0 +1,101 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +msgid "Activate wifi" +msgstr "" + +msgid "Could not find required /usr/bin/wifi_schedule.sh or /sbin/wifi" +msgstr "" + +msgid "Could not find required programm /usr/bin/iwinfo" +msgstr "" + +msgid "Cron Jobs" +msgstr "" + +msgid "Day(s) of Week" +msgstr "" + +msgid "Defines a schedule when to turn on and off wifi." +msgstr "" + +msgid "Determine Modules Automatically" +msgstr "" + +msgid "Disable wifi gracefully" +msgstr "" + +msgid "Disabled wifi forced" +msgstr "" + +msgid "Enable" +msgstr "" + +msgid "Enable Wifi Schedule" +msgstr "" + +msgid "Enable logging" +msgstr "" + +msgid "Force disabling wifi even if stations associated" +msgstr "" + +msgid "Friday" +msgstr "" + +msgid "Global Settings" +msgstr "" + +msgid "Monday" +msgstr "" + +msgid "Saturday" +msgstr "" + +msgid "Schedule" +msgstr "" + +msgid "Schedule events" +msgstr "" + +msgid "Start Time" +msgstr "" + +msgid "Start WiFi" +msgstr "" + +msgid "Stop Time" +msgstr "" + +msgid "Stop WiFi" +msgstr "" + +msgid "Sunday" +msgstr "" + +msgid "The value %s is invalid" +msgstr "" + +msgid "Thursday" +msgstr "" + +msgid "Tuesday" +msgstr "" + +msgid "Unload Modules (experimental; saves more power)" +msgstr "" + +msgid "View Cron Jobs" +msgstr "" + +msgid "View Logfile" +msgstr "" + +msgid "Wednesday" +msgstr "" + +msgid "Wifi Schedule" +msgstr "" + +msgid "Wifi Schedule Logfile" +msgstr "" diff --git a/applications/luci-app-wifischedule/po/zh-cn/wifischedule.po b/applications/luci-app-wifischedule/po/zh-cn/wifischedule.po new file mode 100644 index 0000000000..ab3a8d0bf3 --- /dev/null +++ b/applications/luci-app-wifischedule/po/zh-cn/wifischedule.po @@ -0,0 +1,101 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8\n" + +msgid "Activate wifi" +msgstr "激活 WiFi" + +msgid "Could not find required /usr/bin/wifi_schedule.sh or /sbin/wifi" +msgstr "无法找到必需的 /usr/bin/wifi_schedule.sh 或 /sbin/wifi" + +msgid "Could not find required programm /usr/bin/iwinfo" +msgstr "无法找到必需程序:/usr/bin/iwinfo" + +msgid "Cron Jobs" +msgstr "计划任务" + +msgid "Day(s) of Week" +msgstr "星期" + +msgid "Defines a schedule when to turn on and off wifi." +msgstr "定义自动打开和关闭 WiFi 的计划表" + +msgid "Determine Modules Automatically" +msgstr "自动确定模块" + +msgid "Disable wifi gracefully" +msgstr "正常关闭 WiFi" + +msgid "Disabled wifi forced" +msgstr "强制关闭 WiFi" + +msgid "Enable" +msgstr "启用" + +msgid "Enable Wifi Schedule" +msgstr "启用 WiFi 计划" + +msgid "Enable logging" +msgstr "启用日志" + +msgid "Force disabling wifi even if stations associated" +msgstr "即使有设备连接也强制关闭 WiFi" + +msgid "Friday" +msgstr "星期五" + +msgid "Global Settings" +msgstr "全局设置" + +msgid "Monday" +msgstr "星期一" + +msgid "Saturday" +msgstr "星期六" + +msgid "Schedule" +msgstr "计划表" + +msgid "Schedule events" +msgstr "计划事件" + +msgid "Start Time" +msgstr "启动时间" + +msgid "Start WiFi" +msgstr "启动 WiFi" + +msgid "Stop Time" +msgstr "关闭时间" + +msgid "Stop WiFi" +msgstr "关闭 WiFi" + +msgid "Sunday" +msgstr "星期日" + +msgid "The value %s is invalid" +msgstr "%s 的值无效" + +msgid "Thursday" +msgstr "星期四" + +msgid "Tuesday" +msgstr "星期二" + +msgid "Unload Modules (experimental; saves more power)" +msgstr "卸载模块(实验性的,节省更多电量)" + +msgid "View Cron Jobs" +msgstr "查看计划任务" + +msgid "View Logfile" +msgstr "查看日志文件" + +msgid "Wednesday" +msgstr "星期三" + +msgid "Wifi Schedule" +msgstr "WiFi 计划" + +msgid "Wifi Schedule Logfile" +msgstr "WiFi 计划日志文件" |