-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathstart.sh
More file actions
25 lines (22 loc) · 788 Bytes
/
Copy pathstart.sh
File metadata and controls
25 lines (22 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
COOKIES="/tmp/cookies.txt"
update_port () {
PORT=$(cat $PORT_FORWARDED)
rm -f $COOKIES
curl -s -c $COOKIES --data "username=$QBITTORRENT_USER&password=$QBITTORRENT_PASS" ${HTTP_S}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/auth/login > /dev/null
curl -s -b $COOKIES --data 'json={"listen_port": "'"$PORT"'"}' ${HTTP_S}://${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}/api/v2/app/setPreferences > /dev/null
rm -f $COOKIES
echo "Successfully updated qbittorrent to port $PORT"
}
while true; do
if [ -f $PORT_FORWARDED ]; then
update_port
inotifywait -mq -e close_write $PORT_FORWARDED | while read change; do
update_port
done
else
echo "Couldn't find file $PORT_FORWARDED"
echo "Trying again in 10 seconds"
sleep 10
fi
done