Skip to content

Commit 7f5859a

Browse files
committed
feat: add set_port.sh script
We're using this new script to change the port forwarded in transmission No need for docker containers crashing anymore.
1 parent 1237ad0 commit 7f5859a

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

get_port.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ current_port=$(jq -r '."peer-port"' "${transmission_settings}")
9090

9191
# Check if changes are needed
9292
if [[ ${current_port} -eq ${port} ]]; then
93-
echo "Nothing to do, port is already in used"
93+
echo "Nothing to do, port ${port} is already in used"
9494
exit 0
9595
fi
9696

set_port.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
trap 'exit 0' SIGTERM
4+
5+
readonly root_dir="/home/felipe/workspace/containers/pia-transmission-prowlarr"
6+
readonly transmission_port="${root_dir}/data/pia-port/port.dat"
7+
8+
if ! transmission-remote -l 2>/dev/null; then # Checks that Transmission is running
9+
>&2 echo "Transmission not running."; exit 1
10+
fi
11+
12+
if ! [[ -f ${transmission_port} && -r ${transmission_port} ]]; then
13+
>&2 echo "Port file doesn't exist or is not readable!"; exit 1
14+
fi
15+
16+
# Reading port
17+
PORT=$(cat "${transmission_port}")
18+
echo "Port read from file (${PORT})"
19+
20+
# Changing port
21+
transmission-remote -p "${PORT}"
22+
sleep 2
23+
# Testing port
24+
if [[ $(transmission-remote -pt) != "Port is open: Yes" ]]; then
25+
echo "Transmission port (${PORT}) is not open!"; exit 1
26+
fi
27+
28+
exit 0

0 commit comments

Comments
 (0)