mirror of
https://github.com/haugene/docker-transmission-openvpn.git
synced 2026-01-09 18:41:46 +01:00
* DEBUG: print all lines before execution if var DEBUG is set to anything other than false, each bash script will be run with a set -x. This would ease debugging * DEBUG: centralize commands in utils.sh
43 lines
1.2 KiB
Bash
Executable File
43 lines
1.2 KiB
Bash
Executable File
#! /bin/bash
|
|
|
|
. /etc/transmission/environment-variables.sh
|
|
source /etc/openvpn/utils.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
|
|
|
|
echo "Sending kill signal to transmission-daemon"
|
|
PID=$(pidof transmission-daemon)
|
|
kill "$PID"
|
|
|
|
# Give transmission-daemon some time to shut down
|
|
TRANSMISSION_TIMEOUT_SEC=${TRANSMISSION_TIMEOUT_SEC:-5}
|
|
for i in $(seq "$TRANSMISSION_TIMEOUT_SEC")
|
|
do
|
|
sleep 1
|
|
[[ -z "$(pidof transmission-daemon)" ]] && break
|
|
[[ $i == 1 ]] && echo "Waiting ${TRANSMISSION_TIMEOUT_SEC}s for transmission-daemon to die"
|
|
done
|
|
|
|
# Check whether transmission-daemon is still running
|
|
if [[ -z "$(pidof transmission-daemon)" ]]
|
|
then
|
|
echo "Successfuly closed transmission-daemon"
|
|
else
|
|
echo "Sending kill signal (SIGKILL) to transmission-daemon"
|
|
kill -9 "$PID"
|
|
fi
|
|
|
|
# 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
|