I have a Solaris 10 test guest logical domain (LDom). I plan to have the network on this be reconfigured before rebooting using a startup script in /etc/rc0.d
.
At the moment, when the system boots, everything in the startup script is run as I want it to be, except that the reboot does not occur.
I have created a test script, and stripped it of everything except the essentials:
#!/sbin/sh
# MAIN
case "$1" in
start)
if [ -f /etc/DR_Network_Configured ]; then
exit 0
else
touch /etc/DR_Network_Configured
reboot
fi
exit 0
;;
*)
echo "Usage: $0 { start }"
exit 1
;;
esac
exit 0
If I run the script from the command line, /etc/rc0.d/S99testing start
, the file /etc/DR_Network_Configured
is created and the system immediately reboots, i.e. the desired behaviour.
However, if I remove the file /etc/DR_Network_Configured
, shut the system down, and boot it again, the file /etc/DR_Network_Configured
gets recreated by the script during boot, but no subsequent reboot occurs.
Is there a fail-safe mechanism to stop startup scripts from potentially causing infinite reboots? If so, is there a way around this?
Best Answer
I have tested moving this script from
/etc/rc0.d
to/etc/rcS.d
,/etc/rc1.d
,/etc/rc2.d
and/etc/rc3.d
with the following results:/etc/rc0.d
- /etc/DR_Network_Configured is created, but no reboot occurs.To summarise, when the system is booted to its default (
milestone/multi-user-server:default
, similar to run-level 3), it executes startup scripts located in/etc/rc0.d
,/etc/rcS.d
,/etc/rc2.d
and/etc/rc3.d
, but not/etc/rc1.d
.The reboot and init commands do not work when run from a startup script in
/etc/rc0.d
,/etc/rcS.d
(and possibly/etc/rc1.d
although I can't confirm this as the startup script in this directory never ran). They do work when run from startup scripts in/etc/rc2.d
and/etc/rc3.d
.I imagine that this is designed to prevent a system from constantly rebooting. Should an erroneous startup script in
/etc/rc2.d
or/etc/rc3.d
put the system into an infinite reboot loop, then the system can be fairly easily be rebooted to the single-user milestone and the offending startup script disabled rather than having to locate alternate boot media to boot off, mount the root volume/disk and disable the offending script.Based on the above, I have modified my network reconfiguration script as follows:
/etc/rc0.d
to change the network settings./etc/rc2.d/S99reboot
is created which will reboot the system./etc/DR_Network_Configured
file exists, and/etc/rc2.d/S99reboot
exists, then remove the latter to avoid the system constantly rebooting.My relevant code is: