implemented cron mode
This commit is contained in:
14
init.sh
14
init.sh
@@ -148,6 +148,20 @@ if [[ $RUN_SHELL == true ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If cron mode, run cron tasks then exit
|
||||
if [[ $CRON_MODE == true ]]; then
|
||||
for mod in $MODULE_LIST; do
|
||||
if [[ $(function_exists cron_$mod) ]]; then
|
||||
prnt I "Running cron task for module $mod ..."
|
||||
cron_$mod
|
||||
else
|
||||
prnt I "No cron task for module $mod."
|
||||
fi
|
||||
done
|
||||
prnt I "All cron executed successfully !"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run prechecks
|
||||
if [[ JUMP != true ]]; then
|
||||
tmpfile=$(mktemp /tmp/init-XXXXXX)
|
||||
|
||||
@@ -76,7 +76,10 @@ read_commandline()
|
||||
export RUN_SHELL=true
|
||||
;;
|
||||
"--chroot")
|
||||
local want_chroot
|
||||
local want_chroot=true
|
||||
;;
|
||||
"--cron")
|
||||
export CRON_MODE=true
|
||||
;;
|
||||
*)
|
||||
if [[ $want_module == true ]]; then
|
||||
@@ -273,13 +276,20 @@ process_commandline_and_vars()
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $CRON_MODE == true ]]; then
|
||||
if [[ $CHECK_ONLY == true || $JUMP == true ]]; then
|
||||
prnt E "Des paramètres sont incompatibles avec le mode cron."
|
||||
die 15 --force
|
||||
fi
|
||||
fi
|
||||
|
||||
# Configure module list
|
||||
if [[ -n $MANUAL_MODULE_LIST ]]; then
|
||||
prnt W "Une liste de modules manuelle sera utilisé."
|
||||
export MODULE_LIST=$(echo $MANUAL_MODULE_LIST | sed "s/,/ /g")
|
||||
fi
|
||||
|
||||
# Check for module list existance en basic syntax
|
||||
# Check for module list existance and basic syntax
|
||||
if [[ -n $MODULE_LIST ]]; then
|
||||
if [[ $(echo $MODULE_LIST | grep '-') ]]; then
|
||||
prnt E "Le tiret est interdit dans les noms de module."
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# * PROXYAPTPORT: Working port for APT proxy
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_upgrade_dist="0.1.3"
|
||||
export VER_upgrade_dist="0.2.0"
|
||||
|
||||
# As aptitude might fail if clock is too far from real time, we need to depend
|
||||
# on ntp
|
||||
@@ -70,6 +70,12 @@ precheck_upgrade_dist()
|
||||
fi
|
||||
}
|
||||
|
||||
cron_upgrade_dist()
|
||||
{
|
||||
pkgupdt
|
||||
pkgupgd
|
||||
}
|
||||
|
||||
|
||||
export -f upgrade_dist
|
||||
export -f precheck_upgrade_dist
|
||||
|
||||
Reference in New Issue
Block a user