diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-06-30 04:41:00 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-06-30 04:41:00 +0000 |
commit | 105713ff8fec7e6110f6eff120c7765e560bbac8 (patch) | |
tree | 27e3befbc929ba23609e264913e1a0de540cc28e /modules/freifunk/luasrc | |
parent | 55a4c40c03d5e00942f525b70e613c33e783ce99 (diff) |
modules/freifunk: add webpages for remote-update
Diffstat (limited to 'modules/freifunk/luasrc')
-rw-r--r-- | modules/freifunk/luasrc/controller/freifunk/remote_update.lua | 63 | ||||
-rw-r--r-- | modules/freifunk/luasrc/view/freifunk/remote_update.htm | 59 |
2 files changed, 122 insertions, 0 deletions
diff --git a/modules/freifunk/luasrc/controller/freifunk/remote_update.lua b/modules/freifunk/luasrc/controller/freifunk/remote_update.lua new file mode 100644 index 000000000..badfbf2da --- /dev/null +++ b/modules/freifunk/luasrc/controller/freifunk/remote_update.lua @@ -0,0 +1,63 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2009 Jo-Philipp Wich <xm@subsignal.org> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id: freifunk.lua 4649 2009-05-26 18:30:00Z jow $ +]]-- + +local nixio = require "nixio" + +module("luci.controller.freifunk.remote_update", package.seeall) + +function index() + local i18n = luci.i18n.translate + + entry({"admin", "system", "remote_update"}, call("act_remote_update"), + i18n("ff_remote_update", "Freifunk Remote Update"), 90) +end + +function act_remote_update() + if luci.http.formvalue("flash") == "1" then + if luci.http.formvalue("confirm") == "1" then + local nobackup = ( luci.http.formvalue("keepcfg") ~= "1" ) + local noverify = ( luci.http.formvalue("verify") ~= "1" ) + + luci.http.redirect("/luci-static/flashing.html") + + os.execute("start-stop-daemon -S -b -x /usr/sbin/remote-update -- %s%s-s 5 -y" % { + noverify and "-v " or "", + nobackup and "-n " or "" + }) + else + luci.template.render("freifunk/remote_update", {confirm=1}) + end + else + local fd = io.popen("remote-update -c") + local update = { } + + if fd then + while true do + local ln=fd:read("*l") + + if not ln then break + elseif ln:find("Local: ") then update.locvar = ln:match("Local: (%d+)") + elseif ln:find("Remote: ") then update.remver = ln:match("Remote: (%d+)") + elseif ln == "--" then update.info = "" + elseif update.info ~= nil then + update.info = update.info .. ln .. "\n" + end + end + + fd:close() + end + + luci.template.render("freifunk/remote_update", {update=update}) + end +end diff --git a/modules/freifunk/luasrc/view/freifunk/remote_update.htm b/modules/freifunk/luasrc/view/freifunk/remote_update.htm new file mode 100644 index 000000000..3dfaf5d5c --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk/remote_update.htm @@ -0,0 +1,59 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id: contact.htm 3529 2008-10-07 13:10:24Z jow $ + +-%> +<%+header%> + +<h2><%:ff_remote_update Freifunk Remote Update%></h2> + +<p><%:ff_remote_update_desc Check for new firmware versions and perform automatic updates.%></p> + +<% if update then %> + + <% if update.info then %> + <strong><%:ff_remote_update_available Update available!%></strong> + <br /><br /> + <pre><%=update.info%></pre><br /> + <% else %> + <strong><%:ff_remote_update_uptodate The installed firmware is the most recent version.%></strong> + <br /><br /> + <% end %> + + <p> + <form method="post" action="" class="inline"> + <input type="hidden" name="flash" value="1" /> + <input type="submit" class="cbi-button cbi-button-apply" value="<%:ff_remote_update_install Start Upgrade%>" /> + </form> + </p> + +<% elseif confirm then %> + + <strong><%:ff_remote_update_settings Update Settings%></strong> + <br /><br /> + + <p><form method="post" action="" class="inline"> + <input type="hidden" name="flash" value="1" /> + <input type="hidden" name="confirm" value="1" /> + + <input type="checkbox" class="cbi-input-checkbox" name="keepcfg" value="1" checked="checked" id="cb_keepcfg" /> + <label for="cb_keepcfg"><%:ff_remote_update_keepcfg Keep configuration%></label><br /> + + <input type="checkbox" class="cbi-input-checkbox" name="verify" value="1" checked="checked" id="cb_verify" /> + <label for="cb_verify"><%:ff_remote_update_keepcfg Verify downloaded images%></label><br /><br /> + + <input type="submit" class="cbi-button cbi-button-apply" value="<%:ff_remote_update_install Confirm Upgrade%>" /> + </form></p> + +<% end %> + +<%+footer%> |