123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #!/bin/bash
-
- SCRIPTPATH=$(dirname $0)
- source $SCRIPTPATH/config.txt
-
- # CONFIG: comment this line out when you set the daemondir to what you want
- exit 1
- DAEMONDIR=/var/lib/transmission/info
-
- PIDFILE=$DAEMONDIR/transmission.pid
-
- function natfwd_do {
- $SCRIPTPATH/natfwd.sh --ufw $1 $EXTIF "$EXTPORTS" $NSNAME
- }
-
- case $1 in
- enable)
- set -e
-
- natfwd_do enable
-
- echo 'VPN IP address:' $(ip netns exec $NSNAME curl ifconfig.me)
-
- ip netns exec $NSNAME \
- /usr/bin/transmission-daemon --log-error -g $DAEMONDIR -x $PIDFILE
-
- ;;
-
- disable)
- set -x
-
- if [ -f "$PIDFILE" ]; then
- xmpid=$(cat $PIDFILE | sed 's/\;.*//')
- echo 'killing' $xmpid
- kill -15 $xmpid
- fi
-
- natfwd_do disable
-
- ;;
- reload)
- /bin/kill -s HUP $(cat $PIDFILE)
- ;;
- esac
|