Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions listen-for-shutdown.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Listen for shutdown service at GPIO3
After=syslog.target network.target

[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/local/bin/listen-for-shutdown.py
PIDFile=/run/listen-for-shutdown.pid

[Install]
WantedBy=multi-user.target
21 changes: 21 additions & 0 deletions script/install.systemd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#! /bin/sh

set -e

cd "$(dirname "$0")/.."

echo "=> Installing shutdown listener...\n"
sudo cp listen-for-shutdown.py /usr/local/bin/
sudo chmod +x /usr/local/bin/listen-for-shutdown.py

echo "=> Installing shutdown listener systemd service...\n"
sudo cp listen-for-shutdown.service /etc/systemd/system/
sudo chmod +x /etc/systemd/system/listen-for-shutdown.service

echo "=> Starting shutdown listener...\n"
sudo systemctl daemon-reload
sudo systemctl enable listen-for-shutdown.service
sudo systemctl start listen-for-shutdown.service
sudo systemctl status listen-for-shutdown.service

echo "Shutdown listener installed.\n"
18 changes: 18 additions & 0 deletions script/uninstall.systemd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /bin/sh

set -e

cd "$(dirname "$0")/.."

echo "=> Stopping shutdown listener...\n"
sudo systemctl stop listen-for-shutdown.service

echo "=> Removing shutdown listener...\n"
sudo systemctl disable listen-for-shutdown.service
sudo systemctl status listen-for-shutdown.service
sudo rm -f /etc/systemd/system/listen-for-shutdown.service
sudo rm -f /usr/local/bin/listen-for-shutdown.py

echo "=> Reloading systemd services...\n"
sudo systemctl daemon-reload
echo "Shutdown listener uninstalled.\n"