-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-service.sh
26 lines (19 loc) · 1.03 KB
/
setup-service.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
#!/bin/bash
cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null
if test ! -f "config.json"; then
echo "config.json not found."
echo "Please set up the configuration according to your tado setup. Read README.md for further information."
exit 1
fi
echo "Installing pip requirements..."
python3 -m pip install -r requirements.txt || { echo 'pip install failed' ; exit 1; }
echo "Preparing service..."
sed "s#{INSTALL_DIR}#$(pwd)#" tado-control.service > /tmp/tado-control.service_TMP || { echo 'sed command failed' ; exit 1; }
echo "Setting up service..."
sudo cp /tmp/tado-control.service_TMP /etc/systemd/system/tado-control.service || { echo 'copy to /tmp failed' ; exit 1; }
sudo systemctl daemon-reload || { echo 'systemctl reload failed' ; exit 1; }
sudo systemctl start tado-control || { echo 'starting the service failed' ; exit 1; }
sudo systemctl enable tado-control || { echo 'enabling the service failed' ; exit 1; }
rm /tmp/tado-control.service_TMP
sudo systemctl status tado-control
echo "Systemd service created successfully."