From 0dd9641e76065eba98af8469217508911ec34348 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Thu, 5 Jan 2017 22:58:05 +0000 Subject: [PATCH] move plugins, fix cron, add queue upgrade git-svn-id: file:///root/webif/svn/pkg/webif/trunk@3470 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/postinst | 7 +++++-- CONTROL/prerm | 3 ++- webif/lib/auto/NOTES | 2 +- webif/lib/auto/deq | 2 +- webif/lib/auto/{ => plugin}/decrypt/auto.hook | 0 webif/lib/auto/{ => plugin}/decrypt/queue.hook | 0 webif/lib/auto/{ => plugin}/dedup/auto.hook | 0 webif/lib/auto/{ => plugin}/expire/auto.hook | 0 webif/lib/auto/{ => plugin}/mp3/auto.hook | 0 webif/lib/auto/{ => plugin}/mp3/queue.hook | 0 webif/lib/auto/{ => plugin}/mpg/auto.hook | 0 webif/lib/auto/{ => plugin}/mpg/queue.hook | 0 webif/lib/auto/{ => plugin}/shrink/auto.hook | 0 webif/lib/auto/{ => plugin}/shrink/queue.hook | 0 webif/lib/auto/scan | 2 +- webif/lib/auto/upgrade | 11 +++++++++++ webif/lib/queue.class | 15 +++++++++++++++ 17 files changed, 36 insertions(+), 6 deletions(-) rename webif/lib/auto/{ => plugin}/decrypt/auto.hook (100%) rename webif/lib/auto/{ => plugin}/decrypt/queue.hook (100%) rename webif/lib/auto/{ => plugin}/dedup/auto.hook (100%) rename webif/lib/auto/{ => plugin}/expire/auto.hook (100%) rename webif/lib/auto/{ => plugin}/mp3/auto.hook (100%) rename webif/lib/auto/{ => plugin}/mp3/queue.hook (100%) rename webif/lib/auto/{ => plugin}/mpg/auto.hook (100%) rename webif/lib/auto/{ => plugin}/mpg/queue.hook (100%) rename webif/lib/auto/{ => plugin}/shrink/auto.hook (100%) rename webif/lib/auto/{ => plugin}/shrink/queue.hook (100%) create mode 100755 webif/lib/auto/upgrade diff --git a/CONTROL/postinst b/CONTROL/postinst index 6d92a5c..6a2be02 100755 --- a/CONTROL/postinst +++ b/CONTROL/postinst @@ -18,9 +18,11 @@ export tmpf=/tmp/cronf.$$ crontab=$PKG_ROOT/bin/crontab if [ -x $crontab ]; then - $crontab -l | grep -v webif/lib/bin/auto > $tmpf + $crontab -l | grep -v webif/lib/bin/auto \ + | grep -v webif/lib/auto > $tmpf cat $tmpf - << EOM | $crontab - -* * * * * /mod/webif/lib/bin/auto >/dev/null 2>&1 +* * * * * /mod/webif/lib/auto/scan >/dev/null 2>&1 +* * * * * /mod/webif/lib/auto/deq >/dev/null 2>&1 EOM fi @@ -47,6 +49,7 @@ $PKG_ROOT/etc/init.d/S02anacron start < /dev/null > /dev/null 2>&1 & #fi /mod/webif/lib/bin/diskattrs +/mod/webif/lib/auto/upgrade #/mod/webif/lib/bin/resetnew # Remove hook script placed by the legacy rt3070 package which does not work diff --git a/CONTROL/prerm b/CONTROL/prerm index ce2dc08..196da1d 100755 --- a/CONTROL/prerm +++ b/CONTROL/prerm @@ -4,7 +4,8 @@ export tmpf=/tmp/cronf.$$ crontab=$PKG_ROOT/bin/crontab if [ -x $crontab ]; then - $crontab -l | grep -v webif/lib/bin/auto > $tmpf + $crontab -l | grep -v webif/lib/bin/auto \ + | grep -v webif/lib/auto > $tmpf [ -s $tmpf ] && $crontab $tmpf || $crontab -r fi diff --git a/webif/lib/auto/NOTES b/webif/lib/auto/NOTES index 45a7de6..c714b4c 100644 --- a/webif/lib/auto/NOTES +++ b/webif/lib/auto/NOTES @@ -1,6 +1,6 @@ Everything is a plugin. Those bundled with the web interface are in -/mod/webif/lib/auto/ and others are in /mod/webif/plugin/ +/mod/webif/lib/auto/plugin/ and others are in /mod/webif/plugin/ ---------------------------------------------------------------------- Priorities (* - additional package) diff --git a/webif/lib/auto/deq b/webif/lib/auto/deq index c97bb7a..0120086 100755 --- a/webif/lib/auto/deq +++ b/webif/lib/auto/deq @@ -98,7 +98,7 @@ proc ::auto::register {plugin {priority 500}} { # Load plugins # Bundled -eval_plugins queue 1 "" /mod/webif/lib/auto +eval_plugins queue 1 "" /mod/webif/lib/auto/plugin # Third party diff --git a/webif/lib/auto/decrypt/auto.hook b/webif/lib/auto/plugin/decrypt/auto.hook similarity index 100% rename from webif/lib/auto/decrypt/auto.hook rename to webif/lib/auto/plugin/decrypt/auto.hook diff --git a/webif/lib/auto/decrypt/queue.hook b/webif/lib/auto/plugin/decrypt/queue.hook similarity index 100% rename from webif/lib/auto/decrypt/queue.hook rename to webif/lib/auto/plugin/decrypt/queue.hook diff --git a/webif/lib/auto/dedup/auto.hook b/webif/lib/auto/plugin/dedup/auto.hook similarity index 100% rename from webif/lib/auto/dedup/auto.hook rename to webif/lib/auto/plugin/dedup/auto.hook diff --git a/webif/lib/auto/expire/auto.hook b/webif/lib/auto/plugin/expire/auto.hook similarity index 100% rename from webif/lib/auto/expire/auto.hook rename to webif/lib/auto/plugin/expire/auto.hook diff --git a/webif/lib/auto/mp3/auto.hook b/webif/lib/auto/plugin/mp3/auto.hook similarity index 100% rename from webif/lib/auto/mp3/auto.hook rename to webif/lib/auto/plugin/mp3/auto.hook diff --git a/webif/lib/auto/mp3/queue.hook b/webif/lib/auto/plugin/mp3/queue.hook similarity index 100% rename from webif/lib/auto/mp3/queue.hook rename to webif/lib/auto/plugin/mp3/queue.hook diff --git a/webif/lib/auto/mpg/auto.hook b/webif/lib/auto/plugin/mpg/auto.hook similarity index 100% rename from webif/lib/auto/mpg/auto.hook rename to webif/lib/auto/plugin/mpg/auto.hook diff --git a/webif/lib/auto/mpg/queue.hook b/webif/lib/auto/plugin/mpg/queue.hook similarity index 100% rename from webif/lib/auto/mpg/queue.hook rename to webif/lib/auto/plugin/mpg/queue.hook diff --git a/webif/lib/auto/shrink/auto.hook b/webif/lib/auto/plugin/shrink/auto.hook similarity index 100% rename from webif/lib/auto/shrink/auto.hook rename to webif/lib/auto/plugin/shrink/auto.hook diff --git a/webif/lib/auto/shrink/queue.hook b/webif/lib/auto/plugin/shrink/queue.hook similarity index 100% rename from webif/lib/auto/shrink/queue.hook rename to webif/lib/auto/plugin/shrink/queue.hook diff --git a/webif/lib/auto/scan b/webif/lib/auto/scan index 89463b2..35719f5 100755 --- a/webif/lib/auto/scan +++ b/webif/lib/auto/scan @@ -273,7 +273,7 @@ proc register {type fn {priority 50}} { # Load plugins # Bundled -eval_plugins auto 1 "" /mod/webif/lib/auto +eval_plugins auto 1 "" /mod/webif/lib/auto/plugin # Third party diff --git a/webif/lib/auto/upgrade b/webif/lib/auto/upgrade new file mode 100755 index 0000000..d310b06 --- /dev/null +++ b/webif/lib/auto/upgrade @@ -0,0 +1,11 @@ +#!/mod/bin/jimsh + +source /mod/webif/lib/setup +require queue.class + +if {[queue version] == 1} { + queue dbhandle -close + file delete /mod/etc/queue.db + queue dbhandle +} + diff --git a/webif/lib/queue.class b/webif/lib/queue.class index 8829985..89e9ebe 100644 --- a/webif/lib/queue.class +++ b/webif/lib/queue.class @@ -219,6 +219,21 @@ proc {queue size} {} { return [llength [queue runcandidates]] } +proc {queue version} {} { + set db [queue dbhandle] + + set version 1 + catch { + foreach row [$db query { + select val from config + where var = 'version' + }] { + lassign $row x version + } + } + return $version +} + queue method update {_status {_log ""} {_retries 0} {_runtime 0}} { set db [queue dbhandle] $db query {