-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sh
43 lines (41 loc) · 1.06 KB
/
script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
SERVICE="hass"
while true
do
if ping -q -c 1 -W 1 10.255.0.1 >/dev/null; then
echo "IPv4 is up"
sleep 15
else
echo "IPv4 is down"
if pgrep -x "$SERVICE" >/dev/null
then
echo "$SERVICE is running"
sleep 15
else
echo "$SERVICE stopped"
route add default gw 192.168.122.1 eth9
/usr/bin/vnx_config_nat eth1 eth9
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get -y install python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev
sudo useradd -rm homeassistant -G dialout,gpio,i2c
cd /srv
sudo mkdir homeassistant
sudo chown homeassistant:homeassistant homeassistant
sudo -u homeassistant -H -s
cd /srv/homeassistant
python3 -m venv .
source bin/activate
sleep 30
python3 -m pip install wheel
pip3 install homeassistant
hass &
sleep 55
echo "mqtt:" >> /root/.homeassistant/configuration.yaml
echo " broker: 10.2.2.4" >> /root/.homeassistant/configuration.yaml
# uncomment to start hass if stopped
# systemctl start nginx
# mail
sleep 5
fi
fi
done