forked from reserve85/HoymilesZeroExport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
47 lines (40 loc) · 1.26 KB
/
install.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
42
43
44
45
46
47
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
chmod +x $SCRIPT_DIR/HoymilesZeroExport.py
chmod +x $SCRIPT_DIR/restart.sh
chmod +x $SCRIPT_DIR/uninstall_service.sh
PIP3=$(which pip3)
echo 'Installing packages'
if [ -z $PIP3 ]; then
apt update
apt -y install python3-pip
fi
pip3 install requests
pip3 install packaging
pip3 install pyModbusTCP
echo 'Packages install completed'
if systemctl --type=service --state=running | grep -Fq 'HoymilesZeroExport.service'; then
echo 'Uninstall HoymilesZeroExport.service'
systemctl stop HoymilesZeroExport.service
systemctl disable HoymilesZeroExport.service
rm /etc/systemd/system/HoymilesZeroExport.service
systemctl daemon-reload
systemctl reset-failed
echo 'Uninstallation of HoymilesZeroExport.service completed'
fi
cat << EOF | tee /etc/systemd/system/HoymilesZeroExport.service
[Unit]
Description=HoymilesZeroExport Service
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=${SCRIPT_DIR}/HoymilesZeroExport.py
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable HoymilesZeroExport.service
systemctl start HoymilesZeroExport.service
systemctl status HoymilesZeroExport.service
echo 'Installation of HoymilesZeroExport completed'