Update esphome_setup.sh
This commit is contained in:
parent
31897b7af6
commit
f547d808f6
1 changed files with 25 additions and 12 deletions
|
@ -7,7 +7,12 @@ set -o pipefail
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
CROSS='\033[1;31m\xE2\x9D\x8C\033[0m'
|
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_NUM=5
|
||||||
RETRY_EVERY=3
|
RETRY_EVERY=3
|
||||||
NUM=$RETRY_NUM
|
NUM=$RETRY_NUM
|
||||||
|
@ -27,38 +32,42 @@ function msg() {
|
||||||
echo -e "$TEXT"
|
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
|
sed -i "/$LANG/ s/\(^# \)//" /etc/locale.gen
|
||||||
locale-gen >/dev/null
|
locale-gen >/dev/null
|
||||||
while [ "$(hostname -I)" = "" ]; do
|
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
|
sleep $RETRY_EVERY
|
||||||
((NUM--))
|
((NUM--))
|
||||||
if [ $NUM -eq 0 ]
|
if [ $NUM -eq 0 ]
|
||||||
then
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
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 update &>/dev/null
|
||||||
apt-get -qqy upgrade &>/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 update &>/dev/null
|
||||||
apt-get -qqy install \
|
apt-get -qqy install \
|
||||||
curl \
|
curl \
|
||||||
sudo &>/dev/null
|
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
|
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
|
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
|
pip3 install tornado esptool &>/dev/null
|
||||||
|
|
||||||
service_path="/etc/systemd/system/esphomeDashboard.service"
|
service_path="/etc/systemd/system/esphomeDashboard.service"
|
||||||
|
@ -72,8 +81,9 @@ User=root
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target" > $service_path
|
WantedBy=multi-user.target" > $service_path
|
||||||
systemctl enable esphomeDashboard.service &>/dev/null
|
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/motd
|
||||||
rm /etc/update-motd.d/10-uname
|
rm /etc/update-motd.d/10-uname
|
||||||
touch ~/.hushlogin
|
touch ~/.hushlogin
|
||||||
|
@ -87,5 +97,8 @@ EOF
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//')
|
systemctl restart $(basename $(dirname $GETTY_OVERRIDE) | sed 's/\.d//')
|
||||||
systemctl start esphomeDashboard
|
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/*
|
rm -rf /esphome_setup.sh /var/{cache,log}/* /var/lib/apt/lists/*
|
||||||
|
echo -e "${CM}${CL} \r"
|
||||||
|
|
Loading…
Reference in a new issue