From e957e2c6101f2a0caadb02517b9fe960f8bb572f Mon Sep 17 00:00:00 2001 From: Leonard Excoffier <48970393+excoffierleonard@users.noreply.github.com> Date: Sat, 7 Sep 2024 17:33:21 -0400 Subject: [PATCH] feat: added checks and loads the cron job --- start.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 start.sh diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..62f28ad --- /dev/null +++ b/start.sh @@ -0,0 +1,21 @@ +#!/bin/bash +: ${WEBSITES:?"Environment variable WEBSITES is required but not set."} +: ${WEBHOOK_URL:?"Environment variable WEBHOOK_URL is required but not set."} +: ${DISCORD_ID:?"Environment variable DISCORD_ID is required but not set."} + +# Create a new temporary crontab file +temp_cron_file="/tmp/crontab_with_envs" + +echo "PATH=$PATH" > $temp_cron_file +echo "WEBSITES=$WEBSITES" >> $temp_cron_file +echo "WEBHOOK_URL=$WEBHOOK_URL" >> $temp_cron_file +echo "DISCORD_ID=$DISCORD_ID" >> $temp_cron_file + +# Append the cron configuration to the temp cron configuration file +cat $CRON_CONFIG >> $temp_cron_file + +# Load the new crontab file +crontab $temp_cron_file + +# Start cron +cron -f