Remove remaining references to boa and lucid
[project/luci.git] / modules / admin-core / luasrc / controller / admin / servicectl.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14
15 module("luci.controller.admin.servicectl", package.seeall)
16
17 function index()
18 entry({"servicectl"}, alias("servicectl", "status")).sysauth = "root"
19 entry({"servicectl", "status"}, call("action_status")).leaf = true
20 entry({"servicectl", "restart"}, call("action_restart")).leaf = true
21 end
22
23 function action_status()
24 local data = nixio.fs.readfile("/var/run/luci-reload-status")
25 if data then
26 luci.http.write("/etc/config/")
27 luci.http.write(data)
28 else
29 luci.http.write("finish")
30 end
31 end
32
33 function action_restart(args)
34 local uci = require "luci.model.uci".cursor()
35 if args then
36 local service
37 local services = { }
38
39 for service in args:gmatch("[%w_-]+") do
40 services[#services+1] = service
41 end
42
43 local command = uci:apply(services, true)
44 if nixio.fork() == 0 then
45 local i = nixio.open("/dev/null", "r")
46 local o = nixio.open("/dev/null", "w")
47
48 nixio.dup(i, nixio.stdin)
49 nixio.dup(o, nixio.stdout)
50
51 i:close()
52 o:close()
53
54 nixio.exec("/bin/sh", unpack(command))
55 else
56 luci.http.write("OK")
57 os.exit(0)
58 end
59 end
60 end