bird-openwrt: update to version 0.3
[feed/routing.git] / bird-openwrt / bird6-openwrt / src / model / status.lua
1 --[[
2 Copyright (C) 2014-2017 - Eloi Carbo
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ]]--
17
18 local sys = require "luci.sys"
19
20 m = SimpleForm("bird6", "Bird6 Daemon Status Page", "This page let you Start, Stop, Restart and check Bird6 Service Status.")
21 m.reset = false
22 m.submit = false
23
24 s = m:section(SimpleSection)
25
26 start = s:option(Button, "_start", "Start Bird4 Daemon:")
27 start.inputtitle = " Start "
28 start.inputstyle = "apply"
29
30 stop = s:option(Button, "_stop", "Stop Bird4 Daemon:")
31 stop.inputtitle = " Stop "
32 stop.inputstyle = "remove"
33
34 restart = s:option(Button, "_restart", "Restart Bird4 Daemon:")
35 restart.inputtitle = "Restart"
36 restart.inputstyle = "reload"
37
38 output = s:option(DummyValue, "_value", "Service Status")
39 function output.cfgvalue(self, section)
40 local ret = ""
41 if start:formvalue(section) then
42 ret = sys.exec("/etc/init.d/bird6 start_quiet")
43 elseif stop:formvalue(section) then
44 ret = sys.exec("/etc/init.d/bird6 stop_quiet")
45 elseif restart:formvalue(section) then
46 ret = sys.exec("/etc/init.d/bird6 restart_quiet")
47 else
48 ret = sys.exec("/etc/init.d/bird6 status_quiet")
49 end
50 return ret
51 end
52
53 return m