[plug] Accidental reboot
Nick Bannon
nick at ucc.gu.uwa.edu.au
Tue May 10 18:27:58 WST 2011
On Tue, May 10, 2011 at 03:21:12PM +0800, Brad Campbell wrote:
> I have a number of machines I routinely use, and a number of virtual
> machines inside those. I've lost count of the number of times I've
> run "sudo reboot" thinking I was logged into a guest and taken down
> the host server.
[...]
You molly! Yes, it happens, but the best protection against any accidental
command I've had is to give machines a friendly, unique name which shows
up in the prompt. (Or Tim's coloured terminals?) "ensor", not "bkmac"
or "srv.homea".
That and the habit of a slight pause before doing dangerous actions such
as shutdown, rm, or even cp if you don't have a "cp -i" alias for that.
> [...] Put together a quick /usr/local/bin/reboot
> #!/bin/bash
> echo Surprise!
Handy! There's a packaged solution we use at the UCC, in the form of "molly-guard":
http://www.google.com.au/search?q=molly-guard
Package: molly-guard
Description: protects machines from accidental shutdowns/reboots
The package installs a shell script that overrides the existing
shutdown/reboot/halt/poweroff commands and first runs a set of scripts, which
all have to exit successfully, before molly-guard invokes the real command.
.
One of the scripts checks for existing SSH sessions. If any of the four
commands are called interactively over an SSH session, the shell script
prompts you to enter the name of the host you wish to shut down. This should
adequately prevent you from accidental shutdowns and reboots.
.
This shell script passes through the commands to the respective binaries in
/sbin and should thus not get in the way if called non-interactively, or
locally.
Nick.
--
Nick Bannon | "I made this letter longer than usual because
nick-sig at rcpt.to | I lack the time to make it shorter." - Pascal
More information about the plug
mailing list