34 lines
761 B
Bash
Executable file
34 lines
761 B
Bash
Executable file
#!/bin/bash
|
|
chmod +x run.sh
|
|
# If first arg is of form :n it will set DISPLAY to :n. Default is :0
|
|
dsp_prefix=:
|
|
dsp=:0
|
|
# if [[ -n "${1+x}" ]]; then
|
|
if [[ $1 == $dsp_prefix* ]]; then
|
|
dsp="$1"
|
|
shift
|
|
fi
|
|
# fi
|
|
args="$*"
|
|
rm -f fwledmonitor.service || true
|
|
sed -i "s#led_system_monitor.py.*\$#led_system_monitor.py ${args}#" run.sh
|
|
cat <<EOF >>./fwledmonitor.service
|
|
[Unit]
|
|
Description=Framework 16 LED System Monitor
|
|
After=network.service
|
|
|
|
[Service]
|
|
Environment=DISPLAY=${dsp}
|
|
Type=simple
|
|
Restart=always
|
|
WorkingDirectory=$PWD
|
|
ExecStart=sh -c "'$PWD/run.sh'"
|
|
|
|
[Install]
|
|
WantedBy=default.target
|
|
EOF
|
|
|
|
sudo systemctl stop fwledmonitor
|
|
sudo cp fwledmonitor.service /lib/systemd/system
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable fwledmonitor
|