Skip to content

Instantly share code, notes, and snippets.

@george-hawkins
Created April 19, 2017 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save george-hawkins/21f98e4061fed8d4bb3d9183093c0726 to your computer and use it in GitHub Desktop.
Save george-hawkins/21f98e4061fed8d4bb3d9183093c0726 to your computer and use it in GitHub Desktop.
[Unit]
Description=Broadcast triggered shutdown
After=network.target
# To install:
# $ sudo apt-get install socat
# $ sudo chown root:root broadcast-shutdown.service
# $ sudo mv broadcast-shutdown.service /etc/systemd/system
# $ sudo systemctl daemon-reload
# $ sudo systemctl enable broadcast-shutdown
# $ sudo systemctl start broadcast-shutdown
#
# To trigger shutdown, from another machine on the same subnet, enter the following command then enter bye:
#
# $ socat STDOUT UDP4-DATAGRAM:255.255.255.255:6666,broadcast
# bye
[Service]
ExecStart=/usr/bin/socat UDP4-RECVFROM:6666,broadcast,fork SYSTEM:'hostname; shutdown now'
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment