From 105713ff8fec7e6110f6eff120c7765e560bbac8 Mon Sep 17 00:00:00 2001
From: Jo-Philipp Wich
Date: Tue, 30 Jun 2009 04:41:00 +0000
Subject: [PATCH] modules/freifunk: add webpages for remote-update
---
.../freifunk/htdocs/luci-static/flashing.html | 84 ++++++++++++++++++
.../htdocs/luci-static/resources/flashing.gif | Bin 0 -> 4261 bytes
.../controller/freifunk/remote_update.lua | 63 +++++++++++++
.../luasrc/view/freifunk/remote_update.htm | 59 ++++++++++++
modules/freifunk/root/etc/config/freifunk | 1 +
modules/freifunk/root/usr/sbin/remote-update | 12 ++-
6 files changed, 217 insertions(+), 2 deletions(-)
create mode 100644 modules/freifunk/htdocs/luci-static/flashing.html
create mode 100644 modules/freifunk/htdocs/luci-static/resources/flashing.gif
create mode 100644 modules/freifunk/luasrc/controller/freifunk/remote_update.lua
create mode 100644 modules/freifunk/luasrc/view/freifunk/remote_update.htm
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 0000000000000000000000000000000000000000..e207fc56a1fcf035eba568f4ba5396f6dcd030fc
GIT binary patch
literal 4261
zcmajgX;_kJ-^cNji&a1cMa3lt)Kb%OsZlCxE>KgmOv_5k8Yn9*YiOM^XX3&Q*U&6!
zvcjcwtR^yBb?R~}GA%7r+zJ#GmlV{jx$o|or~B3O=6R0Zov%N~_y0SCLRNE@37CKh
zMgaKq>C@cYr@2p`z@8Sy;a4*s=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Kcd6CL9?Z`%18tA5D^6?_^FxL$tQH_g*a7)o$?
zyX~lTCiWJn?Ry;_UW(dbEivI-5e7?4B;DJ2;(!Q#2aR&n)A>(9MvW15qD`~=!U^oj
z-nrMsis0UMBVwgrUqj|Mhi82(tdwFik!6+CT6HQrfKJ2>N4d1M5SW%2J6iENxleA8
zPdLeymL+inVdTc!?7_MKm&H^DLIh+MxN$(~MKf{|e`mQio+WINiW`4ha8|n3nafz?
z#;z6m%Wx&Wx8LTk0Bz#VVze;tTbp
zn{=ieBXHRJQpofZ?n40{$e8Z6S0f7TmVx(n#iq+aPJ;~f7^olhIjSYoqhTlL9*TXU}?wm1pNn)Z!k
zoFz;bAgCkz5q3tqw4o;H*oYJkOE>`2tzkZc38lh}1vs&iU!n=dIdg!X#9Bv4Cpwr=
z=@3|Z<T(Tq2DvhLouESibXw$#iu;iR#9i_wHhMezM*1U!By((^AO`OS`jK#6D?_0)JDq>
za3JDdMoN&=!P&T`Rb;z*F$UyAdElW)5p}_oW(z8`kcdHFP6z{m`gRfKbDZ~~5Ly;$
zwr4|tYt(3WyA{bpCCM)t;W`Z`dM!P>;cB#)99gl+FkG5*|EEyEf(s8m%(T*~U%Lf4
zgTkeo2*C4%g1g3oX-O&4N9IIFI~Hf`k#b8-zW)OFex3%huc^a2Pbw?Y7+#AL3#u<%
z%L(FOZe+~LSyzyKV=0ixtuB>9rqLTEiXuXxhZ$*UsVJv;hfO1NqAqjP5x>wpjw!Rd
z4?VHCKn>fnSUMXGzH{14C4IwZ37f?P?7DgD3F0V@;!Fe5Pl%zPNOb`7C=M|=y+GuP
znB(oE
+
+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."
--
2.25.1