Wednesday, 22 May 2019

Systemd Service only initiates at shutdown ( no reboot ) and keeps network intact

# the %H is the env var for systemd file which is $(hostname) for bash

[Unit]
Description=Run a Bash script at shutdown
DefaultDependencies=no
Wants=network-online.target
After=network-online.target
Before=poweroff.target halt.target

[Service]
ExecStart=/usr/bin/curl -X POST 'http://box21.ara.ac.nz:32446/query?db=telegraf' --data-urlencode "q=DROP SERIES WHERE host = '%H'"
Type=oneshot
RemainAfterExit=yes

[Install]
WantedBy=poweroff.target halt.target 

No comments:

Post a Comment