-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_daemon.sh
executable file
·50 lines (38 loc) · 1.08 KB
/
setup_daemon.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
#!/bin/sh
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
if python3.10 --version 2>&1; then
echo Python 3.10 detected
else
echo Python 3.10 not found! Exiting...
exit 1
fi
if [ ! -d "$SCRIPTPATH/.venv/" ]; then
echo creating python virtual env
python3.10 -m venv $SCRIPTPATH/.venv
fi
echo Installing dependencies...
$SCRIPTPATH/.venv/bin/python -m pip install -r $SCRIPTPATH/req.txt
echo Creating coolbot service daemon
echo "[Unit]
Description=Coolbot VK daemon service
[Service]
Type=idle
User=root
WorkingDirectory=$SCRIPTPATH
ExecStart=$SCRIPTPATH/.venv/bin/python coolbot.py
[Install]
WantedBy=multi-user.target" | sudo tee --append /etc/systemd/system/coolbot.service
echo Reloading systemctl daemon
sudo systemctl daemon-reload
while true; do
read -p "Do you wish to enable coolbot at every system boot? " yn
case $yn in
[Yy]* ) sudo systemctl enable coolbot.service; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo Starting a coolbot service
sudo systemctl start coolbot.service
echo Done! Coolbot is running