2015-04-10 22:01:51 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
2015-05-19 22:38:18 +00:00
|
|
|
if {[lindex $argv 0] ne "-stop"} exit
|
|
|
|
|
2015-04-14 00:09:47 +00:00
|
|
|
source /mod/webif/lib/setup
|
2015-04-19 22:00:19 +00:00
|
|
|
require system.class settings.class lock
|
|
|
|
|
|
|
|
set loglevel [[settings] autolog]
|
2015-04-10 22:01:51 +00:00
|
|
|
|
2015-05-19 22:38:18 +00:00
|
|
|
set file [lindex $argv 1]
|
2015-04-10 22:01:51 +00:00
|
|
|
set dir [file dirname $file]
|
|
|
|
|
2015-04-19 22:00:19 +00:00
|
|
|
set prefix "autotrigger\[[pid]\]"
|
2015-04-23 19:45:00 +00:00
|
|
|
if {$loglevel > 0} {
|
|
|
|
system plog auto "$prefix: $file"
|
|
|
|
system plog auto "$prefix: will run for $dir"
|
|
|
|
}
|
2015-04-19 22:00:19 +00:00
|
|
|
|
2015-04-14 00:09:47 +00:00
|
|
|
# Wait up to 10 minutes for any existing auto process to finish...
|
2017-01-05 22:36:00 +00:00
|
|
|
if {![acquire_lock webif_autoscan 600 5]} {
|
2015-04-14 00:09:47 +00:00
|
|
|
puts "Cannot acquire exclusive lock, terminating."
|
2015-04-19 22:00:19 +00:00
|
|
|
system plog auto "$prefix: failed to get lock"
|
2015-04-14 00:09:47 +00:00
|
|
|
exit
|
|
|
|
}
|
2015-04-19 22:00:19 +00:00
|
|
|
if {$loglevel > 0} { system plog auto "$prefix: got lock" }
|
|
|
|
|
2017-01-06 20:28:13 +00:00
|
|
|
exec /mod/webif/lib/auto/scan -f -prelocked -logprefix "$prefix: " \
|
|
|
|
-singledir $dir
|
2015-04-14 00:09:47 +00:00
|
|
|
|
2015-04-19 22:00:19 +00:00
|
|
|
if {$loglevel > 0} { system plog auto "$prefix: done" }
|
2015-04-10 22:01:51 +00:00
|
|
|
|