Skip to content

Commit

Permalink
Merge pull request #386 from Dashboy1998/Exit-on-bad-cron-expression
Browse files Browse the repository at this point in the history
Added exit on bad crontab
  • Loading branch information
thijsvanloef authored Feb 14, 2024
2 parents e04b34e + edb4a59 commit f23eaf6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,36 @@ else
/home/steam/server/compile-settings.sh
fi

printf "\e[0;32m%s\e[0m\n" "*****GENERATING CRONTAB*****"

rm -f "/home/steam/server/crontab"
if [ "${BACKUP_ENABLED,,}" = true ]; then
echo "BACKUP_ENABLED=${BACKUP_ENABLED,,}"
echo "Adding cronjob for auto backups"
echo "$BACKUP_CRON_EXPRESSION bash /usr/local/bin/backup" >> "/home/steam/server/crontab"
supercronic -quiet -test "/home/steam/server/crontab" || exit
fi

if [ "${AUTO_UPDATE_ENABLED,,}" = true ] && [ "${UPDATE_ON_BOOT}" = true ]; then
echo "AUTO_UPDATE_ENABLED=${AUTO_UPDATE_ENABLED,,}"
echo "Adding cronjob for auto updating"
echo "$AUTO_UPDATE_CRON_EXPRESSION bash /usr/local/bin/update" >> "/home/steam/server/crontab"
supercronic -quiet -test "/home/steam/server/crontab" || exit
fi

if [ "${AUTO_REBOOT_ENABLED,,}" = true ] && [ "${RCON_ENABLED,,}" = true ]; then
echo "AUTO_REBOOT_ENABLED=${AUTO_REBOOT_ENABLED,,}"
echo "Adding cronjob for auto rebooting"
echo "$AUTO_REBOOT_CRON_EXPRESSION bash /home/steam/server/auto_reboot.sh" >> "/home/steam/server/crontab"
supercronic -quiet -test "/home/steam/server/crontab" || exit
fi

if { [ "${AUTO_UPDATE_ENABLED,,}" = true ] && [ "${UPDATE_ON_BOOT,,}" = true ]; } || [ "${BACKUP_ENABLED,,}" = true ] || \
[ "${AUTO_REBOOT_ENABLED,,}" = true ]; then
supercronic "/home/steam/server/crontab" &
echo "Cronjobs started"
else
echo "No Cronjobs found"
fi

# Configure RCON settings
Expand Down

0 comments on commit f23eaf6

Please sign in to comment.