replaced /etc/environment with /etc/cron-env.sh to work with cron
This commit is contained in:
@@ -1,15 +1,33 @@
|
||||
#!/bin/bash
|
||||
bun run ./src/app.ts --today
|
||||
|
||||
echo "ntfy_on=$ntfy_on" >> /etc/environment
|
||||
echo "ntfy_username=$ntfy_username" >> /etc/environment
|
||||
echo "ntfy_password=$ntfy_password" >> /etc/environment
|
||||
echo "ntfy_host=$ntfy_host" >> /etc/environment
|
||||
echo "ntfy_topic=$ntfy_topic" >> /etc/environment
|
||||
echo "dc_on=$dc_on" >> /etc/environment
|
||||
echo "dc_webhook=$dc_webhook" >> /etc/environment
|
||||
echo "dc_botname=$dc_botname" >> /etc/environment
|
||||
echo "dc_avatar_url=$dc_avatar_url" >> /etc/environment
|
||||
# Create or overwrite the cron env file
|
||||
cat /dev/null > /etc/cron-env.sh
|
||||
chmod 600 /etc/cron-env.sh
|
||||
chmod +x /etc/cron-env.sh
|
||||
# Write the Env Vars into a file for cron. happens during runtime of the container and not build.
|
||||
# List your environment variables here
|
||||
env_vars=(
|
||||
ntfy_on
|
||||
ntfy_username
|
||||
ntfy_password
|
||||
ntfy_host
|
||||
ntfy_topic
|
||||
dc_on
|
||||
dc_webhook
|
||||
dc_botname
|
||||
dc_avatar_url
|
||||
)
|
||||
|
||||
for var in "${env_vars[@]}"; do
|
||||
val="${!var}"
|
||||
if [ -n "$val" ]; then
|
||||
# Safely export the variable with proper quoting
|
||||
printf 'export %s=%q\n' "$var" "$val" >> /etc/cron-env.sh
|
||||
fi
|
||||
done
|
||||
|
||||
export PATH="/root/.bun/bin:$PATH"
|
||||
bun run /opt/app/src/app.ts --today
|
||||
|
||||
# Start cron in foreground
|
||||
exec cron -f
|
||||
Reference in New Issue
Block a user