make code dry

pull/7/head
binhex 6 years ago
parent 469aa665ba
commit d3a5df8139

@ -1,21 +1,6 @@
#!/bin/bash #!/bin/bash
# change incoming port using the qbittorrent api - note this requires anonymous authentication via webui if [[ "${qbittorrent_running}" == "false" ]]; then
# option 'Bypass authentication for clients on localhost'
if [[ "${qbittorrent_running}" == "true" ]]; then
if [[ "${VPN_PROV}" == "pia" && -n "${VPN_INCOMING_PORT}" ]]; then
curl -i -X POST -d "json=%7B%22random_port%22%3Afalse%7D" "http://localhost:${WEBUI_PORT}/command/setPreferences" &> /dev/null
curl -i -X POST -d "json=%7B%22listen_port%22%3A${VPN_INCOMING_PORT}%7D" "http://localhost:${WEBUI_PORT}/command/setPreferences" &> /dev/null
# set qbittorrent port to current vpn port (used when checking for changes on next run)
qbittorrent_port="${VPN_INCOMING_PORT}"
fi
else
echo "[info] Removing session lock file (if it exists)..." echo "[info] Removing session lock file (if it exists)..."
rm -f /config/qBittorrent/data/BT_backup/session.lock rm -f /config/qBittorrent/data/BT_backup/session.lock
@ -62,17 +47,17 @@ else
sleep 0.1 sleep 0.1
done done
# change incoming port using the qbittorrent api - note this requires anonymous authentication via webui fi
# option 'Bypass authentication for clients on localhost'
if [[ "${VPN_PROV}" == "pia" && -n "${VPN_INCOMING_PORT}" ]]; then
curl -i -X POST -d "json=%7B%22random_port%22%3Afalse%7D" "http://localhost:${WEBUI_PORT}/command/setPreferences" &> /dev/null # change incoming port using the qbittorrent api - note this requires anonymous authentication via webui
curl -i -X POST -d "json=%7B%22listen_port%22%3A${VPN_INCOMING_PORT}%7D" "http://localhost:${WEBUI_PORT}/command/setPreferences" &> /dev/null # option 'Bypass authentication for clients on localhost'
if [[ "${VPN_PROV}" == "pia" && -n "${VPN_INCOMING_PORT}" ]]; then
# set rtorrent port to current vpn port (used when checking for changes on next run) curl -i -X POST -d "json=%7B%22random_port%22%3Afalse%7D" "http://localhost:${WEBUI_PORT}/command/setPreferences" &> /dev/null
qbittorrent_port="${VPN_INCOMING_PORT}" curl -i -X POST -d "json=%7B%22listen_port%22%3A${VPN_INCOMING_PORT}%7D" "http://localhost:${WEBUI_PORT}/command/setPreferences" &> /dev/null
fi # set rtorrent port to current vpn port (used when checking for changes on next run)
qbittorrent_port="${VPN_INCOMING_PORT}"
fi fi

Loading…
Cancel
Save