-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathupdate_daemon
61 lines (50 loc) · 1.71 KB
/
update_daemon
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
59
60
61
#!/bin/sh
if [ $(whoami) != 'root' ]; then
echo -e "\nInsuffiecent Rights. (Vous devez avoir les droits super-utilisateur pour executer $0)"
exit 1;
fi
# Check Python 3 is installed
if [[ ! $(which python3) ]]; then
echo "Python 3 is required"
exit 1
fi
echo "Creating service user"
SERVICE_USER='maestro_service'
SERVICE_GROUP='maestro_service'
id -g $SERVICE_GROUP >& /dev/null
if [ $? -eq 1 ]; then
groupadd $SERVICE_GROUP
fi
id -u $SERVICE_USER >& /dev/null
if [ $? -eq 1 ]; then
useradd -r -s /bin/false maestro_service
usermod -g $SERVIC_GROUP $SERVICE_USER
fi
echo "Stopping service (Arret du service maestro)"
systemctl stop maestro.service
echo "Installation des dépendances"
apt-get update
apt-get install build-essential \
libsystemd-dev
/usr/bin/python3 -m pip install paho-mqtt
/usr/bin/python3 -m pip install websocket-client
/usr/bin/python3 -m pip install systemd-python
/usr/bin/python3 -m pip install psutil
echo "Copy files. (Copie des fichiers necessaires)"
if [ ! -d "/usr/local/lib/maestro_service" ];then
mkdir -p /usr/local/lib/maestro_service
chown -R root:$SERVICE_GROUP /usr/local/lib/maestro_service
fi
cp _config_.py /usr/local/lib/maestro_service
cp commands.py /usr/local/lib/maestro_service
cp messages.py /usr/local/lib/maestro_service
cp maestro.py /usr/local/lib/maestro_service
if [ -d "/usr/local/lib/maestro_service" ];then
chown -R root:$SERVICE_GROUP /usr/local/lib/maestro_service/*
chmod -R 0744 /usr/local/lib/maestro_service/*
fi
cp maestro.service /etc/systemd/system
chmod a+x /etc/systemd/system/maestro.service
echo "Restarting service. (Redemarage du service, la fenetre pourra etre fermee.)"
systemctl --system daemon-reload
systemctl restart maestro.service