-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.sh
31 lines (22 loc) · 890 Bytes
/
setup.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
#!/bin/bash
pushd /opt/solis2mqtt
echo "### Installing pip3 ###"
apt-get -y install python3 python3-pip
echo "### Installing requirements ###"
pip3 install -r /opt/solis2mqtt/requirements.txt
echo "### Creating config file if no config exists ###"
[ ! -f config.yaml ] && cp /opt/solis2mqtt/config.yaml.minimal /opt/solis2mqtt/config.yaml
echo "### Creating service user ###"
addgroup --system solis2mqtt
adduser --system --no-create-home --ingroup solis2mqtt solis2mqtt
# to get access to /dev/ttyUSB*
usermod -a -G dialout solis2mqtt
echo "### Changing ownership ###"
chown -R solis2mqtt:solis2mqtt /opt/solis2mqtt
echo "### Creating run directory ###"
mkdir /run/solis2mqtt
chown -R solis2mqtt:solis2mqtt /run/solis2mqtt
echo "### Setting up systemd ###"
cp /opt/solis2mqtt/provisioning/etc/systemd/system/solis2mqtt.service /etc/systemd/system/
systemctl enable solis2mqtt
popd