2 LuCI - Lua Configuration Interface
4 Copyright 2010 Jo-Philipp Wich <xm@subsignal.org>
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
10 http://www.apache.org/licenses/LICENSE-2.0
15 module("luci.controller.admin.servicectl", package.seeall)
18 luci.i18n.loadc("base")
19 local i18n = luci.i18n.translate
21 entry({"servicectl"}, alias("servicectl", "status"), nil, 1).sysauth = "root"
22 entry({"servicectl", "status"}, call("action_status"), nil, 2).leaf = true
23 entry({"servicectl", "restart"}, call("action_restart"), nil, 3).leaf = true
26 function action_status()
27 local data = nixio.fs.readfile("/var/run/luci-reload-status")
29 luci.http.write("/etc/config/")
32 luci.http.write("finish")
36 function action_restart()
37 if luci.dispatcher.context.requestpath[3] then
41 for service in luci.dispatcher.context.requestpath[3]:gmatch("%w+") do
42 services[#services+1] = service
45 if nixio.fork() == 0 then
46 local i = nixio.open("/dev/null", "r")
47 local o = nixio.open("/dev/null", "w")
49 nixio.dup(i, nixio.stdin)
50 nixio.dup(o, nixio.stdout)
55 nixio.exec("/bin/sh", "/sbin/luci-reload", unpack(services))