diff --git a/Dockerfile b/Dockerfile index 99d8f52..c8ba2ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/data/start.sh b/data/start.sh index bf72f93..4a2d403 100755 --- a/data/start.sh +++ b/data/start.sh @@ -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='' }