check incoming port using ext site

pull/23/head 4.1.7-1-01
binhex 5 years ago
parent 9a4cacbdb2
commit 9792f4c660

@ -30,6 +30,15 @@ grep -q 'General\\Locale' "${qbittorrent_config}" || sed -i '/\[Preferences\]/a
qbittorrent_port="6881" qbittorrent_port="6881"
qbittorrent_ip="0.0.0.0" qbittorrent_ip="0.0.0.0"
# define sleep period between loops
sleep_period_secs=30
# define sleep period between incoming port checks
sleep_period_incoming_port_secs=1800
# sleep period counter - used to limit number of hits to external website to check incoming port
sleep_period_counter_secs=0
# while loop to check ip and port # while loop to check ip and port
while true; do while true; do
@ -103,15 +112,13 @@ while true; do
if [[ "${qbittorrent_running}" == "true" ]]; then if [[ "${qbittorrent_running}" == "true" ]]; then
# run netcat to identify if port still open, use exit code if [ "${sleep_period_counter_secs}" -ge "${sleep_period_incoming_port_secs}" ]; then
nc_exitcode=$(/usr/bin/nc -z -w 3 "${vpn_ip}" "${qbittorrent_port}")
if [[ "${nc_exitcode}" -ne 0 ]]; then # run script to check incoming port is accessible
source /home/nobody/checkextport.sh
echo "[info] qBittorrent incoming port closed, marking for reconfigure" # reset sleep period counter
sleep_period_counter_secs=0
# mark as reconfigure required due to mismatch
port_change="true"
fi fi
@ -196,6 +203,9 @@ while true; do
fi fi
sleep 30s # increment sleep period counter - used to limit number of hits to external website to check incoming port
sleep_period_counter_secs=$((sleep_period_counter_secs+"${sleep_period_secs}"))
sleep "${sleep_period_secs}"s
done done

Loading…
Cancel
Save