ソースを参照

option to fw reset setting when upgrading

Danja Vasiliev 9 年 前
コミット
b3cc7fd1b1

+ 11 - 4
openwrt/common/opt/lib/cgi/admin2.cgi

@@ -93,6 +93,7 @@ runSuid() {
 }
 
 getQueryFile() {
+  setQueryVars
   local _UPLD="${HASERL_fwupload_path##*/}"
   logThis "'multipart': decoding stream"
   mv "$_TMP/$_UPLD" "$_TMP/fwupload.bin" 2>/dev/null || _ERR=$?
@@ -322,13 +323,16 @@ showMesg() {
 }
 
 updateFw() {
-  logThis "updating fw"
+  _FWRESET=$POST_fwreset
   _FWFILE="${_TMP}/fwupload.bin"
   _OUT="$(/sbin/sysupgrade -T $_FWFILE 2>&1)"
   _ERR=$?
+  logThis $_ERR
   [[ $_ERR -gt 0 ]] && showMesg "This is not a firmware!" 10 "$_OUT -"
+  logThis 'updating fw'
+  [[ $_FWRESET == 'on' ]] && logThis 'fw reset requested'
   ## using dtach to prevent sysupgrade getting killed
-  runSuid "dtach -n -zE $_SCRIPTS/fw-upgrade.sh $_FWFILE"
+  runSuid "dtach -n -zE $_SCRIPTS/fw-upgrade.sh $_FWFILE $_FWRESET"
   showMesg 'Firmware upgrade is in progress..' '120' 'Device needs to reboot -'
 }
 
@@ -586,7 +590,6 @@ wanuptime=${wan[4]}
 wanssid=$(doUci get wanssid)
 wankey=$(doUci get wankey)
 
-logThis $wanifname
 %>
 
 <body>
@@ -746,7 +749,11 @@ logThis $wanifname
     <input id='uploadfile' placeholder='Select a file..' class='elem' disabled='disabled'>
     <input id='uploadbtn' class='elem' name='fwupload' type='file'>
   </div>
-    <input type='submit' value='Upload' data-wait='Uploading, do NOT interrupt!'>
+  <div style='display:inline-block;'>
+    <input type='checkbox' name='fwreset' id='fw-resetbox' />
+    <label for='fw-resetbox'>Reset all settings</label>
+  </div>
+  <input type='submit' value='Upload' data-wait='Uploading, do NOT interrupt!'>
   </form>
   <span class='help'>help</span>
 </section>

+ 10 - 0
openwrt/common/opt/lib/resources/admin/admin.css

@@ -58,6 +58,16 @@ input[type='submit'] {
   cursor: pointer;
 }
 
+input[type='checkbox'] {
+  width: 26px;
+  height: 30px;
+  display: inline-block ! important;
+}
+
+label {
+  vertical-align: super;
+}
+
 input[type='button'],
 input[type='submit'],
 input[type='reset'],

+ 6 - 2
openwrt/common/opt/lib/scripts/fw-upgrade.sh

@@ -1,7 +1,11 @@
-#!/bin/sh
+#!/bin/bash
+
+RE=$2
 
 sleep 2
 
-sysupgrade -q $1 ##> /tmp/fw-upgrade.log
+[[ $RE == 'on' ]] && RE='-n' || RE=''
+
+sysupgrade $RE -q $1 ##> /tmp/fw-upgrade.log
 
 exit 0