2011-09-02 19:50:10 +00:00
|
|
|
|
2012-01-13 21:23:03 +00:00
|
|
|
if {![exists -proc class]} { package require oo }
|
|
|
|
if {![exists -proc sqlite3.open]} { package require sqlite3 }
|
2011-09-02 19:50:10 +00:00
|
|
|
|
|
|
|
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-11-12 23:57:19 +00:00
|
|
|
proc {system modversion} {{short 0}} {
|
2011-09-14 19:59:56 +00:00
|
|
|
if {[catch {set fp [open /etc/modversion r]}]} {
|
2011-11-12 23:57:19 +00:00
|
|
|
set modver "102"
|
2011-09-14 19:59:56 +00:00
|
|
|
} else {
|
|
|
|
set modver [string trim [read $fp]]
|
|
|
|
close $fp
|
|
|
|
}
|
2011-11-12 23:57:19 +00:00
|
|
|
if {$short} { return $modver }
|
2011-09-14 19:59:56 +00:00
|
|
|
lassign [split $modver ""] a b c
|
|
|
|
return [format "%d.%d%d" $a $b $c]
|
|
|
|
}
|
|
|
|
|
2011-09-25 18:25:09 +00:00
|
|
|
proc {system pkgver} {{pkg webif}} {
|
|
|
|
return [lrange [split [exec opkg list-installed $pkg] " "] 2 end]
|
|
|
|
}
|
|
|
|
|
2011-11-28 15:24:38 +00:00
|
|
|
proc {system pkginst} {pkg} {
|
|
|
|
if {[exec opkg list-installed $pkg] ne ""} {
|
|
|
|
return 1 } else { return 0 }
|
|
|
|
}
|
|
|
|
|
2011-10-31 13:47:47 +00:00
|
|
|
proc {system mediaroot} {} {
|
|
|
|
switch [system model] {
|
|
|
|
HDR { return "/media/My Video" }
|
|
|
|
HD { return "/media/drive1/Video" }
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2012-01-10 19:51:45 +00:00
|
|
|
proc {system dustbin} {} {
|
2012-01-13 23:28:48 +00:00
|
|
|
set dustbin "_dustbin"
|
|
|
|
if {![catch {set fd [open "/mod/boot/dustbin.name" r]}]} {
|
|
|
|
set dustbin [lindex [split [read $fd] "\n"] 0]
|
|
|
|
$fd close
|
2012-01-10 19:51:45 +00:00
|
|
|
}
|
2012-01-13 23:28:48 +00:00
|
|
|
return "[system mediaroot]/$dustbin"
|
2012-01-10 19:51:45 +00:00
|
|
|
}
|
|
|
|
|
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} {} {
|
2011-09-26 20:31:17 +00:00
|
|
|
# Is humaxtv doing anything important?
|
2011-11-27 23:29:14 +00:00
|
|
|
if {[catch {set pid [exec /mod/bin/busybox/pgrep humaxtv]}]} {
|
|
|
|
return 0
|
|
|
|
}
|
2011-09-02 19:50:10 +00:00
|
|
|
set c 0
|
2011-09-26 20:31:17 +00:00
|
|
|
foreach line [split [exec /mod/bin/lsof -p $pid] "\n"] {
|
|
|
|
if {[string match {*Video*.ts} $line]} { incr c }
|
|
|
|
}
|
2011-09-02 19:50:10 +00:00
|
|
|
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]
|
|
|
|
}
|
|
|
|
|
2011-09-18 22:19:54 +00:00
|
|
|
proc {system padding} {} {
|
|
|
|
set start 0
|
|
|
|
set stop 0
|
2011-09-19 17:11:18 +00:00
|
|
|
if {[catch {set db [sqlite3.open /var/lib/humaxtv/setup.db]} msg]} {
|
|
|
|
return {0 0}
|
|
|
|
}
|
2011-09-18 22:19:54 +00:00
|
|
|
foreach l [$db query "
|
|
|
|
select itemName, itemValue
|
|
|
|
from TBL_MENUCONFIG
|
|
|
|
where itemName in ('START_PADDING_TIME', 'STOP_PADDING_TIME')
|
|
|
|
"] {
|
|
|
|
lassign $l x name x val
|
|
|
|
switch $name {
|
|
|
|
"START_PADDING_TIME" { set start $val }
|
|
|
|
"STOP_PADDING_TIME" { set stop $val }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$db close
|
|
|
|
return [list $start $stop]
|
|
|
|
}
|
|
|
|
|
2012-01-10 19:51:45 +00:00
|
|
|
proc {system mkdir_p} {dir} {
|
|
|
|
exec /mod/bin/busybox/mkdir -p $dir
|
|
|
|
}
|
|
|
|
|