Created
April 19, 2017 14:07
-
-
Save george-hawkins/21f98e4061fed8d4bb3d9183093c0726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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