-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall_service.sh
More file actions
executable file
·44 lines (35 loc) · 866 Bytes
/
install_service.sh
File metadata and controls
executable file
·44 lines (35 loc) · 866 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
#!/bin/sh -e
[ $(id -u) != "0" ] || {
echo "Don't run this as root!" >&2
exit 1
}
[ -x "$(which systemctl)" ] || {
echo "systemctl not found. Are you not using Systemd?" >&2
exit 1
}
dir=$(dirname $(realpath $0))
config=
[ -z $1 ] || {
config=$(realpath $1)
}
echo "# Installing service file for ConnectCam..."
sudo tee /etc/systemd/system/connectcam.service > /dev/null << EOF
[Unit]
Description=Minimalistic webcam manager for Prusa Connect
After=network-online.target
StartLimitInterval=200
StartLimitBurst=5
[Service]
User=$(id -u)
Group=$(id -g)
WorkingDirectory=$dir
ExecStart=/usr/bin/python3 $dir/connectcam.py $config
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable connectcam.service
echo "# Starting ConnectCam service..."
sudo systemctl start connectcam.service