feat: added checks and loads the cron job

This commit is contained in:
Leonard Excoffier
2024-09-07 17:33:21 -04:00
parent 6ccdd73fe0
commit e957e2c610

21
start.sh Normal file
View File

@@ -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