-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathroute-pre-down.sh
38 lines (26 loc) · 957 Bytes
/
route-pre-down.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/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"