Saturday, April 07, 2007

apcupsd in Debian Sarge and Etch

There seem to be prolems with apcupsd in Debian Sarge (and Etch): the machine shuts down, but will not restart when the power comes back.

One reason would be that the halt script powers the machine off instead of only shutting down without powering off.

Another is that the "killpower" command is not sent to the UPS, which doesn't cut the power to the machines. So if the power comes back before the batteries run out, the machine will not restart.

I followed the advice in this post, and changed the /etc/init.d/halt script by removing $poweroff from the halt line at the end. (I did not upgrade apcupsd as the poster did). Then the system halted without powering off, and I could read a cryptic error on the screen about ... libcrypto.so.0.9.7. That clue led to this bug report, and even though I don't use LVM or RAID, it looked like the same problem. So I tried the following:

Check that I do have the same library dependencies:
# ldd /sbin/apcupsd | grep usr
libcrypto.so.0.9.7 => /usr/lib/i686/cmov/libcrypto.so.0.9.7 (0xb7e95000)
libsnmp-0.4.2.so => /usr/lib/libsnmp-0.4.2.so (0xb7e33000)
Move these libraries to /lib, which is still accessible during shutdown, after /usr/lib on a different partition isn't anymore.
# mv -i /usr/lib/i686/cmov/libcrypto.so.0.9.7 /lib/libcrypto.so.0.9.7
# mv -i /usr/lib/libsnmp-0.4.2.so /lib/libsnmp-0.4.2.so
Put links where the libraries were originally:
# ln -i -s /lib/libsnmp-0.4.2.so /usr/lib/libsnmp-0.4.2.so
# ln -i -s /lib/libcrypto.so.0.9.7 /usr/lib/i686/cmov/libcrypto.so.0.9.7
and re-build the library cache:
# ldconfig
In Debian Etch, it turned out to be trickier, because some of these files in /usr/lib/ were links. As of now, the procedure for Etch seems to go like this:
# ldd /sbin/apcupsd | grep usr
libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 (0xb7e6c000)
libnetsnmp.so.9 => /usr/lib/libnetsnmp.so.9 (0xb7dc8000)
libz.so.1 => /usr/lib/libz.so.1 (0xb7c69000)
# mv -i /usr/lib/i686/cmov/libcrypto.so.0.9.8 /lib/libcrypto.so.0.9.8
# mv -i /usr/lib/libnetsnmp.so.9 /lib/libnetsnmp.so.9
# mv -i /usr/lib/libnetsnmp.so.9.0.1 /lib/libnetsnmp.so.9.0.1
# mv -i /usr/lib/libz.so.1 /lib/libz.so.1
# mv -i /usr/lib/libz.so.1.2.3 /lib/libz.so.1.2.3
# ln -i -s /lib/libcrypto.so.0.9.8 /usr/lib/i686/cmov/libcrypto.so.0.9.8
# ln -i -s /lib/libnetsnmp.so.9 /usr/lib/libnetsnmp.so.9
# ln -i -s /lib/libnetsnmp.so.9.0.1 /usr/lib/libnetsnmp.so.9.0.1
# ln -i -s /lib/libz.so.1 /usr/lib/libz.so.1
# ln -i -s /lib/libz.so.1.2.3 /usr/lib/libz.so.1.2.3
# ldconfig
It seems to work now, as far as my UPS is concerned. I hope that I din't break something else by moving these shared libraries.

Labels: , , , ,