From 040e3e1eb692394c764f175da47cba76aec8ce30 Mon Sep 17 00:00:00 2001 From: himred Date: Thu, 8 Feb 2018 10:24:08 +0100 Subject: [PATCH 1/3] Update README.md --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 1917b2fb2..f14ffd555 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,21 @@ You may set the following parameters to customize the user id that runs transmis |`PUID` | Sets the user id who will run transmission | `PUID=1003`| |`PGID` | Sets the group id for the transmission user | `PGID=1003` | +If you ever need to run custom code before or after transmission is executed or stopped, you can use the custom scripts feature. +Custom scripts are located in the /scripts directory which is empty by default. +To enable this feature, you'll need to mount the /scripts directory. + +Once /scripts is mounted you'll need to write your custom code in the following bash shell scripts: + +| Script | Function | +|----------|----------| +|/scripts/transmission-pre-start.sh | This shell script will be executed before transmission start | +|/scripts/transmission-post-start.sh | This shell script will be executed after transmission start | +|/scripts/transmission-pre-stop.sh | This shell script will be executed before transmission stop | +|/scripts/transmission-post-stop.sh | This shell script will be executed after transmission stop | + +Don't forget to include the #!/bin/bash shebang and to make the scripts executable using chmod a+x + ### RSS plugin The Transmission RSS plugin can optionally be run as a separate container. It allow to download torrents based on an RSS URL, see [Plugin page](https://github.com/nning/transmission-rss). From e3d38b2d63869130bc7bd4515fbf0b5bbe281884 Mon Sep 17 00:00:00 2001 From: himred Date: Thu, 8 Feb 2018 10:26:33 +0100 Subject: [PATCH 2/3] Update start.sh --- transmission/start.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/transmission/start.sh b/transmission/start.sh index 1cda1bedf..7b742b1d9 100755 --- a/transmission/start.sh +++ b/transmission/start.sh @@ -12,6 +12,15 @@ if [ "$4" = "" ]; then kill -9 $PPID exit 1 fi + +# If transmission-pre-start.sh exists, run it +if [ -x /scripts/transmission-pre-start.sh ] +then + echo "Executing /scripts/transmission-pre-start.sh" + /scripts/transmission-pre-start.sh + echo "/scripts/transmission-pre-start.sh returned $?" +fi + echo "Updating TRANSMISSION_BIND_ADDRESS_IPV4 to the ip of $1 : $4" export TRANSMISSION_BIND_ADDRESS_IPV4=$4 @@ -52,4 +61,12 @@ else echo "NO PORT UPDATER FOR THIS PROVIDER" fi +# If transmission-post-start.sh exists, run it +if [ -x /scripts/transmission-post-start.sh ] +then + echo "Executing /scripts/transmission-post-start.sh" + /scripts/transmission-post-start.sh + echo "/scripts/transmission-post-start.sh returned $?" +fi + echo "Transmission startup script complete." From 977fd4984eb98ae4148c9ac0e9a85a6f5654a59d Mon Sep 17 00:00:00 2001 From: himred Date: Thu, 8 Feb 2018 10:27:24 +0100 Subject: [PATCH 3/3] Update stop.sh --- transmission/stop.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/transmission/stop.sh b/transmission/stop.sh index 216fe5e19..5f88939d5 100755 --- a/transmission/stop.sh +++ b/transmission/stop.sh @@ -1,3 +1,19 @@ #! /bin/sh +# If transmission-pre-stop.sh exists, run it +if [ -x /scripts/transmission-pre-stop.sh ] +then + echo "Executing /scripts/transmission-pre-stop.sh" + /scripts/transmission-pre-stop.sh + echo "/scripts/transmission-pre-stop.sh returned $?" +fi + kill $(pidof transmission-daemon) + +# If transmission-post-stop.sh exists, run it +if [ -x /scripts/transmission-post-stop.sh ] +then + echo "Executing /scripts/transmission-post-stop.sh" + /scripts/transmission-post-stop.sh + echo "/scripts/transmission-post-stop.sh returned $?" +fi