As in the old nextboot.sh script:
- First write everything to a tempfile instead of /boot/nextboot.conf.
- fsync() the tempfile before renaming it to nextboot.conf.
While here fix handling of -f in getopt().
Fixes: fd6d47375a78 ("rescue,nextboot: Install nextboot as a link to reboot, rm nextboot.sh")
This is a change in behavior (here and elsewhere)... any errors in the old script in crwating nextboot mean we'd not fail to reboot anyway...
It may be more correct, but now will result in different behavior for, say, readonly /. I was torn on it, but didn't want to break automated scripting that depends on it since we'd fail with the system still running when we were forcing a reboot even if we couldn't write nextboot...