Hello Alan, thanks for the reply, but I think your reply is about "normal" shutdown scripts used to terminate a service properly.
Would this also work for scripts which change the shutdown logic of the OS itself? I mean not shutting down a specific service and ending my script afterwards - I need to insert a sleeping watchdog loop which makes sure that the system forcedly reboots in certain circumstances (explained in my original forum web-post and reiterated below) - and I don't want this loop killed by "killall -9" lookalike which used to be in /etc/rc0 and may now be in svc.startd or elsewhere. This logic must keep running until the OS uptime ends one way or another. Back in Solaris 8/9/10, the /etc/rc0 script was THE logic which led to system halt or reboot (sans the reboot/halt/uadmin commands themselves). On the way it called the shutdown scripts, issued killall for the leftover processes, and unmounted the filesystems, and reported 'The system is down.' And in my case - after all that it spawned the watchdog loop, immune to killall because there were no killalls after that. In OpenSolaris and later /etc/rc0 only calls the legacy shutdown scripts, while the later half of the logic is gone elsewhere (and I'm trying to discover - where). Here's the pre-history of my question after all - for those who don't like to follow links (I had little hope for that anyway ;) : === Hello all, A long while ago I made a package for NUT (Network UPS Tools) used in some of our projects since Solaris 8. Part of this packaging involved changes to "/etc/rc0" scripts, with variants for Solaris 8 and 9, and for Solaris 10 with SMF, example of the patch changes is attached below. Currently on another occasion I want to add a watchdog cycle to force rebooting/halting with "uadmin" if the pool export-on-shutdown hangs, as happens on my home test box too often. The important part of these patches is adding a watchdog to the shutdown procedure, so that if it does not complete in a timely fashion for any reason (in case of UPS - line power returns during shutdown/halt, and the UPS never dies), and in such event the OS is forcibly rebooted. By adding the watchdog to "/etc/rc0" we could avoid the watchdog being killed as any other system process (it is spawned after the kills). +++ Unlike the UPS case, for the hang during pool-exports problem, apparently, the watchdog must be a background cycle. Otherwise the problem area is the same. These patches no longer work for OpenSolaris and its "SunOS 5.11" descendants, because all of that shutdown logic is no longer in the scripts, but maybe in the binary svc.startd?.. Anyway, what is the proper way to add such special shutdown handlers to modern OpenSolaris versions and its kin? Example of watchdog cycle in "/etc/rc0" for our NUT integration: # cat /etc/ups/rc0.patch.sol10 --- rc0.orig Sat Jan 22 02:27:33 2005 +++ rc0 Thu Sep 28 16:06:15 2006 @@ -16,6 +16,16 @@ PATH=/usr/sbin:/usr/bin +# File used by NUT if shutting down because of UPS event +UPSFLAG=/etc/ups/killpower +# How long we wait after halt before reboot +UPSWAIT=600 +# Flag used by us to trigger waiting +_UPSPOWERDOWN=0 + +[ -f "$UPSFLAG" ] && _UPSPOWERDOWN=1 +[ x"$_UPSPOWERDOWN" = x1 ] && echo "UPS powering off, will wait and reboot in the end" + if [ -z "$SMF_RESTARTER" ]; then echo "Cannot be run outside smf(5)" exit 1 @@ -71,3 +81,11 @@ [ -x /usr/lib/acct/closewtmp ] && /usr/lib/acct/closewtmp /sbin/sync; /sbin/sync; /sbin/sync + +if [ x"$_UPSPOWERDOWN" = x1 -a -x /etc/ups/reboot ]; then + echo "Counting down to restart in case UPS line power is back: waiting $UPSWAIT sec" + sleep "$UPSWAIT" + ( echo "Syncing disks..."; /sbin/sync ) & + sleep 3 + echo "Rebooting system now" + /etc/ups/reboot -lq +fi + === Thanks, //Jim -- This message posted from opensolaris.org _______________________________________________ sysadmin-discuss mailing list sysadmin-discuss@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/sysadmin-discuss