diff --git a/install.sh b/install.sh index 74baca3..57f2476 100755 --- a/install.sh +++ b/install.sh @@ -46,6 +46,7 @@ fi if [ "$dl_server" = "yes" ]; then $sudo cp $run_directory/systemd-templates/transmission-daemon.service /etc/systemd/system/ $sudo sed -i -e "s/PH_NAS_USER/$nas_user/g" /etc/systemd/system/transmission-daemon.service + $sudo sed -i -e "s:PH_DIRECTORY:$run_directory:g" /etc/systemd/system/transmission-daemon.service $sudo sed -i -e "s/PH_AUTHORIZED_ADDRESSES/$authorized_ips/g" /etc/systemd/system/transmission-daemon.service $sudo sed -i -e "s/PH_USER/$user/g" /etc/systemd/system/transmission-daemon.service $sudo sed -i -e "s/PH_PASSWORD/$password/g" /etc/systemd/system/transmission-daemon.service diff --git a/systemd-templates/transmission-daemon.service b/systemd-templates/transmission-daemon.service index e0e408b..257a867 100644 --- a/systemd-templates/transmission-daemon.service +++ b/systemd-templates/transmission-daemon.service @@ -1,12 +1,12 @@ [Unit] Description=Transmission BitTorrent Daemon (KTO) -Requires=transmission-vpn.service BindsTo=transmission-vpn.timer After=network.target transmission-vpn.timer [Service] User=PH_NAS_USER Type=notify +ExecStartPre=PH_DIRECTORY/transmission-vpn.sh ExecStart=/usr/bin/transmission-daemon -f --log-error -a PH_AUTHORIZED_ADDRESSES -C -t -u PH_USER -v PH_PASSWORD -w PH_DL_LOCATION ExecStop=/bin/kill -s STOP $MAINPID ExecReload=/bin/kill -s HUP $MAINPID diff --git a/transmission-vpn.sh b/transmission-vpn.sh index e9053f4..7337aa0 100755 --- a/transmission-vpn.sh +++ b/transmission-vpn.sh @@ -5,6 +5,8 @@ # This will be achieved with a timer started and stopped with transmission service # On transmission starting # When the script exits with failure, associated service should try to start transmission service + # NOTE not on transmission starting, as this script is not run by its service; it means there's an issue with VPN at + # start, and this should be looked at manually # Thus this script will be executed again # We can enter an infinite loop, but this will effectively prevent transmission from connecting # If both services are stopped, this script will never be run by error