実家メンテ計画も最終段階
雷の頻発する昨今なので、サージコンセント&無停電電源装置を導入しました。
Solaris 10にUPSを入れるケースはあまり無いのでメモとして記録。
◇ apcupsdとは
APC社の販売するUPSと連携するためのソフト。
UPSが停電を検知するとホストPCに送信する信号を受信し、停止処理を行なう。
UPSにより供給する電力ではPCは数分しか起動しないため、停止処理をしないと結局ただの電源断と同じになってしまう。このソフトがあれば、UPSからの電源供給が断たれる前に安全に電源を落としてくれる。
注意)gmakeを入れる必要あり!
■ gmakeのインストール
pkg install SUNWgmake
これだけでOK
■ apcupsdのインストール
めんどくさいので丸ごと記録
まずは、コンフィグ。
cappmac@opensolaris:‾/Desktop/src/apcupsd-3.14.9# ./configure --enable-usb
checking for true... /usr/bin/true
checking for false... /usr/bin/false
checking build system type... i386-pc-solaris2.11
checking host system type... i386-pc-solaris2.11
checking for g++... g++
checking for C++ compiler default output file name... a.out
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for a BSD-compatible install... /usr/bin/ginstall -c
checking for gawk... gawk
checking for library containing strerror... none required
checking for shutdown... /usr/sbin/shutdown
checking for mail... /usr/bin/mail
checking for wall... /usr/sbin/wall
checking for sh... /usr/bin/sh
checking for GNU make... gmake
checking for ranlib... /usr/bin/ranlib
checking for rm... /usr/bin/rm
checking for cp... /usr/bin/cp
checking for echo... /usr/bin/echo
checking for ln... /usr/bin/ln
checking for sed... /usr/bin/sed
checking for ar... /usr/bin/ar
checking for mv... /usr/bin/mv
checking for rst2html.py... no
checking for rst2pdf... no
checking for abort... yes
checking for fork... yes
checking for calloc... yes
checking for getpid... yes
checking for ioctl... yes
checking for kill... yes
checking for rewind... yes
checking for select... yes
checking for setsid... yes
checking for signal... yes
checking for strerror... yes
checking for strncmp... yes
checking for strncpy... yes
checking for tcgetattr... yes
checking for vfprintf... yes
checking for setpgrp... yes
checking for snprintf... yes
checking for vsnprintf... yes
checking for library containing nanosleep... none required
checking for syslog... yes
checking for strftime... yes
checking whether setpgrp takes no argument... yes
checking for library containing socket... -lxnet
checking for library containing gethostname... none required
checking for library containing gethostbyname... none required
checking for library containing gethostbyname_r... -lnsl
checking for socklen_t... yes
checking for library containing inet_addr... none required
checking for strchr... yes
using libc's strchr
checking for strstr... yes
checking for strcasecmp... yes
checking for memmove... yes
checking for getopt_long... yes
checking for inet_pton... yes
checking for localtime_r... yes
checking for egrep... egrep
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking ctype.h usability... yes
checking ctype.h presence... yes
checking for ctype.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking pwd.h usability... yes
checking pwd.h presence... yes
checking for pwd.h... yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking stdarg.h usability... yes
checking stdarg.h presence... yes
checking for stdarg.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking for sys/types.h... (cached) yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking arpa/nameser.h usability... yes
checking arpa/nameser.h presence... yes
checking for arpa/nameser.h... yes
checking whether stat file-mode macros are broken... no
checking whether time.h and sys/time.h may both be included... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for struct tm.tm_zone... no
checking for tzname... yes
checking for uid_t in sys/types.h... yes
checking type of array argument to getgroups... gid_t
checking for mode_t... yes
checking for off_t... yes
checking for pid_t... yes
checking return type of signal handlers... void
checking for size_t... yes
checking for uid_t in sys/types.h... (cached) yes
checking for socklen_t... yes
checking for int32_t... yes
checking for X... no
checking whether #! works in shell scripts... yes
Will not install HAL policy file
checking for libusb-config... /usr/bin/libusb-config
Using generic libusb USB driver.
checking for pkg-config... no
checking how many arguments gethostbyname_r() takes... five
checking if libsupc++ is required... yes
checking if GCC supports -fno-exceptions... yes
checking if GCC supports -fno-rtti... yes
checking for wait... yes
checking for waitpid... yes
checking for wait3... yes
checking for union wait... no
Disabling cgi support...
gcc private include directory found.
configure: creating ./config.status
config.status: creating autoconf/variables.mak
config.status: creating platforms/apccontrol
config.status: creating platforms/etc/changeme
config.status: creating platforms/etc/commfailure
config.status: creating platforms/etc/commok
config.status: creating platforms/etc/offbattery
config.status: creating platforms/etc/onbattery
config.status: creating platforms/etc/apcupsd.conf
config.status: creating examples/safe.apccontrol
config.status: creating src/win32/Makefile
config.status: creating platforms/sun/apcupsd
config.status: creating platforms/sun/rc0.solaris
config.status: creating platforms/sun/apccontrol
config.status: creating src/drivers/usb/generic/libusb.h
config.status: creating include/config.h
Configuration on Tue Aug 16 00:08:10 JST 2011:
Host: i386-pc-solaris2.11 -- sun Solaris
Apcupsd version: 3.14.9 (22 July 2011)
Source code location: .
Install binaries: /etc/opt/apcupsd/sbin
Install config files: /etc/opt/apcupsd
Install man files: /usr/share/man
Nologin file in: /etc
PID directory: /var/run
LOG dir (events, status) /etc/opt/apcupsd
LOCK dir (for serial port) /var/spool/locks
Power Fail dir /etc
Compiler: g++ 3.4.3
Compiler flags: -I/usr/local/include -I/usr/sfw/include -g -O2 -fno-exceptions -fno-rtti -Wall
Linker: gcc
Linker flags: -L/usr/local/lib64 -L/usr/local/lib -L/usr/sfw/lib
Host and version: sun Solaris
Shutdown Program: /usr/sbin/shutdown
Port/Device: /dev/ttya
Network Info Port (CGI): 3551
UPSTYPE apcsmart
UPSCABLE smart
drivers (no-* are disabled): apcsmart dumb net generic-usb snmp no-net-snmp pcnet no-test
enable-nis: yes
with-nisip: 0.0.0.0
enable-cgi: no
with-cgi-bin: /etc/apcupsd
with-libwrap:
enable-pthreads: yes
enable-dist-install: yes
enable-gapcmon: no
enable-apcagent: no
Configuration complete: Run 'gmake' to build apcuspd.
次にmake
gmakeを使うので注意。
cappmac@opensolaris:‾/Desktop/src/apcupsd-3.14.9# gmake
src
src/lib
CXX src/lib/apcconfig.c
CXX src/lib/apcerror.c
CXX src/lib/apcevents.c
CXX src/lib/apcexec.c
CXX src/lib/apcfile.c
CXX src/lib/apclibnis.c
CXX src/lib/apclock.c
CXX src/lib/apclog.c
CXX src/lib/apcsignal.c
CXX src/lib/apcstatus.c
CXX src/lib/asys.c
CXX src/lib/newups.c
CXX src/lib/md5.c
CXX src/lib/statmgr.cpp
statmgr.cpp: In member function `bool StatMgr::Update()':
statmgr.cpp:58: warning: 'len' might be used uninitialized in this function
CXX src/lib/gethostname.c
CXX src/lib/amutex.cpp
CXX src/lib/astring.cpp
CXX src/lib/autil.cpp
CXX src/lib/atimer.cpp
CXX src/lib/athread.cpp
CXX src/lib/libsupc++fix.cpp
AR src/lib/libapc.a
src/drivers
src/drivers/apcsmart
CXX src/drivers/apcsmart/smart.c
CXX src/drivers/apcsmart/smarteeprom.c
CXX src/drivers/apcsmart/smartoper.c
CXX src/drivers/apcsmart/smartsetup.c
CXX src/drivers/apcsmart/smartsetup2.c
src/drivers/dumb
CXX src/drivers/dumb/dumboper.c
CXX src/drivers/dumb/dumbsetup.c
src/drivers/net
CXX src/drivers/net/net.c
src/drivers/pcnet
CXX src/drivers/pcnet/pcnet.c
src/drivers/usb
src/drivers/usb/generic
CXX src/drivers/usb/generic/generic-usb.c
In file included from libusb.h:9,
from generic-usb.c:28:
/usr/include/usb.h:60: warning: ignoring #pragma ident
CXX src/drivers/usb/generic/hidutils.c
In file included from libusb.h:9,
from hidutils.c:28:
/usr/include/usb.h:60: warning: ignoring #pragma ident
CXX src/drivers/usb/usb.c
src/drivers/snmplite
CXX src/drivers/snmplite/apc-mib.cpp
CXX src/drivers/snmplite/asn.cpp
CXX src/drivers/snmplite/mge-mib.cpp
CXX src/drivers/snmplite/mibs.cpp
CXX src/drivers/snmplite/rfc1628-mib.cpp
CXX src/drivers/snmplite/snmp.cpp
CXX src/drivers/snmplite/snmplite.cpp
CXX src/drivers/drivers.c
AR src/drivers/libdrivers.a
src/libusbhid
CXX src/libusbhid/parse.c
CXX src/libusbhid/data.c
CXX src/libusbhid/descr.c
AR src/libusbhid/libusbhid.a
CXX src/options.c
CXX src/device.c
CXX src/reports.c
CXX src/action.c
CXX src/apcupsd.c
CXX src/apcnis.c
LD src/apcupsd
CXX src/apcaccess.c
LD src/apcaccess
CXX src/apctest.c
LD src/apctest
CXX src/smtp.c
LD src/smtp
platforms
platforms/etc
platforms/sun
doc
MAN apcupsd.8 -> apcupsd.man.txt
MAN apcaccess.8 -> apcaccess.man.txt
MAN apctest.8 -> apctest.man.txt
MAN apccontrol.8 -> apccontrol.man.txt
MAN apcupsd.conf.5 -> apcupsd.conf.man.txt
最後にmake install
これもgmakeを使うので注意。
cappmac@opensolaris:‾/Desktop/src/apcupsd-3.14.9# gmake install
src
src/lib
src/drivers
src/drivers/apcsmart
src/drivers/dumb
src/drivers/net
src/drivers/pcnet
src/drivers/usb
src/drivers/usb/generic
src/drivers/snmplite
src/libusbhid
MKDIR /etc/opt/apcupsd/sbin
COPY apcupsd => /etc/opt/apcupsd/sbin/apcupsd
COPY apctest => /etc/opt/apcupsd/sbin/apctest
COPY apcaccess => /etc/opt/apcupsd/sbin/apcaccess
COPY smtp => /etc/opt/apcupsd/sbin/smtp
platforms
platforms/etc
COPY apcupsd.conf => /etc/opt/apcupsd/apcupsd.conf
COPY changeme => /etc/opt/apcupsd/changeme
COPY commfailure => /etc/opt/apcupsd/commfailure
COPY commok => /etc/opt/apcupsd/commok
COPY offbattery => /etc/opt/apcupsd/offbattery
COPY onbattery => /etc/opt/apcupsd/onbattery
platforms/sun
------------------------------------------------------------
Sun distribution installation
------------------------------------------------------------
COPY apcupsd => /etc/init.d/apcupsd
LN //etc/rc0.d/K21apcupsd -> ../init.d/apcupsd
LN //etc/rc1.d/S89apcupsd -> ../init.d/apcupsd
LN //etc/rc2.d/S89apcupsd -> ../init.d/apcupsd
=================================================
apcupsd script installation for Solaris Solaris complete.
You should now edit /etc/opt/apcupsd/apcupsd.conf to correspond
to your setup then start the apcupsd daemon with:
/etc/init.d/apcupsd start
Thereafter when you reboot, it will be stopped and started
automatically.
=================================================
Configuring ugen driver to match APC UPSes...
Driver (ugen) is already installed.
NOTE:
"(usbif51d,class3) already in use" and
"Driver (ugen) is already installed"
errors may be safely ignored.
=================================================
Driver configured. You must PERFORM A RECONFIGURE
BOOT "reboot -- -r" before running Apcupsd.
=================================================
COPY apccontrol => /etc/opt/apcupsd/apccontrol
doc
COPY apcupsd.8 => /usr/share/man/man8/apcupsd.8
COPY apcaccess.8 => /usr/share/man/man8/apcaccess.8
COPY apctest.8 => /usr/share/man/man8/apctest.8
COPY apccontrol.8 => /usr/share/man/man8/apccontrol.8
COPY apcupsd.conf.5 => /usr/share/man/man5/apcupsd.conf.5
使い方は他のOSと同様なので割愛。