I have a systemd service that works for what I want, which is to run a script when the system shuts down. However, this also runs on a reboot which is not what I want.
This is the service file:
[Unit]
Description=Shutdown script
Requires=network.target
Before=poweroff.target halt.target
DefaultDependencies=no
[Service]
Type=oneshot
TimeoutSec=5
RemainAfterExit=true
User=sysadm
Group=sysadm
ExecStart=/bin/true
ExecStop=/usr/bin/myscript.sh
[Install]
WantedBy=multi-user.target systemd-halt.service systemd-poweroff.service
Is there any way to make this work for shutdowns only?