edgd1er af3d905b3a
DEBUG: print all lines before execution (#2096)
* 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
2021-12-05 08:25:22 +09:00

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