-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·48 lines (35 loc) · 863 Bytes
/
install.sh
File metadata and controls
executable file
·48 lines (35 loc) · 863 Bytes
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
#!/usr/bin/env bash
WORKDIR=$(dirname "$(realpath "$0")")
SERVICE="python-ip-announcer"
TARGET="/usr/bin/$SERVICE"
echo "Installing $SERVICE..."
if [ $(whoami) != "root" ]
then
echo "Please run as root!"
exit 1
fi
apt update
apt install python3 python3-paho-mqtt python3-netifaces --yes
cp $WORKDIR/$SERVICE $TARGET
chmod +x $TARGET
echo "Create systemd service file"
echo "[Unit]
Description=$SERVICE daemon
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
Restart=never
StartLimitIntervalSec=5
ExecStart=$(which python3) $TARGET
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/$SERVICE.service
echo "Reload daemon"
systemctl daemon-reload
echo "Enable $SERVICE"
systemctl enable $SERVICE.service
echo "Restart $SERVICE"
systemctl restart $SERVICE.service
echo "Done."
systemctl status $SERVICE.service