Show Updatewarning in WebUI

Submitted by Christian Dresel on Feb. 14, 2017, 5:24 p.m.

Details

Message ID 1487093064-6584-1-git-send-email-fff@chrisi01.de
State Superseded
Headers show

Commit Message

Christian Dresel Feb. 14, 2017, 5:24 p.m.
Dieses Patch zeigt im Loginbereich des WebUI eine Warnung an, wenn es eine
neue Firmwareversion gibt

Signed-off-by: Christian Dresel <fff@chrisi01.de>
---
 src/packages/fff/fff-web/Makefile                  |  2 +-
 .../fff/fff-web/files/www/ssl/cgi-bin/header       | 25 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-web/Makefile b/src/packages/fff/fff-web/Makefile
index 5772f87..723d9a9 100644
--- a/src/packages/fff/fff-web/Makefile
+++ b/src/packages/fff/fff-web/Makefile
@@ -1,7 +1,7 @@ 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fff-web
-PKG_VERSION:=0.0.3
+PKG_VERSION:=0.0.4
 PKG_RELEASE:=2
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/fff-web
diff --git a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/header b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/header
index 92bdbc6..6a414b1 100755
--- a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/header
+++ b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/header
@@ -1,6 +1,8 @@ 
 #!/usr/bin/haserl
 
 <%
+. /etc/community.cfg                                                                                           
+. /etc/firmware_release  
 echo -en "Content-Type: text/html\r\n\r\n"
 nav_entry() {
 	script_file="/cgi-bin/$1"
@@ -12,6 +14,20 @@  nav_entry() {
 
 HOSTNAME=$(uci -q get 'system.@system[0].hostname')
 
+NOW=$(date +%s)                                                                                                
+#Check if new Firmware check older then 1 day                                                                  
+if [ "$(cat /tmp/fwcheck)" -lt "$NOW" ] ; then                                                                 
+        rm -f /tmp/isupdate                                                                                    
+        NEXTUPDATE=$(($(date +%s)+86400))                                                                      
+        echo $NEXTUPDATE > /tmp/fwcheck                                                                        
+        wget "${UPGRADE_PATH}/release.nfo" -P /tmp                                                             
+        VERSION=$(cat /tmp/release.nfo|awk -F: '/VERSION:/ { print $2 }')                                      
+        rm -f release.nfo                                                                                      
+        if [ "$VERSION" != "$FIRMWARE_VERSION" ]; then                                                                                                       
+                echo 1 > /tmp/isupdate                                                                                                                       
+        fi                                                                                                                                                   
+fi 
+
 %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
@@ -47,3 +63,12 @@  HOSTNAME=$(uci -q get 'system.@system[0].hostname')
 	<div id="container">
 		<div id="primarycontainer">
 			<div id="primarycontent">
+			<%       
+			if [ "$(cat /tmp/isupdate)" -eq 1 ] ; then
+			%>                
+				<table style="width: 100%;">             
+					<tr>
+						<td><span style="font-size: 18pt; color:#FF0000">Es ist eine neue Firmware für deinen Freifunkrouter verfügbar</td>
+					</tr>
+				</table>
+			<% fi %>

Comments

Robert Langhammer Feb. 14, 2017, 9:19 p.m.
Hi Christian, hab mal was rein geschrieben. Warum möchtest du eigentlich
vor einer neuen Firmwareversion warnen? So schlimm sind die
normalerweise nicht.


Am 14.02.2017 um 18:24 schrieb Christian Dresel:
> Dieses Patch zeigt im Loginbereich des WebUI eine Warnung an, wenn es eine
> neue Firmwareversion gibt
>
> Signed-off-by: Christian Dresel <fff@chrisi01.de>
> ---
>  src/packages/fff/fff-web/Makefile                  |  2 +-
>  .../fff/fff-web/files/www/ssl/cgi-bin/header       | 25 ++++++++++++++++++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/src/packages/fff/fff-web/Makefile b/src/packages/fff/fff-web/Makefile
> index 5772f87..723d9a9 100644
> --- a/src/packages/fff/fff-web/Makefile
> +++ b/src/packages/fff/fff-web/Makefile
> @@ -1,7 +1,7 @@
>  include $(TOPDIR)/rules.mk
>  
>  PKG_NAME:=fff-web
> -PKG_VERSION:=0.0.3
> +PKG_VERSION:=0.0.4
>  PKG_RELEASE:=2
>  
>  PKG_BUILD_DIR:=$(BUILD_DIR)/fff-web
> diff --git a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/header b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/header
> index 92bdbc6..6a414b1 100755
> --- a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/header
> +++ b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/header
> @@ -1,6 +1,8 @@
>  #!/usr/bin/haserl
>  
>  <%
> +. /etc/community.cfg                                                                                           
> +. /etc/firmware_release  
>  echo -en "Content-Type: text/html\r\n\r\n"
>  nav_entry() {
>  	script_file="/cgi-bin/$1"
> @@ -12,6 +14,20 @@ nav_entry() {
>  
>  HOSTNAME=$(uci -q get 'system.@system[0].hostname')
>  
> +NOW=$(date +%s)                                                                                                
> +#Check if new Firmware check older then 1 day   
das wird so nicht laufen. Die Datei /tmp/fwcheck gibts ja erstmal nicht
und wird in der if-Schleife angelegt, in die es deswegen nicht rein geht.

>                                                                
> +if [ "$(cat /tmp/fwcheck)" -lt "$NOW" ] ; then                                                                 
> +        rm -f /tmp/isupdate                                                                                    
> +        NEXTUPDATE=$(($(date +%s)+86400))                                                                      
> +        echo $NEXTUPDATE > /tmp/fwcheck                                                                        
> +        wget "${UPGRADE_PATH}/release.nfo" -P /tmp 
wenn wget den server nicht erreicht ist hier schluss. Da brauchst du ein
timeout.

cat /tmp/release.nfo unten liefert dann auch nen Fehler, wenn es die Datei nicht gibt.


>                                                             
> +        VERSION=$(cat /tmp/release.nfo|awk -F: '/VERSION:/ { print $2 }')                                      
> +        rm -f release.nfo                                          
Pfad: /tmp/release.nfo, kannste aber auch ganz weg lassen.
>                                             
> +        if [ "$VERSION" != "$FIRMWARE_VERSION" ]; then                                                                                                       
> +                echo 1 > /tmp/isupdate
>                                                                                                                        
> +        fi                                                                                                                                                   
> +fi 
> +
>  %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>  <html xmlns="http://www.w3.org/1999/xhtml">
>  <head>
> @@ -47,3 +63,12 @@ HOSTNAME=$(uci -q get 'system.@system[0].hostname')
>  	<div id="container">
>  		<div id="primarycontainer">
>  			<div id="primarycontent">
> +			<%       
> +			if [ "$(cat /tmp/isupdate)" -eq 1 ] ; then
> +			%>                
> +				<table style="width: 100%;">             
> +					<tr>
> +						<td><span style="font-size: 18pt; color:#FF0000">Es ist eine neue Firmware für deinen Freifunkrouter verfügbar</td>
> +					</tr>
> +				</table>
> +			<% fi %>
A. Schulze Feb. 14, 2017, 10:16 p.m.
Am 14.02.2017 um 18:24 schrieb Christian Dresel:
> + <td><span style="font-size: 18pt; color:#FF0000">Es ist eine neue Firmware für deinen Freifunkrouter verfügbar</td>

Christian,

wäre es möglich, dort auch gleich eine "Handlungsanweisung" unterzubringen?
 - schaue $dort nach, was zu tun ist
 - klicke $hier, um weitere Infos zu erhalten

<Kür>
Außerdem ist es immer hilfreicht, wenn konkrete Versionsnummern angegeben werden:
welche Version ist installiert vs. welche Version hätte das Update
</Kür>

Andreas