aboutsummaryrefslogtreecommitdiff
path: root/scripts/entrypoint.sh
diff options
context:
space:
mode:
authorChristian Segundo2023-06-10 00:11:39 +0200
committerChristian Segundo2023-06-10 00:11:39 +0200
commitbe52bd17ea01d8c302e39ba444194de282dc4728 (patch)
treeb1d69842363bce20f3b3141b529b52877dfdbbd7 /scripts/entrypoint.sh
downloadtransmission-hacks-be52bd17ea01d8c302e39ba444194de282dc4728.tar.gz
First commit
Diffstat (limited to 'scripts/entrypoint.sh')
-rw-r--r--scripts/entrypoint.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh
new file mode 100644
index 0000000..4d89be5
--- /dev/null
+++ b/scripts/entrypoint.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+set -euo pipefail
+
+cat <<EOF >> /etc/cron.d/crontab
+PYTHON_PATH=/usr/local/bin/python3
+SCRIPT_PREFIX=/scripts
+TRANSMISSION_HOST=${TRANSMISSION_HOST:-localhost}
+TRANSMISSION_PORT=${TRANSMISSION_PORT:-9091}
+EOF
+
+i=0
+while true; do
+ key="DELETE_TAG_${i}_NAME"
+ val="DELETE_TAG_${i}_AGE"
+ if [ -z "${!key:-}" ]; then
+ break
+ fi
+ cat <<EOF >> /etc/cron.d/crontab
+DELETE_TAG_${i}=${!key}
+DELETE_AGE_${i}=${!val}
+EOF
+ i=$((i+1))
+done
+
+echo "${CRON_EXPRESSION:-* * * * *} /bin/bash /scripts/cron.sh >/proc/1/fd/1 2>/proc/1/fd/2" >> /etc/cron.d/crontab
+cat /etc/cron.d/crontab
+crontab /etc/cron.d/crontab
+cron -f -l "${CRON_LOG_LEVEL:-0}"