forked from hummypkg/webif
create system class and use it. Expand rsv fetch to include ersvtype
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@344 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
df85584352
commit
b378ec1b9c
@ -1,7 +1,7 @@
|
|||||||
Package: webif
|
Package: webif
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: web
|
Section: web
|
||||||
Version: 0.6.6-1
|
Version: 0.6.7
|
||||||
Architecture: mipsel
|
Architecture: mipsel
|
||||||
Maintainer: af123@hummypkg.org.uk
|
Maintainer: af123@hummypkg.org.uk
|
||||||
Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4),jim-oo,jim-pack,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.3),hmt(>=1.0.6),ssmtp
|
Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4),jim-oo,jim-pack,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.3),hmt(>=1.0.6),ssmtp
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
package require cgi
|
package require cgi
|
||||||
source /mod/var/mongoose/lib/setup
|
source /mod/var/mongoose/lib/setup
|
||||||
require epg.class
|
require epg.class system.class
|
||||||
|
|
||||||
puts "Content-Type: text/html"
|
puts "Content-Type: text/html"
|
||||||
puts ""
|
puts ""
|
||||||
@ -76,7 +76,7 @@ if {$msg ne "" || [catch {[rsv new $args] insert} msg]} {
|
|||||||
puts "Error encountered while scheduling the recording: <i>$msg</i>"
|
puts "Error encountered while scheduling the recording: <i>$msg</i>"
|
||||||
} else {
|
} else {
|
||||||
puts "Successfully scheduled recording of <i>[$event get name]</i>"
|
puts "Successfully scheduled recording of <i>[$event get name]</i>"
|
||||||
close [open /tmp/.restartpending w]
|
system restartpending
|
||||||
}
|
}
|
||||||
|
|
||||||
epg cleanup
|
epg cleanup
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
package require cgi
|
package require cgi
|
||||||
source /mod/var/mongoose/lib/setup
|
source /mod/var/mongoose/lib/setup
|
||||||
require rsv.class
|
require rsv.class system.class
|
||||||
|
|
||||||
puts "Content-Type: text/html"
|
puts "Content-Type: text/html"
|
||||||
puts ""
|
puts ""
|
||||||
@ -11,8 +11,7 @@ cgi_input
|
|||||||
if {[cgi_get now] eq "yes"} {
|
if {[cgi_get now] eq "yes"} {
|
||||||
# - Busybox reboot does sync the disk but may still not be clean enough.
|
# - Busybox reboot does sync the disk but may still not be clean enough.
|
||||||
puts "Restarting."
|
puts "Restarting."
|
||||||
exec /etc/init.d/S90settop shut
|
system reboot
|
||||||
exec /sbin/reboot
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,27 +1,9 @@
|
|||||||
#!/mod/bin/jimsh
|
#!/mod/bin/jimsh
|
||||||
|
|
||||||
proc extract {line} {
|
source /mod/var/mongoose/lib/setup
|
||||||
regsub -all -- {[[:space:]]+} $line " " line
|
require system.class
|
||||||
set fields [split $line]
|
|
||||||
set ::size [lindex $fields 1]
|
|
||||||
set ::used [lindex $fields 2]
|
|
||||||
set ::perc [string trimright [lindex $fields 4] "%"]
|
|
||||||
}
|
|
||||||
|
|
||||||
set used 0
|
|
||||||
set size 0
|
|
||||||
set perc 0
|
|
||||||
|
|
||||||
foreach df [split [exec df -h 2>>/dev/null] "\n\r"] {
|
|
||||||
if {[string match *sd?2* $df]} {
|
|
||||||
extract $df
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if {[string match *media/drive? $df]} {
|
|
||||||
extract $df
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
lassign [system diskspace] size used perc
|
||||||
set file [format "%02d" [expr {$perc * 25 / 100 + 1}]]
|
set file [format "%02d" [expr {$perc * 25 / 100 + 1}]]
|
||||||
|
|
||||||
# The HD model only has the USB images which are blue. I prefer the green
|
# The HD model only has the USB images which are blue. I prefer the green
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
#!/mod/bin/jimsh
|
#!/mod/bin/jimsh
|
||||||
|
|
||||||
if {[catch {set fp [open /etc/model r]}]} {
|
source /mod/var/mongoose/lib/setup
|
||||||
set model {HD[R]}
|
require system.class
|
||||||
} else {
|
|
||||||
set model [string trim [read $fp]]
|
|
||||||
close $fp
|
|
||||||
}
|
|
||||||
|
|
||||||
if {[catch {set hostname [string trim [exec hostname]]}]} {
|
puts "Humax [system model] Fox T2 ([system hostname])"
|
||||||
set hostname "humax"
|
|
||||||
}
|
|
||||||
|
|
||||||
puts "Humax $model Fox T2 ($hostname)"
|
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#!/mod/bin/jimsh
|
#!/mod/bin/jimsh
|
||||||
|
|
||||||
|
source /mod/var/mongoose/lib/setup
|
||||||
|
require system.class
|
||||||
|
|
||||||
if {[file exists /tmp/.restartpending]} {
|
if {[file exists /tmp/.restartpending]} {
|
||||||
|
|
||||||
puts {
|
puts {
|
||||||
@ -12,12 +15,7 @@ puts {
|
|||||||
<font class=blood>
|
<font class=blood>
|
||||||
}
|
}
|
||||||
|
|
||||||
# Is humaxtv doing anything?
|
if {[system busy]} {
|
||||||
set pid [exec pgrep humaxtv]
|
|
||||||
set c 0
|
|
||||||
catch { set c [exec /mod/bin/lsof -p $pid | grep Video | fgrep .ts | wc -l] }
|
|
||||||
|
|
||||||
if {$c > 0} {
|
|
||||||
puts "Cannot restart whilst box is busy."
|
puts "Cannot restart whilst box is busy."
|
||||||
} else {
|
} else {
|
||||||
puts {
|
puts {
|
||||||
|
@ -240,18 +240,19 @@ proc {rsv entry} {{table TBL_RESERVATION} crid svc} {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
proc {rsv fetch} {{table TBL_RESERVATION} hsvc nsttime usevtid events} {
|
proc {rsv fetch} {{table TBL_RESERVATION} ersvtype hsvc nsttime usevtid events} {
|
||||||
set res [$::rsvdb query "
|
set res [$::rsvdb query "
|
||||||
select $table.*,
|
select $table.*,
|
||||||
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn
|
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn
|
||||||
from $table
|
from $table
|
||||||
left join channel.TBL_SVC
|
left join channel.TBL_SVC
|
||||||
on $table.hSvc = channel.TBL_SVC.hSvc
|
on $table.hSvc = channel.TBL_SVC.hSvc
|
||||||
where $table.hsvc = '%s'
|
where $table.ersvtype = '%s'
|
||||||
|
and $table.hsvc = '%s'
|
||||||
and $table.nsttime = '%s'
|
and $table.nsttime = '%s'
|
||||||
and $table.usevtid = '%s'
|
and $table.usevtid = '%s'
|
||||||
and $table.szEventToRecord = '%s'
|
and $table.szEventToRecord = '%s'
|
||||||
" $hsvc $nsttime $usevtid $events]
|
" $ersvtype $hsvc $nsttime $usevtid $events]
|
||||||
|
|
||||||
if {[llength $res] > 0} {
|
if {[llength $res] > 0} {
|
||||||
return [rsv new [lindex $res 0]]
|
return [rsv new [lindex $res 0]]
|
||||||
|
64
var/mongoose/lib/system.class
Normal file
64
var/mongoose/lib/system.class
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
foreach line [split [exec df -h $part 2>>/dev/null] "\n\r"] {
|
||||||
|
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?
|
||||||
|
set pid [exec pgrep humaxtv]
|
||||||
|
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]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user