From b54ca7c8cce8871a3c432bbc946775a2aba40618 Mon Sep 17 00:00:00 2001 From: tteckster Date: Tue, 1 Feb 2022 21:57:42 -0500 Subject: [PATCH] Update ubuntu_setup.sh --- setup/ubuntu_setup.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/setup/ubuntu_setup.sh b/setup/ubuntu_setup.sh index dc6db27d..b35e5027 100644 --- a/setup/ubuntu_setup.sh +++ b/setup/ubuntu_setup.sh @@ -6,7 +6,10 @@ set -o nounset set -o pipefail shopt -s expand_aliases alias die='EXIT=$? LINE=$LINENO error_exit' +CROSS='\033[1;31m\xE2\x9D\x8C\033[0m' CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m' +RETRY_NUM=5 +RETRY_EVERY=3 trap die ERR trap 'die "Script interrupted."' INT @@ -26,6 +29,17 @@ function msg() { echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen locale-gen >/dev/null +while [ "$(hostname -I)" = "" ]; do + 1>&2 echo -e "${CROSS} \e[1;31m No Network: \e[0m $(date)" + sleep $RETRY_EVERY + ((NUM--)) + if [ $NUM -eq 0 ] + then + 1>&2 echo -e "${CROSS} \e[1;31m No Network After $RETRY_NUM Tries \e[0m" + exit 1 + fi +done + echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" echo -e "${CHECKMARK} \e[1;92m Updating Container OS \e[0m" apt update &>/dev/null