Skip to content

Commit cdd35ab

Browse files
committed
Firmware: make the connectivity audit more robust
Change the ping to size 1500 to emulate a typical download scenario. Sometimes small pings will respond but not the larger fetch. Secondly, do a separate IPv4 and IPv6 update of the repository depending on whether we got a corresponding address from the host. It should clear up the question if IPv4 or IPv6 or both is broken/defunct/disabled.
1 parent 9eaa897 commit cdd35ab

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/opnsense/scripts/firmware/connection.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,29 @@ TEE="/usr/bin/tee -a"
3030
: > ${LOCKFILE}
3131

3232
URL=$(opnsense-update -M)
33+
POPT="-c4 -s1500"
34+
3335
HOST=${URL#*://}
3436
HOST=${HOST%%/*}
3537
IPV4=$(host -t A ${HOST} | head -n 1 | cut -d\ -f4)
3638
IPV6=$(host -t AAAA ${HOST} | head -n 1 | cut -d\ -f5)
3739

3840
echo "***GOT REQUEST TO AUDIT CONNECTIVITY***" >> ${LOCKFILE}
3941
echo "Currently running $(opnsense-version) at $(date)" >> ${LOCKFILE}
40-
echo "Checking connectivity for host: ${HOST}" | ${TEE} ${LOCKFILE}
4142
if [ -n "${IPV4}" -a -z "${IPV4%%*.*}" ]; then
42-
(ping -c4 ${IPV4} 2>&1) | ${TEE} ${LOCKFILE}
43+
echo "Checking connectivity for host: ${HOST} -> ${IPV4}" | ${TEE} ${LOCKFILE}
44+
(ping ${POPT} ${IPV4} 2>&1) | ${TEE} ${LOCKFILE}
45+
echo "Checking connectivity for repository (IPv4): ${URL}" | ${TEE} ${LOCKFILE}
46+
(pkg -4 update -f 2>&1) | ${TEE} ${LOCKFILE}
4347
else
44-
echo "No IPv4 address could be found." | ${TEE} ${LOCKFILE}
48+
echo "No IPv4 address could be found for host: ${HOST}" | ${TEE} ${LOCKFILE}
4549
fi
4650
if [ -n "${IPV6}" -a -z "${IPV6%%*:*}" ]; then
47-
(ping6 -c4 ${IPV6} 2>&1) | ${TEE} ${LOCKFILE}
51+
echo "Checking connectivity for host: ${HOST} -> ${IPV6}" | ${TEE} ${LOCKFILE}
52+
(ping6 ${POPT} ${IPV6} 2>&1) | ${TEE} ${LOCKFILE}
53+
echo "Checking connectivity for repository (IPv6): ${URL}" | ${TEE} ${LOCKFILE}
54+
(pkg -6 update -f 2>&1) | ${TEE} ${LOCKFILE}
4855
else
49-
echo "No IPv6 address could be found." | ${TEE} ${LOCKFILE}
56+
echo "No IPv6 address could be found for host: ${HOST}" | ${TEE} ${LOCKFILE}
5057
fi
51-
echo "Checking connectivity for URL: ${URL}" | ${TEE} ${LOCKFILE}
52-
(pkg update -f 2>&1) | ${TEE} ${LOCKFILE}
5358
echo '***DONE***' >> ${LOCKFILE}

0 commit comments

Comments
 (0)