2011-09-02 19:50:10 +00:00
|
|
|
|
|
|
|
if {![exists -proc class ]} { package require oo }
|
|
|
|
|
|
|
|
class system {}
|
|
|
|
|
|
|
|
proc {system model} {} {
|
|
|
|
if {[catch {set fp [open /etc/model r]}]} {
|
|
|
|
set model {HD[R]}
|
|
|
|
} else {
|
|
|
|
set model [string trim [read $fp]]
|
|
|
|
close $fp
|
|
|
|
}
|
|
|
|
return $model
|
|
|
|
}
|
|
|
|
|
|
|
|
proc {system hostname} {} {
|
|
|
|
if {[catch {set hostname [string trim [exec hostname]]}]} {
|
|
|
|
set hostname "humax"
|
|
|
|
}
|
|
|
|
return $hostname
|
|
|
|
}
|
|
|
|
|
2011-09-14 19:59:56 +00:00
|
|
|
proc {system modversion} {} {
|
|
|
|
if {[catch {set fp [open /etc/modversion r]}]} {
|
|
|
|
set modver "1.02"
|
|
|
|
} else {
|
|
|
|
set modver [string trim [read $fp]]
|
|
|
|
close $fp
|
|
|
|
}
|
|
|
|
lassign [split $modver ""] a b c
|
|
|
|
return [format "%d.%d%d" $a $b $c]
|
|
|
|
}
|
|
|
|
|
2011-09-02 19:50:10 +00:00
|
|
|
proc {system diskspace} {} {
|
|
|
|
switch [system model] {
|
|
|
|
HDR { set part /mnt/hd2 }
|
|
|
|
HD { set part /media/drive1 }
|
|
|
|
}
|
|
|
|
|
|
|
|
set size 0
|
|
|
|
set used 0
|
|
|
|
set perc 0
|
2011-09-05 22:23:29 +00:00
|
|
|
foreach line [split [exec /mod/bin/busybox/df -h $part 2>>/dev/null] "\n\r"] {
|
2011-09-02 19:50:10 +00:00
|
|
|
if {[string match "/*" $line]} {
|
|
|
|
regsub -all -- {[[:space:]]+} $line " " line
|
|
|
|
set fields [split $line]
|
|
|
|
set size [lindex $fields 1]
|
|
|
|
set used [lindex $fields 2]
|
|
|
|
set perc [string trimright [lindex $fields 4] "%"]
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return [list $size $used $perc]
|
|
|
|
}
|
|
|
|
|
|
|
|
proc {system busy} {} {
|
|
|
|
# Is humaxtv doing anything?
|
2011-09-04 00:18:07 +00:00
|
|
|
set pid [exec /mod/bin/busybox/pgrep humaxtv]
|
2011-09-02 19:50:10 +00:00
|
|
|
set c 0
|
|
|
|
catch { set c [exec /mod/bin/lsof -p $pid | grep Video | fgrep .ts | wc -l] }
|
|
|
|
|
|
|
|
if {$c > 0} { return 1 }
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
proc {system reboot} {} {
|
|
|
|
exec /etc/init.d/S90settop shut
|
|
|
|
exec /sbin/reboot
|
|
|
|
}
|
|
|
|
|
|
|
|
proc {system restartpending} {} {
|
|
|
|
close [open /tmp/.restartpending w]
|
|
|
|
}
|
|
|
|
|