1.2.2-6 with autotrigger enhancements

git-svn-id: file:///root/webif/svn/pkg/webif/trunk@2401 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2015-04-19 22:00:19 +00:00
parent c54dd07563
commit 677bc95882
6 changed files with 76 additions and 24 deletions

View File

@ -1,10 +1,10 @@
Package: webif
Priority: optional
Section: web
Version: 1.2.2-5
Version: 1.2.2-6
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.17),lighttpd(>=1.4.35-2),jim(>=0.76),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.0),hmt(>=2.0.3),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.2)
Depends: webif-channelicons(>=1.1.18),lighttpd(>=1.4.35-2),jim(>=0.76),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.0),hmt(>=2.0.3),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.3)
Suggests:
Description: An evolving web interface for the Humax.
Tags: http://hummy.tv/forum/threads/5866/

View File

@ -20,7 +20,7 @@ crontab=$PKG_ROOT/bin/crontab
if [ -x $crontab ]; then
$crontab -l | grep -v webif/lib/bin/auto > $tmpf
cat $tmpf - << EOM | $crontab -
*/10 * * * * /mod/webif/lib/bin/auto >/dev/null 2>&1
5,25,45 * * * * /mod/webif/lib/bin/auto >/dev/null 2>&1
EOM
fi
@ -54,6 +54,9 @@ fi
hook=/mod/boot/xinit.d/rt3070
[ -f $hook ] && rm -f $hook
# Remove legacy mongoose startup script
[ -f /mod/etc/init.d/Z01mongoose ] && rm -f /mod/etc/init.d/Z01mongoose
# Migrate record log to new name.
(
cd /mod/tmp

View File

@ -1,17 +1,25 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require lock
require system.class settings.class lock
set loglevel [[settings] autolog]
set file [lindex $argv 0]
set dir [file dirname $file]
set prefix "autotrigger\[[pid]\]"
if {$loglevel > 0} { system plog auto "$prefix: will run for $dir" }
# Wait up to 10 minutes for any existing auto process to finish...
if {![acquire_lock webif_auto 600]} {
if {![acquire_lock webif_auto 600 5]} {
puts "Cannot acquire exclusive lock, terminating."
system plog auto "$prefix: failed to get lock"
exit
}
release_lock webif_auto
if {$loglevel > 0} { system plog auto "$prefix: got lock" }
exec /mod/webif/lib/bin/auto -single $dir
exec /mod/webif/lib/bin/auto -prelocked -logprefix "$prefix: " -singledir $dir
if {$loglevel > 0} { system plog auto "$prefix: done" }

View File

@ -137,8 +137,6 @@ puts {
placeholder="Defaults to channel name"
class="text ui-widget-content ui-corner-all">
</td>
</tr><tr>
</td>
</tr>
</table>
</form>

View File

@ -10,29 +10,56 @@ set audiomp3 [$settings audiomp3]
set modules {decrypt dedup shrink mpg mp3 expire}
if {![acquire_lock webif_auto]} {
puts "Cannot acquire exclusive lock, terminating."
set logfile "/mod/tmp/auto.log"
set logfd "unset"
set logprefix ""
set prelocked 0
while {[llength $argv]} {
switch -- [lindex $argv 0] {
-d {
set loglevel 2
set logfd stdout
}
-prelocked {
set prelocked 1
}
-logprefix {
set argv [lrange $argv 1 end]
if {[llength $argv]} {
set logprefix [lindex $argv 0]
}
}
default {
# Unknown option, pass to rest of script.
break
}
}
set argv [lrange $argv 1 end]
}
if {!$prelocked && ![acquire_lock webif_auto 10 1]} {
if {$loglevel > 1} {
system plog auto "Could not acquire lock."
}
puts "Could acquire exclusive lock, terminating."
exit
}
set logfile "/mod/tmp/auto.log"
# Rotate log file if large enough.
if {[file exists $logfile] && [file size $logfile] > 2097152} {
file copy -force $logfile "/mod/tmp/auto_old.log"
file delete $logfile
}
if {[lindex $argv 0] eq "-d"} {
set argv [lrange $argv 1 end]
set loglevel 2
set logfd stdout
} else {
if {$logfd eq "unset"} {
set logfd [open "/mod/tmp/auto.log" "a+"]
}
proc log {msg {level 1}} {
if {$level > $::loglevel} return
puts $::logfd "[system logtimestamp] - $msg"
puts $::logfd "[system logtimestamp] - $::logprefix$msg"
flush $::logfd
}
@ -55,6 +82,8 @@ foreach mod $modules {
set "hook_pre$mod" {}
set "hook_post$mod" {}
set "hook_post${mod}scan" {}
set "hook_pre${mod}singledir" {}
set "hook_post${mod}singledir" {}
}
proc register {type fn {priority 50}} {
@ -72,10 +101,14 @@ proc runplugin {name {ts 0}} {
global $var
foreach p [lsort -index end -decreasing -integer [subst $$var]] {
lassign $p fn priority
log "Running $name plugin $fn (priority $priority)" 2
if {[catch {uplevel 1 $fn $ts} msg]} {
log "Running $name plugin $fn (priority $priority) \[$ts]" 2
if {[catch {uplevel 1 [list $fn $ts]} msg]} {
log "Plugin error: $msg" 0
foreach {proc file line} [info stacktrace] {
log " @ $file:$proc:$line" 0
}
}
log "Completed $name plugin $fn" 2
}
}
@ -308,7 +341,11 @@ proc do_decrypt {ts} {
set helper 0
} else {
log " $file - Not yet indexed, trying helper."
lassign [system dlnahelper [file normalize $file]] url
if {[catch {
lassign [system dlnahelper [file normalize $file]] url
} msg]} {
log " $file - $msg"
}
if {$url eq ""} {
log " $file - Can't use helper."
return
@ -706,7 +743,9 @@ proc scansingle {dirs} {
log "Encountered special directory."
break
}
runplugin "pre${arg}singledir" $dir
xscan $dir $arg $sup 0
runplugin "post${arg}singledir" $dir
log "$arg scan completed in [elapsed $st] seconds."
}
}
@ -717,12 +756,16 @@ file stat "$root/" rootstat
set rootdev $rootstat(dev)
log "Root device: $rootdev" 2
if {[lindex $argv 0] eq "-single"} {
if {[lindex $argv 0] eq "-singledir"} {
scansingle [lrange $argv 1 end]
} elseif {[llength $argv] > 0} {
set loglevel 2
foreach arg $argv {
set st [clock milliseconds]
if {$arg ni $modules} {
log "Unknown scan type: $arg"
continue
}
log "$arg scan starting."
set processed_files {}
runplugin "pre${arg}scan"

View File

@ -14,7 +14,7 @@ proc _lock_to_port {id} {
proc _lock_dummy {newsock addr port} { }
proc acquire_lock {id {timeout 0}} {
proc acquire_lock {id {timeout 0} {interval 0.2}} {
global _locks
set port [_lock_to_port $id]
@ -24,7 +24,7 @@ proc acquire_lock {id {timeout 0}} {
while {[catch {set socket [\
socket stream.server "127.0.0.1:$port"]} msg]} {
if {[clock seconds] > $timeout} { return 0 }
sleep 0.2
sleep $interval
}
set _locks($id) $socket