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
12 $Id: freifunk.lua 4649 2009-05-26 18:30:00Z jow $
15 local nixio = require "nixio"
17 module("luci.controller.freifunk.remote_update", package.seeall)
20 local i18n = luci.i18n.translate
22 entry({"admin", "system", "remote_update"}, call("act_remote_update"),
23 i18n("ff_remote_update", "Freifunk Remote Update"), 90)
26 function act_remote_update()
27 if luci.http.formvalue("flash") == "1" then
28 if luci.http.formvalue("confirm") == "1" then
29 local nobackup = ( luci.http.formvalue("keepcfg") ~= "1" )
30 local noverify = ( luci.http.formvalue("verify") ~= "1" )
32 luci.http.redirect("/luci-static/flashing.html")
34 os.execute("start-stop-daemon -S -b -x /usr/sbin/remote-update -- %s%s-s 5 -y" % {
35 noverify and "-v " or "",
36 nobackup and "-n " or ""
39 luci.template.render("freifunk/remote_update", {confirm=1})
42 local fd = io.popen("remote-update -c")
47 local ln=fd:read("*l")
50 elseif ln:find("Local: ") then update.locvar = ln:match("Local: (%d+)")
51 elseif ln:find("Remote: ") then update.remver = ln:match("Remote: (%d+)")
52 elseif ln == "--" then update.info = ""
53 elseif update.info ~= nil then
54 update.info = update.info .. ln .. "\n"
61 luci.template.render("freifunk/remote_update", {update=update})