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

39 lines
957 B
Bash

#!/bin/bash
# redirect stdout/stderr to a file
source /etc/openvpn/utils.sh
#exec &>>route-pre-down.log
#Print Date
NOW=$(date +"%Y-%m-%d %T")
echo "${NOW}: route-pre-down script: Start "
echo "Sending exit signal to transmission."
TRANSMISSION_PASSWD_FILE=/config/transmission-credentials.txt
transmission_username=$(head -1 ${TRANSMISSION_PASSWD_FILE})
transmission_passwd=$(tail -1 ${TRANSMISSION_PASSWD_FILE})
transmission_settings_file=${TRANSMISSION_HOME}/settings.json
# Check if transmission remote is set up with authentication
auth_enabled=$(grep 'rpc-authentication-required\"' "$transmission_settings_file" \
| grep -oE 'true|false')
if [[ "true" = "$auth_enabled" ]]
then
echo "transmission auth required"
myauth="--auth $transmission_username:$transmission_passwd"
else
echo "transmission auth not required"
myauth=""
fi
transmission-remote $myauth --exit &
wait
echo "route-pre-down script: Done"