1 -- Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
2 -- Licensed to the public under the Apache License 2.0.
4 module("luci.controller.admin.servicectl", package.seeall)
7 entry({"servicectl"}, alias("servicectl", "status")).sysauth = "root"
8 entry({"servicectl", "status"}, call("action_status")).leaf = true
9 entry({"servicectl", "restart"}, call("action_restart")).leaf = true
12 function action_status()
13 local data = nixio.fs.readfile("/var/run/luci-reload-status")
15 luci.http.write("/etc/config/")
18 luci.http.write("finish")
22 function action_restart(args)
23 local uci = require "luci.model.uci".cursor()
28 for service in args:gmatch("[%w_-]+") do
29 services[#services+1] = service
32 local command = uci:apply(services, true)
33 if nixio.fork() == 0 then
34 local i = nixio.open("/dev/null", "r")
35 local o = nixio.open("/dev/null", "w")
37 nixio.dup(i, nixio.stdin)
38 nixio.dup(o, nixio.stdout)
43 nixio.exec("/bin/sh", unpack(command))