diff --git a/CONTROL/control b/CONTROL/control index 4e9d6b52..22037105 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 0.6.6-1 +Version: 0.6.7 Architecture: mipsel 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 diff --git a/var/mongoose/cgi-bin/epg_schedule.jim b/var/mongoose/cgi-bin/epg_schedule.jim index 2f1e67b1..e6b986f1 100755 --- a/var/mongoose/cgi-bin/epg_schedule.jim +++ b/var/mongoose/cgi-bin/epg_schedule.jim @@ -2,7 +2,7 @@ package require cgi source /mod/var/mongoose/lib/setup -require epg.class +require epg.class system.class puts "Content-Type: text/html" puts "" @@ -76,7 +76,7 @@ if {$msg ne "" || [catch {[rsv new $args] insert} msg]} { puts "Error encountered while scheduling the recording: $msg" } else { puts "Successfully scheduled recording of [$event get name]" - close [open /tmp/.restartpending w] + system restartpending } epg cleanup diff --git a/var/mongoose/cgi-bin/restart.jim b/var/mongoose/cgi-bin/restart.jim index 4b0748ba..67d456f7 100755 --- a/var/mongoose/cgi-bin/restart.jim +++ b/var/mongoose/cgi-bin/restart.jim @@ -2,7 +2,7 @@ package require cgi source /mod/var/mongoose/lib/setup -require rsv.class +require rsv.class system.class puts "Content-Type: text/html" puts "" @@ -11,8 +11,7 @@ cgi_input if {[cgi_get now] eq "yes"} { # - Busybox reboot does sync the disk but may still not be clean enough. puts "Restarting." - exec /etc/init.d/S90settop shut - exec /sbin/reboot + system reboot exit } diff --git a/var/mongoose/include/diskspace.jim b/var/mongoose/include/diskspace.jim index c511943a..fc90df05 100755 --- a/var/mongoose/include/diskspace.jim +++ b/var/mongoose/include/diskspace.jim @@ -1,27 +1,9 @@ #!/mod/bin/jimsh -proc extract {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] "%"] -} - -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 - } -} +source /mod/var/mongoose/lib/setup +require system.class +lassign [system diskspace] size used perc set file [format "%02d" [expr {$perc * 25 / 100 + 1}]] # The HD model only has the USB images which are blue. I prefer the green diff --git a/var/mongoose/include/model.jim b/var/mongoose/include/model.jim index c51f00cf..8a64159a 100755 --- a/var/mongoose/include/model.jim +++ b/var/mongoose/include/model.jim @@ -1,15 +1,7 @@ #!/mod/bin/jimsh -if {[catch {set fp [open /etc/model r]}]} { - set model {HD[R]} -} else { - set model [string trim [read $fp]] - close $fp -} +source /mod/var/mongoose/lib/setup +require system.class -if {[catch {set hostname [string trim [exec hostname]]}]} { - set hostname "humax" -} - -puts "Humax $model Fox T2 ($hostname)" +puts "Humax [system model] Fox T2 ([system hostname])" diff --git a/var/mongoose/include/restart.jim b/var/mongoose/include/restart.jim index c4efc46c..9b9c47ff 100755 --- a/var/mongoose/include/restart.jim +++ b/var/mongoose/include/restart.jim @@ -1,5 +1,8 @@ #!/mod/bin/jimsh +source /mod/var/mongoose/lib/setup +require system.class + if {[file exists /tmp/.restartpending]} { puts { @@ -12,12 +15,7 @@ puts { } -# 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} { +if {[system busy]} { puts "Cannot restart whilst box is busy." } else { puts { diff --git a/var/mongoose/lib/rsv.class b/var/mongoose/lib/rsv.class index ad4ed956..4678fe36 100755 --- a/var/mongoose/lib/rsv.class +++ b/var/mongoose/lib/rsv.class @@ -240,18 +240,19 @@ proc {rsv entry} {{table TBL_RESERVATION} crid svc} { 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 " select $table.*, channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn from $table left join channel.TBL_SVC 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.usevtid = '%s' and $table.szEventToRecord = '%s' - " $hsvc $nsttime $usevtid $events] + " $ersvtype $hsvc $nsttime $usevtid $events] if {[llength $res] > 0} { return [rsv new [lindex $res 0]] diff --git a/var/mongoose/lib/system.class b/var/mongoose/lib/system.class new file mode 100644 index 00000000..e0d5bf6d --- /dev/null +++ b/var/mongoose/lib/system.class @@ -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] +} +