Script to change transmission listening port
Posted: Thu Sep 10, 2015 12:31 am
I am trying to run a script that will automatically change the port that transmission is listening on. My network setup is more advanced than the typical person I guess and this is the only way to get it to work since the port changes whenever my VPN decides to release a new port. I already have a sample script, but it is intended for a Synology system and when I try it on my ubuntu server it gives an error
Thank you
Original Synology Script:
Can any one help me please?transmission-port: 40: transmission-port: Syntax error: end of file unexpected (expecting "then")
Thank you
Original Synology Script:
Code: Select all
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
# Script to update port used by Transmission torrent client
# Developed for use on Synology DSM. Should work on other platforms.
# v1.0 (22nd January 2014)
# Written by Andy Fox
# This script is configured to work with Transmission that has password
# protection on the web GUI. You can remove this stuff if you don't use it.
USERNAME="username"
PASSWORD="password"
if [ ! -e /tmp/pia_port.txt ]; then
logger -p user.crit "transmission-port: Setting up port forward for first time."
cd /tmp && curl -O -k https://192.168.1.1/pia_port.txt
/usr/local/transmission/bin/transmission-remote --auth $USERNAME:$PASSWORD -p $(cat /tmp/pia_port.txt)
else
CURPORT=`cat /tmp/pia_port.txt`
cd /tmp && curl -o pia_new.txt -k https://192.168.1.1/pia_port.txt
NEWPORT=`cat /tmp/pia_new.txt`
logger -p user.crit "transmission-port: Current port: $CURPORT"
logger -p user.crit "transmission-port: New Port: $NEWPORT"
if [ "$CURPORT" = "$NEWPORT" ]; then
logger -p user.crit "transmission-port: Port not changed. Exiting."
exit 0
fi
logger -p user.crit "transmission-port: Updating port."
mv /tmp/pia_new.txt /tmp/pia_port.txt
/usr/local/transmission/bin/transmission-remote --auth $USERNAME:$PASSWORD -p $(cat /tmp/pia_port.txt)
fi