From 0de011e28d7906ab1f8de8e1b2094ce00016bf12 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Mon, 23 May 2016 20:41:47 +0000 Subject: [PATCH] set wakeup timer when rebooting git-svn-id: file:///root/webif/svn/pkg/webif/trunk@2960 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 4 +- webif/html/browse/clipboard.jim | 3 +- webif/lib/bin/reboot | 107 +++++++++++++++++++++++++++++++- webif/lib/system.class | 8 ++- 4 files changed, 115 insertions(+), 7 deletions(-) diff --git a/CONTROL/control b/CONTROL/control index 0c3b785..8ec42ef 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,10 +1,10 @@ Package: webif Priority: optional Section: web -Version: 1.3.0-5 +Version: 1.3.0-6 Architecture: mipsel Maintainer: af123@hpkg.tv -Depends: tcpfix,webif-channelicons(>=1.1.23),lighttpd(>=1.4.39-1),jim(>=0.76-2),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.3),hmt(>=2.0.9),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.8),webif-charts(>=1.2-1),stripts(>=1.2.5-3),tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7) +Depends: tcpfix,webif-channelicons(>=1.1.23),lighttpd(>=1.4.39-1),jim(>=0.76-2),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.3),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.9),webif-charts(>=1.2-1),stripts(>=1.2.5-3),tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl Suggests: Description: An evolving web interface for the Humax. Tags: http://hummy.tv/forum/threads/7116/ diff --git a/webif/html/browse/clipboard.jim b/webif/html/browse/clipboard.jim index 5c6f9ac..40b6ea1 100755 --- a/webif/html/browse/clipboard.jim +++ b/webif/html/browse/clipboard.jim @@ -11,6 +11,7 @@ cgi_input 1 set cb [[clipboard new {path "/tmp/webif-browse.cb"}] load] set action [cgi_get act list] +set imgpath "/lib/jquery.plugin/contextMenu/images" switch $action { list { @@ -27,7 +28,7 @@ switch $action { set path [$file get path] set xpath [cgi_quote_html $path] puts "" - puts "" + puts "" set dfile [file tail $path] if {[string length $dfile] > 25} { set dfile "[string range $dfile 0 22]..." diff --git a/webif/lib/bin/reboot b/webif/lib/bin/reboot index f65e808..3ebcc6a 100755 --- a/webif/lib/bin/reboot +++ b/webif/lib/bin/reboot @@ -1,8 +1,111 @@ #!/bin/sh +#exec >>/tmp/reboot.log 2>&1 + +if [ "$1" = "-f" -a "$0" != "/tmp/fastreboot" ]; then + cp $0 /tmp/fastreboot + chmod 755 /tmp/fastreboot + exec /tmp/fastreboot -f + + exit 0 +fi + +readwakeup() +{ + # Read the wakeup timer from the front panel + tries=10 + while [ $tries -gt 0 ]; do + wakeup="`/mod/bin/hwctl d`" + [ -n "$wakeup" ] && break + tries=$((tries - 1)) + sleep 1 + done + + echo "Wakeup: $wakeup" +} + +setwakeup() +{ + tries=10 + while [ $tries -gt 0 ]; do + echo "Setting wakeup timer..." + /mod/bin/hwctl 5 1 ^`date +%s` >/dev/null + tries=$((tries - 1)) + if readwakeup | grep "00 00 00 00"; then + sleep 1 + continue + fi + echo "Success" + break + done +} + +lbr=0 +if [ -f /tmp/.lbr ]; then + lbr="`cat /tmp/.lbr`" + echo "LBR: $lbr" +else + # No last-boot-reason file, fall-back to reading timer directly. + echo "No .lbr, falling back to timer..." + if readwakeup | grep "00 00 00 00"; then + echo "Setting LBR=3" + lbr=3 + fi +fi + +if [ $lbr -eq 3 ]; then + # Last boot was for scheduled recording. Need to set a wakeup + # flag in the Micom or the reboot will result in the Humax + # software just powering down (it presumably think that there has + # been a power failure). + readwakeup # For interest + setwakeup + readwakeup +fi + +# Normal reboot. + +if [ "$1" != "-f" ]; then + /etc/init.d/S90settop shut + /mod/bin/sync + /sbin/reboot + exit 0 +fi + +###################################################################### +# Fast reboot, thanks to work by prpr + +model="`cat /etc/model`" + +# Stop mod services +for f in /mod/etc/init.d/S??*; do + [ -f "$f" ] || continue + $f stop +done + +# Stop Humax App /etc/init.d/S90settop shut -/mod/bin/sync -/sbin/reboot + +# Kill DHCP daemon +killall udhcpc + +# Stop any processes still using the disk +#sleep 1 +#[ "$model" = "HDR" ] && part=/mnt/hd2 || part=/media/drive1 +#lsof -t $part | xargs kill -9 + +# Unmount disks +mount | grep '^/dev/sd' | awk '{print $1}' | xargs umount -l + +# Stop device +for f in /sys/block/sd?; do + echo 1 >> $f/device/delete +done + +# Restart xinit modules +/etc/init.d/S80xinit start +# Restart Humax app +/etc/init.d/S90settop resume exit 0 diff --git a/webif/lib/system.class b/webif/lib/system.class index 383f2ef..4482582 100644 --- a/webif/lib/system.class +++ b/webif/lib/system.class @@ -453,8 +453,12 @@ proc {system dirinuse} {dir} { return $files } -proc {system reboot} {} { - exec /mod/webif/lib/bin/reboot +proc {system reboot} {{fast 0}} { + if {$fast} { + exec /mod/webif/lib/bin/reboot -f + } else { + exec /mod/webif/lib/bin/reboot + } } proc {system restartpending} {{mode 1}} {