2
0
Fork 0

update: check if qBittorrent is reachable, and quit if not

This commit is contained in:
soxfor 2023-03-22 01:51:27 +00:00
parent 7d4b211884
commit e8bdd43dbf
2 changed files with 13 additions and 3 deletions

View File

@ -20,7 +20,7 @@ LABEL version="1.0.4"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt install --no-install-suggests --no-install-recommends -y natpmpc curl bc
RUN apt install --no-install-suggests --no-install-recommends -y natpmpc curl bc ncat
RUN rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN apt clean

View File

@ -34,6 +34,11 @@ qbt_checksid(){
fi
}
qbt_isreachable(){
(sleep 3; echo "^C") | ncat -4 --wait 5 ${QBITTORRENT_SERVER} ${QBITTORRENT_PORT} 2>/dev/null &>/dev/null
return $?
}
get_portmap() {
res=0
public_ip=$(getpublicip)
@ -97,8 +102,13 @@ return 0
load_vals(){
public_ip=$(getpublicip)
qbt_sid=$(qbt_login)
configured_port=$(findconfiguredport ${qbt_sid})
if qbt_isreachable; then
qbt_sid=$(qbt_login)
configured_port=$(findconfiguredport ${qbt_sid})
else
echo "$(timestamp) | Unable to reach qBittorrent at ${QBITTORRENT_SERVER}:${QBITTORRENT_PORT}"
exit 6
fi
active_port=''
}