Прикручивание бесперебойника Smart-UPS APC-1500 к FreeBSD

/usr/home/lissyara/>cd /usr/ports/
/usr/ports/>make search name='apcups'
Port:   apcupsd-3.10.18_1
Path:   /usr/ports/sysutils/apcupsd
Info:   A daemon for controlling APC UPS
Maint:  [email protected]
B-deps: expat-1.95.8_3 gettext-0.14.5 libiconv-1.9.2_1
R-deps: expat-1.95.8_3 gettext-0.14.5 libiconv-1.9.2_1
WWW:    http://www.apcupsd.com

/usr/ports/>su
/usr/ports/>cd /usr/ports/sysutils/apcupsd
/usr/ports/sysutils/apcupsd/>make && make install && make clean

Вылазиет синенькое окошко, где я выбрал только первый пункт:
 [X] CLIENT_ONLY Build apcupsd client only (no network server)
 [ ] CGI         Compile with CGI programms to show status
 [ ] USB         Compile with USB Support (READ MANUAL!!!)
 [ ] SNMP        Compile with SNMP Support (READ MANUAL!!!)
 [ ] NOPTHREADS  Compile without pthreads support (READ MANUAL!!!) 

Почему не по USB? Он у меня из ядра ампутирован, да и не родной это интерфейс, как ни крути. Родной - COM. После установки копируем скрипт запуска, добавляем строку в /etc/rc.conf:
===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/sbin/apcaccess
/usr/local/sbin/apctest
/usr/local/sbin/powerflute
/usr/local/sbin/apcupsd
/usr/local/sbin/apcnisd

      This port has installed the following startup scripts which may cause
      these network services to be started at boot time.
/usr/local/etc/rc.d/apcupsd.sh.sample

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:
http://www.apcupsd.com
===>  Cleaning for libiconv-1.9.2_1
===>  Cleaning for gettext-0.14.5
===>  Cleaning for libtool-1.5.20
===>  Cleaning for expat-1.95.8_3
===>  Cleaning for apcupsd-3.10.18_1
/usr/ports/sysutils/apcupsd/>cd /usr/local/etc/rc.d/
/usr/local/etc/rc.d/>ls | grep apc
apcupsd.sh.sample
/usr/local/etc/rc.d/>cp apcupsd.sh.sample apcupsd.sh
/usr/local/etc/rc.d/>echo '' >> /etc/rc.conf
/usr/local/etc/rc.d/>echo 'apcupsd_enable="YES"' >> /etc/rc.conf
/usr/local/etc/rc.d/>

Установился. Топаем в /usr/local/etc/apcupsd/
/usr/local/etc/rc.d/>cd ../apcupsd/
/usr/local/etc/apcupsd/>ls
apccontrol                      commfailure
apcupsd.conf                    commok
apcupsd.conf.net-master.sample  mainsback
apcupsd.conf.net-slave.sample   masterconnect
apcupsd.conf.sample             mastertimeout
changeme                        onbattery
/usr/local/etc/apcupsd/>dmesg | grep sio
usb0: USB revision 1.0
sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
sio0: type 16550A
sio1 at port 0x2f8-0x2ff irq 3 on isa0
sio1: type 16550A
/usr/local/etc/apcupsd/>

В итоге, у меня получился следующий файл (комменты удалены за ненадобностью):
/usr/local/etc/apcupsd/>cat apcupsd.conf | grep -v "^#"
UPSCABLE smart
UPSTYPE smartups
DEVICE /dev/cuaa1 # первый (cuaa0) COM-порт у меня занят,
                  # поэтому повесил на второй
LOCKFILE /var/spool/lock
ONBATTERYDELAY 6
BATTERYLEVEL 5
MINUTES 3
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 10
EVENTSFILE /var/log/apcupsd.events
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0
UPSNAME APC-1500 RC
WAKEUP 30

После чего запускаем, проверяем запустился ли, и, на `бис`, выдёргиваем питальник из UPS`a :)))

/usr/local/etc/apcupsd/>/usr/local/etc/rc.d/apcupsd.sh start
 apcupsd
/usr/local/etc/apcupsd/>
/usr/local/etc/apcupsd/>ps -ax | grep apc
11605  ??  Ss     0:00.05 /usr/local/sbin/apcupsd --kill-on-powerfail
11613  p0  R+     0:00.00 grep apc
/usr/local/etc/apcupsd/>
Broadcast Message from [email protected]
        (no tty) at 14:35 MSK...

Warning power loss detected.

Broadcast Message from [email protected]
        (no tty) at 14:35 MSK...

Power has returned...
/usr/local/etc/apcupsd/>

Все готово. Можем и протестировать отключив от питания, письма будут слаться root`у - о кажом скачке напряжения.



Источник статьи