Help needed modifying shutdown scripts
Dominic Bishop
dom at bishnet.net
Mon Feb 23 04:29:27 PST 2004
I am trying to use some custom startup+shutdown scripts to control a Belkin
UPS using the nut utility. Essentially to achieve what is shown in point 4
of
http://quasar.mathstat.uottawa.ca/~selinger/ups/belkin-universal-ups.html
Before continuing, here is the output of uname -a:
FreeBSD magellan.dom.bishnet.net 5.2.1-RC2 FreeBSD 5.2.1-RC2 #1: Sun Feb 22
02:52:35 GMT 2004
dom at dom.bishnet.net:/u2/usr/obj/u2/usr/src/sys/MAGELLAN
i386
The startup section is working fine, I created my own script in /etc/rc.d
and
it runs at the correct time.
The shutdown bit however is causing me problems, I inserted my code into
rc.shutdown under the section headed "# Insert other shutdown procedures
here"
Since FreeBSD doesn't seem to remount disks read-only during this script I
first unmounted all unnecessary partitions and then made sure /, /usr, /var
were all mounted read-only, as these are needed for the UPS driver to run.
The UPS driver runs as expected and sits there monitoring battery power,
however I get a fair few processes exiting on signal 11 which is worrying
and then more worrying is that it kills the driver, and completes halting
the
system. Once in this state the system will never come back when AC power
returns which is of course not desirable.
Here is console output from around the point of the driver starting onwards:
(Currently the script calls mount with no arguments so I could check that
the mounts were as I expected, hence the mountpoint entries)
pid 478 (mountd), uid 0: exited on signal 11
/dev/ar0s1a on / (ufs, local, read-only)
devfs on /dev (devfs, local)
procfs on /proc (procfs, local)
/dev/ar0s1f on /usr (ufs, local, read-only)
/dev/ar0s1d on /var (ufs, local, read-only)
Waiting for AC power, or for UPS batteries to run out...
Network UPS Tools - Belkin 'Universal UPS' driver 0.06 (1.5.13)
Connecting to UPS...
pid 542 (ntpd), uid 0: exited on signal 11
UPS is on battery, battery level: 20%
pid 511 (usbd), uid 0: exited on signal 11
pid 801 (logger), uid 0: exited on signal 11
UPS is on battery, battery level: 17%
pid 394 (rpcbind), uid 0: exited on signal 11
UPS is on battery, battery level: 15%
pid 806 (identd), uid 0: exited on signal 11
UPS is on battery, battery level: 12%
pid 769 (moused), uid 0: exited on signal 11
pid 563 (sshd), uid 0: exited on signal 11
pid 499 (rpc.lockd), uid 1: exited on signal 11
pid 385 (named), uid 53: exited on signal 11
FWaiting (max 60 seconds) for system process `vnlru' to stop...stopped
Waiting (max 60 seconds) for system process `bufdaemon' to stop...stopped
Waiting (max 60 seconds) for system process `syncer' to stop...stopped
syncing disks, buffers remaining...
done
Uptime: 6m27s
GEOM: destroy disk twed0 dp=0xc616200c
twed0: detached
Shutting down ACPI
The operating system has halted.
Most importantly can anyone tell me how to stop the system being shutdown
before rc.shutdown terminates? (the UPS driver stays in foreground until the
battery runs out, unless AC power returns in which case it calls reboot)
I'm guessing that all the sig 11s are due to filesystems being mounted read
only, but what I don't understand is why these processes are even still
running?
All of these processes are controlled by rc.d and looking at rc.shutdown
they
should have been stopped before the section I've placed my code is reached.
ie in the section:
# Determine the shutdown order of the /etc/rc.d scripts,
# and perform the operation
This got me curious so I created a simple test script which was a copy of
the
original rc.shutdown with the watchdog timer bits removed and the running of
rc.d script shutdown set to simply echo the command instead, when run it
output
this:
run_rc_script /etc/rc.d/exim stop
run_rc_script /etc/rc.d/inetd stop
run_rc_script /etc/rc.d/localpkg stop
run_rc_script /etc/rc.d/jail stop
run_rc_script /etc/rc.d/cron stop
run_rc_script /etc/rc.d/local stop
run_rc_script /etc/rc.d/nfsclient stop
run_rc_script /etc/rc.d/ipfs stop
run_rc_script /etc/rc.d/random stop
run_rc_script /etc/rc.d/swap1 stop
.
This seems to be a rather small subset of the scripts in rc.d that are run
on
startup, and notably excludes commands to stop all the processes I was
getting
sig 11s from. Am I missing something here?
So in summary, the most important thing I wish to fix is to stop the OS from
halting whilst the UPS driver is still running as at the moment it leaves me
with the possibility of the system not resuming unattended.
The less important aspect is stopping the sig 11s from those processes as it
would be nice not to get a whole bunch of .core files in my / ;-)
However I can live with them if I have to.
Any suggestions?
Regards,
Dominic Bishop
More information about the freebsd-questions
mailing list