-
Notifications
You must be signed in to change notification settings - Fork 0
/
startService.sh
54 lines (45 loc) · 1.5 KB
/
startService.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
48
49
50
51
52
53
54
#!/usr/bin/env bash
SUMP_SERVICE_FILE=sumpPump.service
YELLOW='\033[1;33m'
WHITE='\033[0m'
function cloneServiceFiles {
if [[ -d "/home/pi/SumpPumpOverflow" ]]
then
echo -e "${YELLOW}---------------Service Folder Exists---------------${WHITE}"
cd /home/pi/SumpPumpOverflow
git pull
else
echo -e "${YELLOW}---------------Cloning Service---------------${WHITE}"
cd /home/pi/
git clone https://github.com/jonny561201/SumpPumpOverflow.git /home/pi/SumpPumpOverflow
fi
}
function installDependencies {
echo -e "${YELLOW}---------------Installing Dependencies---------------${WHITE}"
pip3 install -Ur requirements.txt
}
function stopService {
echo -e "${YELLOW}---------------Stopping Service---------------${WHITE}"
sudo systemctl stop ${SUMP_SERVICE_FILE}
sudo rm /lib/systemd/system/${SUMP_SERVICE_FILE}
}
function copyServiceFile {
echo -e "${YELLOW}---------------Creating SystemD---------------${WHITE}"
sudo chmod 644 ${SUMP_SERVICE_FILE}
sudo yes | sudo cp ${SUMP_SERVICE_FILE} /lib/systemd/system/${SUMP_SERVICE_FILE}
}
function configureSystemD {
echo -e "${YELLOW}---------------Configuring SystemD---------------${WHITE}"
sudo systemctl daemon-reload
sudo systemctl enable ${SUMP_SERVICE_FILE}
}
function restartDevice {
echo -e "${YELLOW}---------------Rebooting Device---------------${WHITE}"
sudo reboot
}
stopService
cloneServiceFiles
installDependencies
copyServiceFile
configureSystemD
restartDevice