From: Jo-Philipp Wich Date: Tue, 30 Jun 2009 04:41:00 +0000 (+0000) Subject: modules/freifunk: add webpages for remote-update X-Git-Tag: 0.10.0~1479 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=105713ff8fec7e6110f6eff120c7765e560bbac8;p=oweals%2Fluci.git modules/freifunk: add webpages for remote-update --- diff --git a/modules/freifunk/htdocs/luci-static/flashing.html b/modules/freifunk/htdocs/luci-static/flashing.html new file mode 100644 index 000000000..f2de57507 --- /dev/null +++ b/modules/freifunk/htdocs/luci-static/flashing.html @@ -0,0 +1,84 @@ + + + + + + LuCI - System Upgrade + + + + + + + +
+

Performing Upgrade

+ +

+ The System is flashing now. The procedure can take up to 20 minutes, + please be patient and wait until this page reloads itself. + +
+ + Remaining time (estimated): unknown +

+
+ + + diff --git a/modules/freifunk/htdocs/luci-static/resources/flashing.gif b/modules/freifunk/htdocs/luci-static/resources/flashing.gif new file mode 100644 index 000000000..e207fc56a Binary files /dev/null and b/modules/freifunk/htdocs/luci-static/resources/flashing.gif differ 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 + +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 +Copyright 2008 Jo-Philipp Wich + +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%> + +

<%:ff_remote_update Freifunk Remote Update%>

+ +

<%:ff_remote_update_desc Check for new firmware versions and perform automatic updates.%>

+ +<% if update then %> + + <% if update.info then %> + <%:ff_remote_update_available Update available!%> +

+
<%=update.info%>

+ <% else %> + <%:ff_remote_update_uptodate The installed firmware is the most recent version.%> +

+ <% end %> + +

+

+ + +
+

+ +<% elseif confirm then %> + + <%:ff_remote_update_settings Update Settings%> +

+ +

+ + + + +
+ + +

+ + +

+ +<% end %> + +<%+footer%> diff --git a/modules/freifunk/root/etc/config/freifunk b/modules/freifunk/root/etc/config/freifunk index 49112894c..d6f3d57df 100644 --- a/modules/freifunk/root/etc/config/freifunk +++ b/modules/freifunk/root/etc/config/freifunk @@ -78,6 +78,7 @@ config defaults time config defaults upgrade option repository "http://dev.luci.freifunk-halle.net/freifunk-snapshots" + option rssfeed "http://firmware.leipzig.freifunk.net/kamikaze/.rss.xml" config community leipzig option name "Freifunk Leipzig" diff --git a/modules/freifunk/root/usr/sbin/remote-update b/modules/freifunk/root/usr/sbin/remote-update index 3f50f3207..67751d6cf 100755 --- a/modules/freifunk/root/usr/sbin/remote-update +++ b/modules/freifunk/root/usr/sbin/remote-update @@ -49,9 +49,14 @@ find_local_checksum() echo $1 } +find_remote_info() +{ + wget -qO- "${1%/*}/VERSION.txt" 2>/dev/null +} + find_remote_version() { - wget -qO- "${1%/*}/VERSION.txt" 2>/dev/null | \ + find_remote_info "$1" | \ sed -ne "s!.*$D4/$D2/$D2 $D2:$D2.*!\\1\\2\\3\\4\\5!p;t" } @@ -197,9 +202,12 @@ if [ "$checkupdate" = 1 ]; then [ -n "$v1" -a -n "$v2" ] && { version_compare "$v1" "$v2" [ $? == 2 ] && { - echo "Update available! $v1 -> $v2" + echo "Update available!${NL}Local: $v1${NL}Remote: $v2${NL}--" + find_remote_info "$image_url" + exit 0 } || { echo "Local version $v1 is up to date" + exit 2 } } || { echo "No remote time stamp found."