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,6 +47,8 @@ else
sleep 0.1 sleep 0.1
done done
fi
# change incoming port using the qbittorrent api - note this requires anonymous authentication via webui # change incoming port using the qbittorrent api - note this requires anonymous authentication via webui
# option 'Bypass authentication for clients on localhost' # option 'Bypass authentication for clients on localhost'
if [[ "${VPN_PROV}" == "pia" && -n "${VPN_INCOMING_PORT}" ]]; then if [[ "${VPN_PROV}" == "pia" && -n "${VPN_INCOMING_PORT}" ]]; then
@ -74,7 +61,5 @@ else
fi fi
fi
# set qbittorrent ip to current vpn ip (used when checking for changes on next run) # set qbittorrent ip to current vpn ip (used when checking for changes on next run)
qbittorrent_ip="${vpn_ip}" qbittorrent_ip="${vpn_ip}"

Loading…
Cancel
Save