Reboot Fail Figured Out
It's happened a few times that I've (dunderheadedly) reboot this server remotely and it fails to complete. I've figured out why, and created a workaround.
It seems that the "reboot" command has been broken for a little while, and in the last Ubuntu update they've "fixed" it. Previously the command "reboot now" worked, starting a reboot immediately. It turns out that "reboot" always reboots immediately, isn't the right way to do a reboot, and doesn't take a parameter "now" as a valid parameter.
What happens after the fix is that the "now" messes up the "reboot" command and sets the machine into a single-user mode. Technically the "now" becomes a reboot command for the "reboot" command, and "now" is nonsense in this context, so the reboot gets interrupted after the multi-user mode stops.
What should happen, I've since learned, is that "shutdown -r now" should be called. It sounds like that's what "reboot" is supposed to be doing, but when there's a boot command it does something different.
To mitigate my errant "reboot now" ways I've added this little script to help prevent hanging systems.
#! /bin/bash pass="" for param do case "$param" in now) echo "Probably meant to do 'shutdown -r now'" /sbin/shutdown -r +1 exit ;; *) pass="${pass} ${param}" ;; esac done /sbin/reboot $pass
Some script savvy folk will surely find more terse ways to do this, but it works for now. The echo isn't really necessary, but helps me remember I've done it wrong, and the extra minute (instead of "now") gives me a chance to see it (and as I was testing it...stop it...). I should probably consider always just executing /sbin/shutdown, as that's really the only thing I do, but I figure since the manpage for reboot says that's what it does without parameters, that's what I'll let it do.
I added this to /usr/local/sbin as that's the first folder in my sudoers' path, so it will be hit before the /sbin/reboot. Tested, and works! Here's to no more failed reboots!