From 03e6cdcce994296b260c83f755879a49781c9282 Mon Sep 17 00:00:00 2001 From: Kristian Haugene Date: Fri, 5 May 2017 21:10:46 +0200 Subject: [PATCH] Update UFW rules when changing peer port --- transmission/updatePort.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/transmission/updatePort.sh b/transmission/updatePort.sh index 796948a36..2bf2e6b36 100755 --- a/transmission/updatePort.sh +++ b/transmission/updatePort.sh @@ -75,11 +75,22 @@ fi # get current listening port transmission_peer_port=$(transmission-remote $myauth -si | grep Listenport | grep -oE '[0-9]+') -if [ "$new_port" != "$transmission_peer_port" ] - then +if [ "$new_port" != "$transmission_peer_port" ]; then + if [ "true" = "$ENABLE_UFW" ]; then + echo "Update UFW rules before changing port in Transmission" + + echo "denying access to $TRANSMISSION_PEER_PORT" + ufw deny $TRANSMISSION_PEER_PORT + + echo "allowing $new_port through the firewall" + ufw allow $new_port + fi + transmission-remote $myauth -p "$new_port" + echo "Checking port..." - sleep 10 && transmission-remote $myauth -pt + sleep 10 + transmission-remote $myauth -pt else echo "No action needed, port hasn't changed" fi