aboutsummaryrefslogtreecommitdiff
path: root/src/entrypoint.sh
diff options
context:
space:
mode:
authorChristian Segundo2024-07-23 21:43:05 +0200
committerChristian Segundo2024-07-23 21:43:05 +0200
commit362af4e16d7cdfa1512a6f2f154f055907b4d900 (patch)
treef0e8817df1cad49bd466c60016cdd8b70913690c /src/entrypoint.sh
parent076b6aefd5b17cccc34cc403b7b4f2ba4f093a57 (diff)
downloadtransmission-hacks-362af4e16d7cdfa1512a6f2f154f055907b4d900.tar.gz
add ci
Diffstat (limited to 'src/entrypoint.sh')
-rw-r--r--src/entrypoint.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/entrypoint.sh b/src/entrypoint.sh
new file mode 100644
index 0000000..925afa1
--- /dev/null
+++ b/src/entrypoint.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -euo pipefail
+
+cat <<EOF >>/etc/cron.d/crontab
+PYTHON_PATH=/usr/local/bin/python3
+SCRIPT_PREFIX=/scripts
+SCRIPT_TIMEOUT=${SCRIPT_TIMEOUT:-300}
+TRANSMISSION_HOST=${TRANSMISSION_HOST:-localhost}
+TRANSMISSION_PORT=${TRANSMISSION_PORT:-9091}
+TRANSMISSION_DOWNLOAD_ROOT=${TRANSMISSION_DOWNLOAD_ROOT:-/downloads/complete}
+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
+
+i=0
+while true; do
+ key="DELETE_UNLINKED_${i}_NAME"
+ val="DELETE_UNLINKED_${i}_AGE"
+ if [ -z "${!key:-}" ]; then
+ break
+ fi
+ cat <<EOF >>/etc/cron.d/crontab
+DELETE_UNLINKED_TAG_${i}=${!key}
+DELETE_UNLINKED_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}"