AI Implementation feature(1082): Project Scaffold and Docker Packaging (#1)
This commit was merged in pull request #1.
This commit is contained in:
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
export DEBIAN_FRONTEND="${DEBIAN_FRONTEND:-noninteractive}"
|
||||
export TZ="${TZ:-Europe/Berlin}"
|
||||
|
||||
if [ -f /usr/share/zoneinfo/"${TZ}" ] && [ ! -f /etc/localtime ]; then
|
||||
ln -snf /usr/share/zoneinfo/"${TZ}" /etc/localtime || true
|
||||
fi
|
||||
|
||||
required_vars=(
|
||||
MASTODON_BASE_URL
|
||||
MASTODON_ACCESS_TOKEN
|
||||
SITE_URL
|
||||
HASHTAGS
|
||||
RUN_AT
|
||||
)
|
||||
|
||||
missing=()
|
||||
for var in "${required_vars[@]}"; do
|
||||
if [ -z "${!var:-}" ]; then
|
||||
missing+=("${var}")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${#missing[@]}" -gt 0 ]; then
|
||||
echo "ERROR: missing required environment variable(s): ${missing[*]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run_at="${RUN_AT}"
|
||||
if ! [[ "${run_at}" =~ ^([01][0-9]|2[0-3]):[0-5][0-9]$ ]]; then
|
||||
echo "ERROR: RUN_AT='${run_at}' must be in HH:MM (24-hour) format" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
hour="${run_at%%:*}"
|
||||
minute="${run_at##*:}"
|
||||
|
||||
tmp_cron="$(mktemp)"
|
||||
trap 'rm -f "${tmp_cron}"' EXIT
|
||||
|
||||
{
|
||||
echo "SHELL=/bin/bash"
|
||||
echo "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
echo "TZ=${TZ}"
|
||||
echo "${minute} ${hour} * * * cd /app && /usr/local/bin/python -m tenbackward >> /app/data/cron.log 2>&1"
|
||||
} > "${tmp_cron}"
|
||||
|
||||
install -m 0644 -o root -g root "${tmp_cron}" /etc/cron.d/tenbackward
|
||||
|
||||
/app/crontab/install-cron.sh /etc/cron.d/tenbackward
|
||||
|
||||
echo "tenbackward: starting cron (RUN_AT=${run_at}, TZ=${TZ})"
|
||||
exec cron -f
|
||||
Reference in New Issue
Block a user