From 77f299cb0568c09c1192318d9599c9e94c3d1c54 Mon Sep 17 00:00:00 2001 From: tteckster Date: Mon, 29 Aug 2022 20:22:03 -0400 Subject: [PATCH] Add network tools (#467) --- setup/debian-install.sh | 8 ++++++++ setup/ubuntu-install.sh | 13 +++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/setup/debian-install.sh b/setup/debian-install.sh index 299f9728..d738a621 100644 --- a/setup/debian-install.sh +++ b/setup/debian-install.sh @@ -37,6 +37,10 @@ function msg_ok() { local msg="$1" echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } +function msg_error() { + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} msg_info "Setting up Container OS " sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen @@ -54,6 +58,10 @@ done msg_ok "Set up Container OS" msg_ok "Network Connected: ${BL}$(hostname -I)" +if nc -zw1 8.8.8.8 443; then msg_ok "Internet Connected"; else msg_error "Internet NOT Connected"; fi; +RESOLVEDIP=$(nslookup "google.com" | awk -F':' '/^Address: / { matched = 1 } matched { print $2}' | xargs) +if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved to $RESOLVEDIP"; fi; + msg_info "Updating Container OS" apt-get update &>/dev/null apt-get -y upgrade &>/dev/null diff --git a/setup/ubuntu-install.sh b/setup/ubuntu-install.sh index c26130b6..55469d7a 100644 --- a/setup/ubuntu-install.sh +++ b/setup/ubuntu-install.sh @@ -38,22 +38,31 @@ function msg_ok() { echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } +function msg_error() { + local msg="$1" + echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" +} + msg_info "Setting up Container OS " sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen locale-gen >/dev/null while [ "$(hostname -I)" = "" ]; do - 1>&2 echo -en "${CROSS}${RD} No Network! " + 1>&2 echo -en "${CROSS}${RD} No Network! " sleep $RETRY_EVERY ((NUM--)) if [ $NUM -eq 0 ] then - 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" + 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" exit 1 fi done msg_ok "Set up Container OS" msg_ok "Network Connected: ${BL}$(hostname -I)" +if nc -zw1 8.8.8.8 443; then msg_ok "Internet Connected"; else msg_error "Internet NOT Connected"; fi; +RESOLVEDIP=$(nslookup "google.com" | awk -F':' '/^Address: / { matched = 1 } matched { print $2}' | xargs) +if [[ -z "$RESOLVEDIP" ]]; then msg_error "DNS Lookup Failure"; else msg_ok "DNS Resolved to $RESOLVEDIP"; fi; + msg_info "Updating Container OS" apt-get update &>/dev/null apt-get -y upgrade &>/dev/null