Debounce, Service
This commit is contained in:
+20
-5
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Generate systemd service file
|
||||
|
||||
set -e
|
||||
|
||||
FILE=/etc/systemd/system/buttond.service
|
||||
|
||||
button=$(realpath button.py)
|
||||
@@ -10,20 +12,33 @@ if [[ ! -f $button ]]; then
|
||||
fi
|
||||
|
||||
vpython=$(realpath venv/)/bin/python
|
||||
if [[ ! -e $vpython ]]; then
|
||||
if [[ ! -x $vpython ]]; then
|
||||
echo venv not found
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > "$FILE" << EOF
|
||||
[Unit]
|
||||
Description = buttonctl
|
||||
Description=Button Service 1. OG
|
||||
StartLimitIntervalSec=60s
|
||||
StartLimitBurst=10
|
||||
|
||||
[Service]
|
||||
Type = simple
|
||||
ExecStart = $vpython $button
|
||||
Type=exec
|
||||
ExecStart=$vpython -u $button
|
||||
User=root
|
||||
WorkingDirectory=$(dirname "$button")
|
||||
Restart=on-failure
|
||||
RestartSec=3s
|
||||
NoNewPrivileges=yes
|
||||
PrivateTmp=yes
|
||||
ProtectSystem=full
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Alias=buttond.service
|
||||
EOF
|
||||
|
||||
service=$(basename "$FILE")
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now "$service"
|
||||
systemctl --no-pager status "$service"
|
||||
|
||||
Reference in New Issue
Block a user