Update esphome_setup.sh

This commit is contained in:
tteckster 2022-02-24 12:44:01 -05:00 committed by GitHub
parent 31897b7af6
commit f547d808f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 12 deletions

View File

@ -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"