1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils linux-info flag-o-matic systemd udev
8 DESCRIPTION="APC UPS daemon with integrated tcp/ip remote shutdown"
9 HOMEPAGE="http://www.apcupsd.org/"
10 SRC_URI="mirror://sourceforge/apcupsd/${P}.tar.gz"
14 KEYWORDS="amd64 ~arm ppc x86 ~x86-fbsd"
15 IUSE="snmp +usb cgi nls gnome kernel_linux"
18 || ( >=sys-apps/util-linux-2.23[tty-helpers(-)]
19 sys-freebsd/freebsd-ubin
21 cgi? ( >=media-libs/gd-1.8.4 )
22 nls? ( sys-devel/gettext )
23 snmp? ( >=net-analyzer/net-snmp-5.7.2 )
24 gnome? ( >=x11-libs/gtk+-2.4.0:2
26 >=gnome-base/gconf-2.0 )"
31 CONFIG_CHECK="~USB_HIDDEV ~HIDRAW"
32 ERROR_USB_HIDDEV="CONFIG_USB_HIDDEV: needed to access USB-attached UPSes"
33 ERROR_HIDRAW="CONFIG_HIDRAW: needed to access USB-attached UPSes"
36 if use kernel_linux && use usb && linux_config_exists; then
42 epatch "${FILESDIR}/${PN}-3.14.9-aliasing.patch"
47 use cgi && myconf="${myconf} --enable-cgi --with-cgi-bin=/usr/libexec/${PN}/cgi-bin"
49 myconf="${myconf} --with-upstype=usb --with-upscable=usb --enable-usb --with-dev= "
51 myconf="${myconf} --with-upstype=apcsmart --with-upscable=smart --disable-usb"
54 # We force the DISTNAME to gentoo so it will use gentoo's layout also
55 # when installed on non-linux systems.
58 --sysconfdir=/etc/apcupsd \
59 --with-pwrfail-dir=/etc/apcupsd \
60 --with-lock-dir=/run/apcupsd \
61 --with-pid-dir=/run/apcupsd \
62 --with-log-dir=/var/log \
63 --with-nis-port=3551 \
64 --enable-net --enable-pcnet \
65 --with-distname=gentoo \
66 $(use_enable snmp net-snmp) \
67 $(use_enable gnome gapcmon) \
69 APCUPSD_MAIL=/bin/mail
73 # Workaround for bug #280674; upstream should really just provide
74 # the text files in the distribution, but I wouldn't count on them
75 # doing that anytime soon.
76 MANPAGER=$(type -p cat) \
77 emake || die "emake failed"
81 emake DESTDIR="${D}" install
82 rm -f "${D}"/etc/init.d/halt
85 newins examples/safe.apccontrol safe.apccontrol
86 doins "${FILESDIR}"/apcupsd.conf
88 dodoc ChangeLog* ReleaseNotes
91 dohtml -r doc/manual/*
93 rm "${D}"/etc/init.d/apcupsd
94 newinitd "${FILESDIR}/${PN}.init.4" "${PN}"
95 newinitd "${FILESDIR}/${PN}.powerfail.init" "${PN}".powerfail
97 systemd_dounit "${FILESDIR}"/${PN}.service
98 systemd_dotmpfilesd "${FILESDIR}"/${PN}-tmpfiles.conf
100 # remove hal settings, we don't really want to have it around still.
101 rm -r "${D}"/usr/share/hal
103 # replace it with our udev rules if we're in Linux
104 if use kernel_linux; then
105 udev_newrules "${FILESDIR}"/apcupsd-udev.rules 60-${PN}.rules
112 elog "The cgi-bin directory for ${PN} is /usr/libexec/${PN}/cgi-bin."
113 elog "Set up your ScriptAlias or symbolic links accordingly."
117 elog "Since version 3.14.0 you can use multiple apcupsd instances to"
118 elog "control more than one UPS in a single box with openRC."
119 elog "To do this, create a link between /etc/init.d/apcupsd to a new"
120 elog "/etc/init.d/apcupsd.something, and it will then load the"
121 elog "configuration file at /etc/apcupsd/something.conf."
124 elog 'If you want apcupsd to power off your UPS when it'
125 elog 'shuts down your system in a power failure, you must'
126 elog 'add apcupsd.powerfail to your shutdown runlevel:'
128 elog ' \e[01m rc-update add apcupsd.powerfail shutdown \e[0m'
131 if use kernel_linux; then
132 elog "Starting from version 3.14.9-r1, ${PN} installs udev rules"
133 elog "for persistent device naming. If you have multiple UPS"
134 elog "connected to the machine, you can point them to the devices"
135 elog "in /dev/apcups/by-id directory."