2 LuCI - Lua Configuration Interface
4 Copyright 2009 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
14 module("luci.controller.freifunk.remote_update", package.seeall)
17 if not nixio.fs.access("/usr/sbin/remote-update") then
21 entry({"admin", "system", "remote_update"}, call("act_remote_update"),
22 _("Freifunk Remote Update"), 90)
25 function act_remote_update()
26 if luci.http.formvalue("flash") == "1" then
27 if luci.http.formvalue("confirm") == "1" then
28 local nobackup = ( luci.http.formvalue("keepcfg") ~= "1" )
29 local noverify = ( luci.http.formvalue("verify") ~= "1" )
31 luci.http.redirect("/luci-static/flashing.html")
33 os.execute("start-stop-daemon -S -b -x /usr/sbin/remote-update -- %s%s-s 5 -y" % {
34 noverify and "-v " or "",
35 nobackup and "-n " or ""
38 luci.template.render("freifunk/remote_update", {confirm=1})
41 local fd = io.popen("remote-update -c")
46 local ln=fd:read("*l")
49 elseif ln:find("Local: ") then update.locvar = ln:match("Local: (%d+)")
50 elseif ln:find("Remote: ") then update.remver = ln:match("Remote: (%d+)")
51 elseif ln == "--" then update.info = ""
52 elseif update.info ~= nil then
53 update.info = update.info .. ln .. "\n"
60 luci.template.render("freifunk/remote_update", {update=update})