Compare commits

...

5 Commits

4 changed files with 48 additions and 26 deletions

View File

@ -90,7 +90,7 @@ switch $action {
if {$mode eq "cut"} {
catch {file rename $path "$dir/$file"}
} else {
catch {puts [exec /mod/bin/busybox/cp -r \
catch {puts [exec cp -r \
$path $dir]}
}
} elseif {[string match {*.ts} $path]} {

View File

@ -9,13 +9,17 @@ httpheader "application/json"
set dir [cgi_get dir "/media/My Video"]
set dlen [string length "$dir/"]
proc du {args} {
if {[catch {exec du {*}$args}} dutxt]} {
set dutxt ""
}
return $dutxt
}
#9.4G /media/My Video/Archive
#1.4G /media/My Video/CSI_ Crime Scene Investigation
puts "{"
if {[catch {exec /mod/bin/busybox/du -h -l -d 1 "$dir/"} dutxt]} {
set dutxt ""
}
foreach line [split $dutxt "\n"] {
foreach line [split [du -h -l -d 1 "$dir/"] "\n"] {
lassign [split $line "\t"] size node
set node [string range $node $dlen end]
if {[string length $node]} {
@ -31,10 +35,7 @@ foreach file [readdir $dir] {
if {![string match "/*" $lk]} { set lk "$dir/$lk" }
if {![file isdirectory $lk]} continue
if {[catch {exec /mod/bin/busybox/du -h "$lk"} dutxt]} {
set dutxt ""
}
foreach line [split $dutxt "\n"] {
foreach line [split [du -h "$lk"] "\n"] {
set fields [split $line "\t"]
if {[lindex $fields 1] eq $lk} {
set node [file tail $file]
@ -44,11 +45,11 @@ foreach file [readdir $dir] {
}
}
if {[catch {exec /mod/bin/busybox/du -hs "$dir/"} dutxt]} {
set dutxt [du -hs "$dir/"]
if {$dutxt eq ""} {
set dutxt "N/A"
}
lassign [split $dutxt] total
puts "\"\": \"$total\""
puts "}"

View File

@ -29,7 +29,7 @@ set rsize 0
proc gen {dir ddir {depth 0} {expand 0}} {{i 0}} {
global root lroot rsize
if {[catch {set dsize [exec /mod/bin/busybox/du -s "$dir/"]} msg]} {
if {[catch {set dsize [exec du -s "$dir/"]} msg]} {
puts "Error, $dir, $msg"
return
}

View File

@ -3,19 +3,19 @@
#exec >>/tmp/reboot.log 2>&1
if [ "$1" = "-f" -a "$0" != "/tmp/fastreboot" ]; then
cp $0 /tmp/fastreboot
cp "$0" /tmp/fastreboot
chmod 755 /tmp/fastreboot
exec /tmp/fastreboot -f
exit 0
fi
model="`cat /etc/model`"
model=$(cat /etc/model)
feedback()
{
[ -x /mod/bin/hwctl ] && /mod/bin/hwctl 13 0 >> /dev/null 2>&1
[ "$model" = HDR ] && display "$1" || display "\$$2"
if [ "$model" = HDR ]; then display "$1"; else display "\$$2"; fi
}
readwakeup()
@ -23,7 +23,7 @@ readwakeup()
# Read the wakeup timer from the front panel
tries=10
while [ $tries -gt 0 ]; do
wakeup="`/mod/bin/hwctl d`"
wakeup=$(/mod/bin/hwctl d)
[ -n "$wakeup" ] && break
tries=$((tries - 1))
sleep 1
@ -37,7 +37,7 @@ setwakeup()
tries=10
while [ $tries -gt 0 ]; do
echo "Setting wakeup timer..."
/mod/bin/hwctl 5 1 ^`date +%s` >/dev/null
/mod/bin/hwctl 5 1 "^$(date +%s)" >/dev/null
tries=$((tries - 1))
if readwakeup | grep "00 00 00 00"; then
sleep 1
@ -50,7 +50,7 @@ setwakeup()
lbr=0
if [ -f /tmp/.lbr ]; then
lbr="`cat /tmp/.lbr`"
lbr=$(cat /tmp/.lbr)
#echo "LBR: $lbr"
else
# No last-boot-reason file, fall-back to reading timer directly.
@ -87,12 +87,28 @@ fi
feedback "Fast Reboot" "FRBT"
# Stop mod services
for f in `ls -1r /mod/etc/init.d/S??*`; do
[ -f "$f" -a -x "$f" ] || continue
# Don't stop the SSH server
echo $f | grep -q dropbear && continue
$f stop
done
ls -1r /mod/etc/init.d/S??* |
while read -r f; do
[ -f "$f" ] || continue
case $f in
*.sh)
# actually no such scripts
continue
(
trap - INT QUIT TSTP
set -- stop
# might not use $1 ?
. "$f"
)
;;
*)
# Don't stop the SSH server
echo "$f" | grep -q dropbear && continue
[ -x "$f" ] && "$f" stop
;;
esac
done
# Stop Humax App
/etc/init.d/S90settop shut
@ -107,11 +123,16 @@ killall udhcpc
# Unmount disks
/bin/sync
mount | grep '^/dev/sd' | awk '{print $1}' | xargs umount -l
mount | grep '^/dev/sd' |
{ lastdev=
while read -r dev _; do
[ "${lastdev:-}" = "$dev" ] && continue
umount -l "$dev"; lastdev=$dev
done; }
# Stop device
for f in /sys/block/sd?; do
echo 1 >> $f/device/delete
echo 1 >> "$f/device/delete"
done
feedback "START SYSTEM" "boot"