Execute a call to an API before reboot and after boot
I want to call an api with curl before reboot or shutdown -r now and after boot for maintenance propose, only when I call reboot manually and came out with this.
It works, but it's calling the api on shutdown now/halt too.
The ideia it to call this api to disable monitoring on reboot and enable it on boot.
[Unit] Description = Maintenance mode Before = reboot.target After = network-online.target boot-complete.target Requires = network-online.target Conflicts = halt.target poweroff.target [Service] User = root Group = root Type = oneshot RemainAfterExit = yes ExecStart = "/usr/local/bin/maintenance-on.sh" ExecStop = "/usr/local/bin/maintenance-off.sh" [Install] WantedBy = multi-user.target