Simplify URL validation, don't use ping/ICMP

This commit is contained in:
Jose
2019-12-05 03:38:33 -04:00
parent 6e8279ecd4
commit cfcad20f4a

View File

@@ -441,11 +441,9 @@ case "${1}" in
NAME_VERIFY=$(echo "${RELEASE}" | grep -iwE '^([1-9]{2,2})\.[0-9](-RELEASE|-RC[1-2])$' | tr '[:lower:]' '[:upper:]')
if [ -n "${NAME_VERIFY}" ]; then
RELEASE="${NAME_VERIFY}"
if ping -c1 -t2 ftp.freebsd.org >/dev/null 2>&1; then
## main http
UPSTREAM_URL="http://ftp.freebsd.org/pub/FreeBSD/releases/${HW_MACHINE}/${HW_MACHINE_ARCH}/${RELEASE}"
else
## main ftp
UPSTREAM_URL="http://ftp.freebsd.org/pub/FreeBSD/releases/${HW_MACHINE}/${HW_MACHINE_ARCH}/${RELEASE}"
if ! fetch -qo /dev/null "${UPSTREAM_URL}/MANIFEST" 2>/dev/null; then
## try an alternate url
UPSTREAM_URL="ftp://ftp.freebsd.org/pub/FreeBSD/releases/${HW_MACHINE}/${HW_MACHINE_ARCH}/${RELEASE}"
fi
bootstrap_directories
@@ -465,7 +463,7 @@ if [ -n "${NAME_VERIFY}" ]; then
else
usage
fi
;;
;;
*-stable-build-*|*-STABLE-BUILD-*)
## check for HardenedBSD(for current changes)
NAME_VERIFY=$(echo "${RELEASE}" | grep -iwE '([0-9]{1,2})(-stable-build|-STABLE-BUILD)-([0-9]{1,2})$' | sed 's/BUILD/build/g' | sed 's/STABLE/stable/g')
@@ -473,11 +471,9 @@ NAME_RELEASE=$(echo ${NAME_VERIFY} | sed 's/-build-[0-9]\{1,2\}//g')
NAME_BUILD=$(echo ${NAME_VERIFY} | sed 's/[0-9]\{1,2\}-stable-//g')
if [ -n "${NAME_VERIFY}" ]; then
RELEASE="${NAME_VERIFY}"
if ping -c1 -t2 installer.hardenedbsd.org >/dev/null 2>&1; then
## main site
UPSTREAM_URL="http://installer.hardenedbsd.org/pub/hardenedbsd/${NAME_RELEASE}/${HW_MACHINE}/${HW_MACHINE_ARCH}/${NAME_BUILD}"
else
## alternate mirror
UPSTREAM_URL="http://installer.hardenedbsd.org/pub/hardenedbsd/${NAME_RELEASE}/${HW_MACHINE}/${HW_MACHINE_ARCH}/${NAME_BUILD}"
if ! fetch -qo /dev/null "${UPSTREAM_URL}/MANIFEST" 2>/dev/null; then
## try an alternate url
UPSTREAM_URL="http://ci-01.nyi.hardenedbsd.org/pub/hardenedbsd/${NAME_RELEASE}/${HW_MACHINE}/${HW_MACHINE_ARCH}/${NAME_BUILD}"
fi
bootstrap_directories