shutdown/reboot suggestion

Bill Moran wmoran at
Mon Aug 11 12:25:33 UTC 2008

"Michael Grant" <mgrant at> wrote:
> I have such a script, I put it in /bin/require_hostname and symlinked
> shutdown, halt, reboot, fastboot, and fasthalt to this script:
> #!/bin/sh
> if [ "$1" = `hostname` ]; then
>         shift
>         exec /sbin/`basename $0` $@
> else
>         echo "For your protection, use: $0 hostname ..."
> fi
> I realize a lot of people have their own tricks and habits for
> avoiding such stupidity, but what is the problem of fixing the problem
> globally by getting these commands to take a hostname argument?
> This could certainly be the basis for another thread (and this is
> perhaps not the correct list), but is there some way to request a
> modification across all the unix/linux distributions out there to
> maintain some level of consistency across them?  Except for Posix, is
> there some overall list which deals with this conformity of all these
> sibling platforms?

Changing that command globally is a huge undertaking.  First off, it
will break every single script out there that uses those commands, thus
causing a worldwide riot.

Second, it's not compliant with POSIX, thus we reopen the wound of The
Unix Wars.

Third, it's not a very good solution.  Off the top of my head:
1) What happens to machines that don't have a hostname yet?  (during
   install for example) you can't shut them down?
2) Which hostname?  The FQDN, which can be REALLY long in many cases.
   Or the short name, which can be duplicated (how many web00s do I
   have in various facilities across the country?) so then doesn't solve
   the problem.
3) I'm not having the problem you describe, thus you're asking me to
   type more (possibly a LOT more) to solve a problem I don't have.
4) It breaks every single script out there that uses those commands
5) Tied in with #3, there's a REALLY easy way to fix this for those
   out there who are having trouble with it.

I'm unclear why you find the mechanisms built into the system that allow
you to fix this yourself to be inadequate?

Bill Moran

More information about the freebsd-questions mailing list