diff --git a/scripts/adsbexchange-feed.service b/scripts/adsbexchange-feed.service index a4f6d02..e734198 100644 --- a/scripts/adsbexchange-feed.service +++ b/scripts/adsbexchange-feed.service @@ -11,6 +11,8 @@ ExecStart=/usr/local/share/adsbexchange/adsbexchange-feed.sh Type=simple Restart=always RestartSec=30 +StartLimitInterval=1 +StartLimitBurst=100 SyslogIdentifier=adsbexchange-feed [Install] diff --git a/scripts/adsbexchange-feed.sh b/scripts/adsbexchange-feed.sh index 489583e..957871b 100755 --- a/scripts/adsbexchange-feed.sh +++ b/scripts/adsbexchange-feed.sh @@ -12,10 +12,10 @@ INPUT_PORT=$(echo $INPUT | cut -d: -f2) SOURCE="--net-connector $INPUT_IP,$INPUT_PORT,beast_in" MLAT_IN="--net-connector localhost,30157,beast_in" -if ! nc -z "$INPUT_IP" "$INPUT_PORT"; then - echo "<3>Could not connect to $INPUT_IP:$INPUT_PORT" - exit 1 -fi +while ! nc -z "$INPUT_IP" "$INPUT_PORT" && command -v nc &>/dev/null; do + echo "<3>Could not connect to $INPUT_IP:$INPUT_PORT, retry in 30 seconds." + sleep 30 +done /usr/local/share/adsbexchange/feed-adsbx --net --net-only --debug=n --quiet \ --write-json /run/adsbexchange-feed \ diff --git a/scripts/adsbexchange-mlat.service b/scripts/adsbexchange-mlat.service index 1180958..190ded0 100644 --- a/scripts/adsbexchange-mlat.service +++ b/scripts/adsbexchange-mlat.service @@ -10,6 +10,8 @@ ExecStart=/usr/local/share/adsbexchange/adsbexchange-mlat.sh Type=simple Restart=always RestartSec=30 +StartLimitInterval=1 +StartLimitBurst=100 SyslogIdentifier=adsbexchange-mlat [Install] diff --git a/scripts/adsbexchange-mlat.sh b/scripts/adsbexchange-mlat.sh index 32ad864..be5a2a5 100755 --- a/scripts/adsbexchange-mlat.sh +++ b/scripts/adsbexchange-mlat.sh @@ -9,10 +9,11 @@ fi INPUT_IP=$(echo $INPUT | cut -d: -f1) INPUT_PORT=$(echo $INPUT | cut -d: -f2) -if ! nc -z "$INPUT_IP" "$INPUT_PORT"; then - echo "<3>Could not connect to $INPUT_IP:$INPUT_PORT" - exit 1 -fi + +while ! nc -z "$INPUT_IP" "$INPUT_PORT" && command -v nc &>/dev/null; do + echo "<3>Could not connect to $INPUT_IP:$INPUT_PORT, retry in 30 seconds." + sleep 30 +done /usr/local/share/adsbexchange/venv/bin/python3 /usr/local/share/adsbexchange/venv/bin/mlat-client \ --input-type "$INPUT_TYPE" --no-udp \ diff --git a/setup.sh b/setup.sh index 05938f3..7eebb02 100755 --- a/setup.sh +++ b/setup.sh @@ -152,9 +152,10 @@ fi for package in $required_packages do if [ $(dpkg-query -W -f='${STATUS}' $package 2>/dev/null | grep -c "ok installed") -eq 0 ]; then - if [[ $APT_UPDATED == "false" ]]; then - apt-get update && APT_UPDATE="true" + if [[ "$APT_UPDATED" == "false" ]]; then + apt-get update >> $LOGFILE 2>&1 && APT_UPDATED="true" fi + echo Installing $package >> $LOGFILE 2>&1 apt-get install -y $package >> $LOGFILE 2>&1 fi progress=$((progress+2))