summaryrefslogtreecommitdiffstats
path: root/adei/configs/adei.cron.sh
diff options
context:
space:
mode:
Diffstat (limited to 'adei/configs/adei.cron.sh')
-rw-r--r--adei/configs/adei.cron.sh81
1 files changed, 81 insertions, 0 deletions
diff --git a/adei/configs/adei.cron.sh b/adei/configs/adei.cron.sh
new file mode 100644
index 0000000..eccb4cb
--- /dev/null
+++ b/adei/configs/adei.cron.sh
@@ -0,0 +1,81 @@
+#! /bin/bash
+
+function process_setup {
+ setup="$1"
+ parallel="$2"
+
+ local args="-parallel $parallel"
+ if [ -n "$setup" ]; then
+ args="$args -setup $setup"
+ else
+ setup=$(php -r 'require "adei.php"; echo $ADEI_SETUP;')
+ fi
+
+ if [ ! -d "setups/$setup" ]; then
+ echo "$setup is not existing"
+ return
+ fi
+
+ if [ -f setups/$setup/adei.cron.sh ]; then
+ setups/$setup/adei.cron.sh
+ return
+ fi
+
+ /usr/bin/php system/cache.php $args
+}
+
+[ -f /adei/env ] && . /adei/env
+
+script=$( cd $(dirname "$0") && pwd )/$( basename "$0" )
+if [ -f /adei/sys/adei.cron.sh -a "$script" != /adei/sys/adei.cron.sh ]; then
+ /adei/sys/adei.cron.sh
+ exit
+fi
+
+(
+ cd /srv/www/htdocs/adei
+
+# Link extra setups from docker installation
+ if [ -d /adei/cfg ]; then
+ for cfg in /adei/cfg/*/config.php; do
+ [ -f "$cfg" ] || break
+ path=$(dirname $cfg)
+ setup=$(basename $path)
+ if [[ ! -a "setups/$setup" ]]; then
+ ln -s $path setups/$setup
+ fi
+ done
+ fi
+
+# Find out if we need to process multiple setups
+ if [ -n "$ADEI_SETUP" -o -n "$ADEI_ENABLED_SETUPS" ]; then
+ if [ "$ADEI_SETUP" = "all" ]; then
+ list=$(echo "$ADEI_ENABLED_SETUPS" | xargs -n 1 | sort -u)
+ else
+ list=$(echo "$ADEI_SETUP $ADEI_ENABLED_SETUPS" | xargs -n 1 | sort -u)
+ fi
+ else
+ for name in setups/*; do
+ if [ -f $name/.cache ]; then
+ list="$list $(basename $name)"
+ fi
+ done
+ fi
+
+# Run processing for each requested setup
+ if [ -n "$list" ]; then
+ for setup in $list; do
+ process_setup "$setup" "$ADEI_PARALLEL" &
+ pids="$pids $!"
+ done
+ else
+ process_setup "" "$ADEI_PARALLEL" &
+ pids="$!"
+ fi
+
+ /usr/bin/php system/downloads_check.php
+
+ for pid in $pids; do
+ wait $pid
+ done
+)