From f547d808f6d43020f2573b443f7c84abf8b46088 Mon Sep 17 00:00:00 2001 From: tteckster Date: Thu, 24 Feb 2022 12:44:01 -0500 Subject: [PATCH] Update esphome_setup.sh --- setup/esphome_setup.sh | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/setup/esphome_setup.sh b/setup/esphome_setup.sh index d62a6e2e..001730f0 100644 --- a/setup/esphome_setup.sh +++ b/setup/esphome_setup.sh @@ -7,7 +7,12 @@ 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' +YW=`echo "\033[33m"` +BL=`echo "\033[36m"` +RD=`echo "\033[01;31m"` +CM='\xE2\x9C\x94\033' +GN=`echo "\033[1;92m"` +CL=`echo "\033[m"` RETRY_NUM=5 RETRY_EVERY=3 NUM=$RETRY_NUM @@ -27,38 +32,42 @@ function msg() { echo -e "$TEXT" } -echo -e "${CHECKMARK} \e[1;92m Setting up Container OS... \e[0m" +echo -en "${GN} Setting up Container OS... " 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)" + 1>&2 echo -en "${CROSS}${RD} No Network! " 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" + 1>&2 echo -e "${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}" exit 1 fi done - echo -e "${CHECKMARK} \e[1;92m Network Connected: \e[0m $(hostname -I)" +echo -e "${CM}${CL} \r" -echo -e "${CHECKMARK} \e[1;92m Updating Container OS... \e[0m" +echo -en "${GN} Updating Container OS... " apt-get update &>/dev/null apt-get -qqy upgrade &>/dev/null +echo -e "${CM}${CL} \r" -echo -e "${CHECKMARK} \e[1;92m Installing Dependencies... \e[0m" +echo -en "${GN} Installing Dependencies... " apt-get update &>/dev/null apt-get -qqy install \ curl \ sudo &>/dev/null +echo -e "${CM}${CL} \r" -echo -e "${CHECKMARK} \e[1;92m Installing pip3... \e[0m" +echo -en "${GN} Installing pip3... " apt-get install python3-pip -y &>/dev/null +echo -e "${CM}${CL} \r" -echo -e "${CHECKMARK} \e[1;92m Installing ESPHome... \e[0m" +echo -en "${GN} Installing ESPHome... " pip3 install esphome &>/dev/null +echo -e "${CM}${CL} \r" -echo -e "${CHECKMARK} \e[1;92m Installing ESPHome Dashboard... \e[0m" +echo -en "${GN} Installing ESPHome Dashboard... " pip3 install tornado esptool &>/dev/null service_path="/etc/systemd/system/esphomeDashboard.service" @@ -72,8 +81,9 @@ User=root [Install] WantedBy=multi-user.target" > $service_path systemctl enable esphomeDashboard.service &>/dev/null +echo -e "${CM}${CL} \r" -echo -e "${CHECKMARK} \e[1;92m Customizing Container... \e[0m" +echo -en "${GN} Customizing Container... " rm /etc/motd rm /etc/update-motd.d/10-uname touch ~/.hushlogin @@ -87,5 +97,8 @@ EOF systemctl daemon-reload systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//') systemctl start esphomeDashboard -echo -e "${CHECKMARK} \e[1;92m Cleanup... \e[0m" +echo -e "${CM}${CL} \r" + +echo -en "${GN} Cleanup... " rm -rf /esphome_setup.sh /var/{cache,log}/* /var/lib/apt/lists/* +echo -e "${CM}${CL} \r"