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).

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 Klimov
-- 
This message posted from opensolaris.org
_______________________________________________
sysadmin-discuss mailing list
sysadmin-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/sysadmin-discuss

Reply via email to