From 733b1e4c50e5943de559778330061ed803070e1c Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 22 Feb 2018 16:22:17 +0100 Subject: Support more parameters from environment --- adei/configs/adei_manager.cron.sh | 74 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 adei/configs/adei_manager.cron.sh (limited to 'adei/configs/adei_manager.cron.sh') diff --git a/adei/configs/adei_manager.cron.sh b/adei/configs/adei_manager.cron.sh new file mode 100644 index 0000000..0ba77b5 --- /dev/null +++ b/adei/configs/adei_manager.cron.sh @@ -0,0 +1,74 @@ +#! /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_manager.cron.sh ]; then + setups/$setup/adei_manager.cron.sh + return + fi + + if [ -f setups/$setup/.cache_archives ]; then + /usr/bin/php system/cache.php -archives $args + fi + + if [ -f setups/$setup/.backup ]; then + /usr/bin/php system/backup.php $args + fi +} + +[ -f /adei/env ] && . /adei/env + +script=$( cd $(dirname "$0") && pwd )/$( basename "$0" ) +if [ -f /adei/sys/adei_manager.cron.sh -a "$script" != /adei/sys/adei_manager.cron.sh ]; then + /adei/sys/adei_manager.cron.sh + exit +fi + +( + cd /srv/www/htdocs/adei + + 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 + + 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_clean.php + + for pid in $pids; do + wait $pid + done +) -- cgit v1.2.3