-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup.sh
58 lines (47 loc) · 1.91 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
red=`tput setaf 9`
purple=`tput setaf 4`
green=`tput setaf 10`
yellow=`tput setaf 11`
reset=`tput sgr0`
checkmark="${green}✔${reset}"
cross="${red}✖${reset}"
printf "\033c"
echo "${purple}"
echo " _____ _ _ _ _____ _____ _____ _____ "
echo "| __|___ ___ _ _ _| |_|_| |_ | | |_ _|_ _|"
echo "| | | _| . | | | | '_| | _| | | | | | | | | | | "
echo "|_____|_| |___|_____|_,_|_|_| |_|_|_|__ _| |_| |_| "
echo " |__| "
echo "${reset}"
printf "More info at: 🌿🌱 ${green}https://link.studionoorderlicht.nl/mqtt${reset} 🌱🌿\n\n"
printf "Do you want to install/uninstall the watcher service? (i/u/Cancel): "
read answer
if [ "$answer" != "${answer#[Uu]}" ] ;then
sudo systemctl stop growkit-mqtt.service
echo "${checkmark} Stopped service if running"
sudo systemctl disable growkit-mqtt.service
echo "${checkmark} Disabled service from systemctl"
sudo systemctl daemon-reload
sudo systemctl reset-failed
echo "${checkmark} Reloaded systemctl"
elif [ "$answer" != "${answer#[Iiy]}" ] ;then
sudo chmod +x watcher.py
printf "\n${checkmark} Made watcher.py executable"
sudo cp service /etc/systemd/system/growkit-mqtt.service
printf "\n${checkmark} Installed service"
sudo systemctl daemon-reload
printf "\n${checkmark} Reloaded systemctl\n"
printf "\nDo you want to run the service at the boot of your system? (Y/n): "
read answer
if [ "$answer" != "${answer#[Nn]}" ] ;then
printf "\n${cross} Skipping boot configuration"
else
sudo systemctl enable growkit-mqtt.service
printf "\n${checkmark} Installed the watcher as startup service"
fi
sudo systemctl start growkit-mqtt.service
printf "\n${checkmark} Watcher service started systemctl\n\n"
else
printf "\n${cross} Canceling setup...\n\n"
fi