30 lines
471 B
Bash
30 lines
471 B
Bash
#!/usr/bin/env bash
|
|
# Generate systemd service file
|
|
|
|
FILE=/etc/systemd/system/buttond.service
|
|
|
|
button=$(realpath button.py)
|
|
if [[ ! -f $button ]]; then
|
|
echo button.py not found
|
|
exit 1
|
|
fi
|
|
|
|
vpython=$(realpath venv/)/bin/python
|
|
if [[ ! -e $vpython ]]; then
|
|
echo venv not found
|
|
exit 1
|
|
fi
|
|
|
|
cat > "$FILE" << EOF
|
|
[Unit]
|
|
Description = buttonctl
|
|
|
|
[Service]
|
|
Type = simple
|
|
ExecStart = $vpython $button
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
Alias=buttond.service
|
|
EOF
|