I thought I would post this to get some comments.
The rc scripts do a . (aka source) import of /etc/rc.conf which means any syntax error makes the machine unusable.
A simple `
Is there a way that /sbin/reboot could do that test and ask if it should reboot a broken system?
Another option would be fix
Simply sourcing the rc.conf in a subshell does work:
Will claim "Bad2" if given bad input such as:
Perhaps the best option is
The problem is reboot is sometimes scripted with no human interaction so "rc.conf is borked, no reboot for you" isn't an option and splitting the rc.conf needs safe place to do it that is writable very early in the boot process way before things are set up nice and sane.
The rc scripts do a . (aka source) import of /etc/rc.conf which means any syntax error makes the machine unusable.
A simple `
sh /etc/rc.conf` will show these errors but kills the shell that runs it.Is there a way that /sbin/reboot could do that test and ask if it should reboot a broken system?
Another option would be fix
rc to do checking and fallback to something like /etc/rc.conf.safe or a line by line parsing to keep some of the system running like bringing up interfaces and sshd. Most rc.conf files could be split -l 1 and then sourced independently. Simply sourcing the rc.conf in a subshell does work:
Code:
#!/bin/sh
`. ./rc.test || echo bad1` || echo Bad2
Code:
#syntax error double double quote at end:
foo_enable="YES""
Perhaps the best option is
if `. rc.conf` then . rc.conf else . rc.conf.safe? Or split and do that per line?The problem is reboot is sometimes scripted with no human interaction so "rc.conf is borked, no reboot for you" isn't an option and splitting the rc.conf needs safe place to do it that is writable very early in the boot process way before things are set up nice and sane.