Introduce Network UPS Tools nut development port. This port tracks

the networkupstools/nut github repo.
This commit is contained in:
cy
2020-03-26 20:48:28 +00:00
parent e547b84166
commit d24299463a
19 changed files with 1049 additions and 0 deletions
+1
View File
@@ -753,6 +753,7 @@
SUBDIR += nsysctl
SUBDIR += ntfy
SUBDIR += nut
SUBDIR += nut-devel
SUBDIR += nvclock
SUBDIR += nvme-cli
SUBDIR += nvramtool
+204
View File
@@ -0,0 +1,204 @@
# Created by: Boris Popov <bp@FreeBSD.org>
# $FreeBSD$
PORTNAME= nut
PORTVERSION= ${NUT_COMMIT_DATE}
CATEGORIES= sysutils
PKGNAMESUFFIX= -devel
# MASTER_SITES= http://www.networkupstools.org/source/${PORTVERSION:R}/
# DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
# EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX}
MAINTAINER= cy@FreeBSD.org
COMMENT= Network UPS Tools
USE_GITHUB= yes
GH_ACCOUNT= networkupstools
GH_TAGNAME= e27f1f9
NUT_COMMIT_DATE= 2020.02.09
GNU_CONFIGURE= yes
USE_LDCONFIG= yes
USES= autoreconf:build gmake pkgconfig libtool
NUT_USER?= uucp
NUT_GROUP?= uucp
STATEDIR?= /var/db/nut
PLIST_SUB+= NUT_USER=${NUT_USER}
PLIST_SUB+= NUT_GROUP=${NUT_GROUP}
OPTIONS_DEFAULT=SERIAL USB SNMP NEON IPMI_OFF SSL_OFF
OPTIONS_DEFINE= SERIAL USB SNMP NEON PDU CGI BASH AVAHI DOCS
OPTIONS_SINGLE= IPMI SSL
OPTIONS_SINGLE_IPMI= IPMI_OFF IPMIPSU FREEIPMI
OPTIONS_SINGLE_SSL= SSL_OFF OPENSSL NSS
SERIAL_DESC= SERIAL support
USB_DESC= USB support
SNMP_DESC= SNMP support
NEON_DESC= NEON XML/HTTP support
PDU_DESC= Powerman PDU support
CGI_DESC= Web CGI interface
BASH_DESC= Bash Completion support
AVAHI_DESC= Avahi support
IPMI_OFF_DESC= No IPMI support
FREEIPMI_DESC= freeipmi support
IPMIPSU_DESC= Use nut-ipmipsu support (experimental)
SSL_OFF_DESC= No SSL support
USE_RC_SUBR= nut nut_upsmon nut_upslog
SUB_LIST+= STATEDIR=${STATEDIR}
PLIST_SUB+= STATEDIR=${STATEDIR}
PORTDOCS= *
.include <bsd.port.options.mk>
CONFIGURE_ARGS= --sysconfdir=${PREFIX}/etc/nut \
--program-transform-name="" \
--localstatedir=${STATEDIR} \
--datadir=${PREFIX}/etc/nut \
--with-devd-dir=${PREFIX}/etc/devd \
--with-drvpath=${PREFIX}/libexec/nut \
--with-statepath=${STATEDIR} \
--with-altpidpath=${STATEDIR} \
--with-pidpath=${STATEDIR} \
--with-pkgconfig-dir=${PREFIX}/libdata/pkgconfig \
--with-user=${NUT_USER} \
--with-group=${NUT_GROUP} \
--with-dev
.if ${PORT_OPTIONS:MCGI}
LIB_DEPENDS+= libgd.so:graphics/gd
CGIDIR?= ${PREFIX}/www/cgi-bin/${PORTNAME}
CGIDIR_REL?= ${CGIDIR:S,^${PREFIX}/,,}
CONFIGURE_ARGS+= --with-cgi --with-cgipath=${CGIDIR} \
--with-htmlpath=${WWWDIR} \
--with-gd-includes=-I${LOCALBASE}/include \
--with-gd-libs="-L${LOCALBASE}/lib -lgd"
PLIST_SUB+= NUT_CGI=""
PLIST_SUB+= CGIDIR="${CGIDIR_REL}"
PLIST_SUB+= CGIETCDIR="etc/nut/"
.else
CONFIGURE_ARGS+= --without-cgi
PLIST_SUB+= NUT_CGI="@comment "
.endif
.if ${PORT_OPTIONS:MSERIAL}
CONFIGURE_ARGS+= --with-serial
PLIST_SUB+= NUT_SERIAL=""
.else
CONFIGURE_ARGS+= --without-serial
PLIST_SUB+= NUT_SERIAL="@comment "
.endif
.if ${PORT_OPTIONS:MUSB}
#EXTRA_PATCHES= ${FILESDIR}/extra-patch-m4_nut_check_libusb.m4
CONFIGURE_ARGS+= --with-usb=auto
PLIST_SUB+= NUT_USB=""
.else
CONFIGURE_ARGS+= --without-usb
PLIST_SUB+= NUT_USB="@comment "
.endif
.if ${PORT_OPTIONS:MSNMP}
LIB_DEPENDS+= libnetsnmp.so:net-mgmt/net-snmp
CONFIGURE_ARGS+= --with-snmp
PLIST_SUB+= NUT_SNMP=""
.else
CONFIGURE_ARGS+= --without-snmp
PLIST_SUB+= NUT_SNMP="@comment "
.endif
.if ${PORT_OPTIONS:MNEON}
LIB_DEPENDS+= libneon.so:www/neon
CONFIGURE_ARGS+= --with-neon
PLIST_SUB+= NUT_NEON=""
.else
CONFIGURE_ARGS+= --without-neon
CONFIGURE_ARGS+= --disable-neon
PLIST_SUB+= NUT_NEON="@comment "
.endif
.if ${PORT_OPTIONS:MPDU}
LIB_DEPENDS+= libpowerman.so:sysutils/powerman
CONFIGURE_ARGS+= --with-powerman
PLIST_SUB+= NUT_PDU=""
.else
CONFIGURE_ARGS+= --without-powerman
PLIST_SUB+= NUT_PDU="@comment "
.endif
.if ${PORT_OPTIONS:MBASH}
BUILD_DEPENDS+= ${LOCALBASE}/share/bash-completion/bash_completion.sh:shells/bash-completion
RUN_DEPENDS+= ${LOCALBASE}/share/bash-completion/bash_completion.sh:shells/bash-completion
PLIST_SUB+= BASH=""
.else
PLIST_SUB+= BASH="@comment "
.endif
.if ${PORT_OPTIONS:MAVAHI}
BUILD_DEPENDS+= ${LOCALBASE}/include/avahi-ui/avahi-ui.h:net/avahi-header
BUILD_DEPENDS+= avahi-daemon:net/avahi-app
RUN_DEPENDS+= avahi-daemon:net/avahi-app
CONFIGURE_ARGS+= --with-avahi
.else
CONFIGURE_ARGS+= --without-avahi
.endif
.if ${PORT_OPTIONS:MFREEIPMI}
LIB_DEPENDS+= libfreeipmi.so:sysutils/freeipmi
CONFIGURE_ARGS+= --with-freeipmi
PLIST_SUB+= NUT_FREEIPMI=""
.else
CONFIGURE_ARGS+= --without-freeipmi
PLIST_SUB+= NUT_FREEIPMI="@comment "
.endif
.if ${PORT_OPTIONS:MIPMIPSU}
LIB_DEPENDS+= libfreeipmi.so:sysutils/freeipmi
CONFIGURE_ARGS+= --with-ipmi
PLIST_SUB+= NUT_IPMIPSU=""
.else
CONFIGURE_ARGS+= --without-ipmi
PLIST_SUB+= NUT_IPMIPSU="@comment "
.endif
.if ${PORT_OPTIONS:MOPENSSL}
USES+= ssl
CONFIGURE_ARGS+= --with-openssl
.elif ${PORT_OPTIONS:MNSS}
LIB_DEPENDS= libnss3.so:security/nss
CONFIGURE_ARGS+= --with-nss
.else
CONFIGURE_ARGS+= --without-openssl --without-ssl
.endif
pre-configure:
cd ${WRKSRC} && ./autogen.sh
pre-install:
@${MKDIR} ${STAGEDIR}${PREFIX}/libexec/nut
@${REINPLACE_CMD} -e 's/device-name\*/cdev/g' ${WRKSRC}/scripts/devd/nut-usb.conf
post-install:
@${MKDIR} ${STAGEDIR}${STATEDIR}
.if ${PORT_OPTIONS:MDOCS}
.if ${PORT_OPTIONS:MBASH}
@${MKDIR} ${STAGEDIR}${PREFIX}/etc/bash_completion.d/
${INSTALL_DATA} ${WRKSRC}/scripts/misc/nut.bash_completion ${STAGEDIR}${PREFIX}/etc/bash_completion.d/
.endif
@${MKDIR} ${STAGEDIR}${DOCSDIR}/cables
${INSTALL_DATA} ${WRKSRC}/docs/cables/*.txt ${STAGEDIR}${DOCSDIR}/cables
${INSTALL_DATA} ${WRKSRC}/docs/*.txt ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/docs/FAQ.txt ${STAGEDIR}${DOCSDIR}
.for file in AUTHORS COPYING INSTALL MAINTAINERS NEWS README UPGRADING
${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}
.endfor
.endif
@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample
${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample
${MKDIR} ${STAGEDIR}/var/log/nut
.include <bsd.port.mk>
+3
View File
@@ -0,0 +1,3 @@
TIMESTAMP = 1585101068
SHA256 (networkupstools-nut-2020.02.09-e27f1f9_GH0.tar.gz) = 8eb734b4141309dc95bec47b21aa890496d8f0c0377c0c4343ca571e6a9c92f5
SIZE (networkupstools-nut-2020.02.09-e27f1f9_GH0.tar.gz) = 1938546
+56
View File
@@ -0,0 +1,56 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: nut
# REQUIRE: NETWORKING
# BEFORE: LOGIN
# KEYWORD: shutdown
# Define these nut_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/nut
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
nut_enable=${nut_enable:-"NO"}
nut_prefix=${nut_prefix:-"%%PREFIX%%"}
nut_upsshut=${nut_upsshut:-"NO"}
. /etc/rc.subr
name="nut"
rcvar=nut_enable
load_rc_config $name
required_dirs="%%STATEDIR%%"
required_files="${nut_prefix}/etc/nut/ups.conf ${nut_prefix}/etc/nut/upsd.conf ${nut_prefix}/etc/nut/upsd.users"
command="${nut_prefix}/sbin/upsd"
pidfile="%%STATEDIR%%/upsd.pid"
start_precmd="nut_prestart"
stop_postcmd="nut_poststop"
nut_prestart() {
${nut_prefix}/sbin/upsdrvctl start
}
nut_poststop() {
if ${nut_prefix}/sbin/upsdrvctl stop && checkyesno nut_upsshut; then
if ${nut_prefix}/sbin/upsmon -K; then
${nut_prefix}/sbin/upsdrvctl shutdown
fi
fi
}
extra_commands=reload
reload()
{
kill -HUP `cat $pidfile`
}
run_rc_command "$1"
+7
View File
@@ -0,0 +1,7 @@
# configuration file for newsyslog for nut
#
# see newsyslog.conf(5) for details
#
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/nut/upsd.log uucp:uucp 644 7 100 * J /var/db/nut/upslog.pid
+2
View File
@@ -0,0 +1,2 @@
!upsmon
*.* /var/log/nut/upsd.log
+37
View File
@@ -0,0 +1,37 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: nut_upslog
# REQUIRE: NETWORKING nut
# BEFORE: LOGIN
# KEYWORD: shutdown
# Define these nut_upslog* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/nut_upslog
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
nut_upslog_enable=${nut_upslog_enable:-"NO"}
nut_upslog_prefix=${nut_upslog_prefix:-"%%PREFIX%%"}
nut_upslog_logfile=${nut_upslog_logfile:-"/var/log/nut/ups.log"}
nut_upslog_interval=${nut_upslog_interval:-"300"}
nut_upslog_ups=${nut_upslog_ups:-"myups@localhost"}
# nut_upslog_format
. /etc/rc.subr
name="nut_upslog"
rcvar=nut_upslog_enable
load_rc_config $name
required_dirs="%%STATEDIR%%"
command="${nut_upslog_prefix}/bin/upslog"
pidfile="%%STATEDIR%%/upslog.pid"
nut_upslog_flags=${nut_upslog_flags:-"-s ${nut_upslog_ups} -l ${nut_upslog_logfile} -i ${nut_upslog_interval} ${nut_upslog_format:+-f \"${nut_upslog_format}\"}"}
run_rc_command "$1"
+47
View File
@@ -0,0 +1,47 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: nut_upsmon
# REQUIRE: NETWORKING nut
# BEFORE: LOGIN
# KEYWORD: shutdown
# Define these nut_upsmon* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/nut_upsmon
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
nut_upsmon_enable=${nut_upsmon_enable:-"NO"}
nut_upsmon_prefix=${nut_upsmon_prefix:-"%%PREFIX%%"}
. /etc/rc.subr
name="nut_upsmon"
rcvar=nut_upsmon_enable
load_rc_config $name
required_dirs="%%STATEDIR%%"
required_files="${nut_upsmon_prefix}/etc/nut/upsmon.conf"
command="${nut_upsmon_prefix}/sbin/upsmon"
pidfile="%%STATEDIR%%/upsmon.pid"
nut_upsmon_flags=${nut_upsmon_flags:-"localhost"}
extra_commands=reload
stop_cmd="upsmon_stop"
reload()
{
${command} -c reload
}
upsmon_stop()
{
${command} -c stop
}
run_rc_command "$1"
@@ -0,0 +1,79 @@
--- drivers/blazer_usb.c.orig 2015-12-29 12:08:34 UTC
+++ drivers/blazer_usb.c
@@ -118,9 +118,9 @@ static int phoenix_command(const char *cmd, char *buf,
*/
switch (ret)
{
- case -EPIPE: /* Broken pipe */
+ case LIBUSB_ERROR_PIPE: /* Broken pipe */
usb_clear_halt(udev, 0x81);
- case -ETIMEDOUT: /* Connection timed out */
+ case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */
break;
}
@@ -188,7 +188,7 @@ static int ippon_command(const char *cmd, char *buf, s
0x09, 0x2, 0, &tmp[i], 8, 1000);
if (ret <= 0) {
- upsdebugx(3, "send: %s", (ret != -ETIMEDOUT) ? usb_strerror() : "Connection timed out");
+ upsdebugx(3, "send: %s", (ret != LIBUSB_ERROR_TIMEOUT) ? usb_strerror() : "Connection timed out");
return ret;
}
}
@@ -203,7 +203,7 @@ static int ippon_command(const char *cmd, char *buf, s
* will happen after successfully writing a command to the UPS)
*/
if (ret <= 0) {
- upsdebugx(3, "read: %s", (ret != -ETIMEDOUT) ? usb_strerror() : "Connection timed out");
+ upsdebugx(3, "read: %s", (ret != LIBUSB_ERROR_TIMEOUT) ? usb_strerror() : "Connection timed out");
return ret;
}
@@ -423,38 +423,28 @@ int blazer_command(const char *cmd, char *buf, size_t
switch (ret)
{
- case -EBUSY: /* Device or resource busy */
+ case LIBUSB_ERROR_BUSY: /* Device or resource busy */
fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver");
- case -EPERM: /* Operation not permitted */
- fatal_with_errno(EXIT_FAILURE, "Permissions problem");
-
- case -EPIPE: /* Broken pipe */
+ case LIBUSB_ERROR_PIPE: /* Broken pipe */
if (usb_clear_halt(udev, 0x81) == 0) {
upsdebugx(1, "Stall condition cleared");
break;
}
-#ifdef ETIME
- case -ETIME: /* Timer expired */
-#endif
if (usb_reset(udev) == 0) {
upsdebugx(1, "Device reset handled");
}
- case -ENODEV: /* No such device */
- case -EACCES: /* Permission denied */
- case -EIO: /* I/O error */
- case -ENXIO: /* No such device or address */
- case -ENOENT: /* No such file or directory */
+ case LIBUSB_ERROR_NO_DEVICE: /* No such device */
+ case LIBUSB_ERROR_ACCESS: /* Permission denied */
+ case LIBUSB_ERROR_IO: /* I/O error */
+ case LIBUSB_ERROR_NOT_FOUND: /* No such file or directory */
/* Uh oh, got to reconnect! */
usb->close(udev);
udev = NULL;
break;
- case -ETIMEDOUT: /* Connection timed out */
- case -EOVERFLOW: /* Value too large for defined data type */
-#ifdef EPROTO
- case -EPROTO: /* Protocol error */
-#endif
+ case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */
+ case LIBUSB_ERROR_OVERFLOW: /* Value too large for defined data type */
default:
break;
}
@@ -0,0 +1,23 @@
--- drivers/libshut.c.orig 2015-12-29 12:08:34 UTC
+++ drivers/libshut.c
@@ -37,6 +37,7 @@
#include "nut_stdint.h" /* for uint8_t, uint16_t, uint32_t */
#include "serial.h"
+#include "libusb.h"
#include "libshut.h"
#include "common.h" /* for xmalloc, upsdebugx prototypes */
@@ -809,10 +810,10 @@ int shut_get_string_simple(int upsfd, int index,
return ret;
if (tbuf[1] != USB_DT_STRING)
- return -EIO;
+ return LIBUSB_ERROR_IO;
if (tbuf[0] > ret)
- return -EFBIG;
+ return LIBUSB_ERROR_OVERFLOW;
/* skip the UTF8 zero'ed high bytes */
for (di = 0, si = 2; si < tbuf[0]; si += 2)
@@ -0,0 +1,65 @@
--- drivers/libusb.c.orig 2015-12-29 12:08:34 UTC
+++ drivers/libusb.c
@@ -428,26 +428,21 @@ static int libusb_strerror(const int ret, const char *
switch(ret)
{
- case -EBUSY: /* Device or resource busy */
- case -EPERM: /* Operation not permitted */
- case -ENODEV: /* No such device */
- case -EACCES: /* Permission denied */
- case -EIO: /* I/O error */
- case -ENXIO: /* No such device or address */
- case -ENOENT: /* No such file or directory */
- case -EPIPE: /* Broken pipe */
- case -ENOSYS: /* Function not implemented */
+ case LIBUSB_ERROR_BUSY: /* Device or resource busy */
+ case LIBUSB_ERROR_NO_DEVICE: /* No such device */
+ case LIBUSB_ERROR_ACCESS: /* Permission denied */
+ case LIBUSB_ERROR_IO: /* I/O error */
+ case LIBUSB_ERROR_NOT_FOUND: /* No such file or directory */
+ case LIBUSB_ERROR_PIPE: /* Broken pipe */
+ case LIBUSB_ERROR_NOT_SUPPORTED: /* Function not implemented */
upslogx(LOG_DEBUG, "%s: %s", desc, usb_strerror());
return ret;
- case -ETIMEDOUT: /* Connection timed out */
+ case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */
upsdebugx(2, "%s: Connection timed out", desc);
return 0;
- case -EOVERFLOW: /* Value too large for defined data type */
-#ifdef EPROTO
- case -EPROTO: /* Protocol error */
-#endif
+ case LIBUSB_ERROR_OVERFLOW: /* Value too large for defined data type */
upsdebugx(2, "%s: %s", desc, usb_strerror());
return 0;
@@ -478,7 +473,7 @@ static int libusb_get_report(usb_dev_handle *udev, int
0, raw_buf, ReportSize, USB_TIMEOUT);
/* Ignore "protocol stall" (for unsupported request) on control endpoint */
- if (ret == -EPIPE) {
+ if (ret == LIBUSB_ERROR_PIPE) {
return 0;
}
@@ -500,7 +495,7 @@ static int libusb_set_report(usb_dev_handle *udev, int
0, raw_buf, ReportSize, USB_TIMEOUT);
/* Ignore "protocol stall" (for unsupported request) on control endpoint */
- if (ret == -EPIPE) {
+ if (ret == LIBUSB_ERROR_PIPE) {
return 0;
}
@@ -532,7 +527,7 @@ static int libusb_get_interrupt(usb_dev_handle *udev,
ret = usb_interrupt_read(udev, 0x81, (char *)buf, bufsize, timeout);
/* Clear stall condition */
- if (ret == -EPIPE) {
+ if (ret == LIBUSB_ERROR_PIPE) {
ret = usb_clear_halt(udev, 0x81);
}
@@ -0,0 +1,27 @@
--- drivers/libusb.h.orig 2015-12-29 12:08:34 UTC
+++ drivers/libusb.h
@@ -36,6 +36,24 @@
#include <usb.h> /* libusb header file */
+/* libusb 1.0 errors used by FreeBSD */
+enum libusb_error {
+ LIBUSB_SUCCESS = 0,
+ LIBUSB_ERROR_IO = -1,
+ LIBUSB_ERROR_INVALID_PARAM = -2,
+ LIBUSB_ERROR_ACCESS = -3,
+ LIBUSB_ERROR_NO_DEVICE = -4,
+ LIBUSB_ERROR_NOT_FOUND = -5,
+ LIBUSB_ERROR_BUSY = -6,
+ LIBUSB_ERROR_TIMEOUT = -7,
+ LIBUSB_ERROR_OVERFLOW = -8,
+ LIBUSB_ERROR_PIPE = -9,
+ LIBUSB_ERROR_INTERRUPTED = -10,
+ LIBUSB_ERROR_NO_MEM = -11,
+ LIBUSB_ERROR_NOT_SUPPORTED = -12,
+ LIBUSB_ERROR_OTHER = -99,
+};
+
extern upsdrv_info_t comm_upsdrv_info;
/*!
@@ -0,0 +1,79 @@
--- drivers/nutdrv_qx.c.orig 2016-03-08 12:01:11 UTC
+++ drivers/nutdrv_qx.c
@@ -561,9 +561,9 @@ static int phoenix_command(const char *cmd, char *buf,
* In order to read correct replies we need to flush the output buffers of the converter until we get no more data (ie, it times out). */
switch (ret)
{
- case -EPIPE: /* Broken pipe */
+ case LIBUSB_ERROR_PIPE: /* Broken pipe */
usb_clear_halt(udev, 0x81);
- case -ETIMEDOUT: /* Connection timed out */
+ case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */
break;
}
@@ -635,7 +635,7 @@ static int ippon_command(const char *cmd, char *buf, s
ret = usb_control_msg(udev, USB_ENDPOINT_OUT + USB_TYPE_CLASS + USB_RECIP_INTERFACE, 0x09, 0x2, 0, &tmp[i], 8, 1000);
if (ret <= 0) {
- upsdebugx(3, "send: %s (%d)", (ret != -ETIMEDOUT) ? usb_strerror() : "Connection timed out", ret);
+ upsdebugx(3, "send: %s (%d)", (ret != LIBUSB_ERROR_TIMEOUT) ? usb_strerror() : "Connection timed out", ret);
return ret;
}
@@ -648,7 +648,7 @@ static int ippon_command(const char *cmd, char *buf, s
/* Any errors here mean that we are unable to read a reply (which will happen after successfully writing a command to the UPS) */
if (ret <= 0) {
- upsdebugx(3, "read: %s (%d)", (ret != -ETIMEDOUT) ? usb_strerror() : "Connection timed out", ret);
+ upsdebugx(3, "read: %s (%d)", (ret != LIBUSB_ERROR_TIMEOUT) ? usb_strerror() : "Connection timed out", ret);
return ret;
}
@@ -2124,38 +2124,28 @@ static int qx_command(const char *cmd, char *buf, size
switch (ret)
{
- case -EBUSY: /* Device or resource busy */
+ case LIBUSB_ERROR_BUSY: /* Device or resource busy */
fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver");
- case -EPERM: /* Operation not permitted */
- fatal_with_errno(EXIT_FAILURE, "Permissions problem");
-
- case -EPIPE: /* Broken pipe */
+ case LIBUSB_ERROR_PIPE: /* Broken pipe */
if (usb_clear_halt(udev, 0x81) == 0) {
upsdebugx(1, "Stall condition cleared");
break;
}
- #ifdef ETIME
- case -ETIME: /* Timer expired */
- #endif /* ETIME */
if (usb_reset(udev) == 0) {
upsdebugx(1, "Device reset handled");
}
- case -ENODEV: /* No such device */
- case -EACCES: /* Permission denied */
- case -EIO: /* I/O error */
- case -ENXIO: /* No such device or address */
- case -ENOENT: /* No such file or directory */
+ case LIBUSB_ERROR_NO_DEVICE: /* No such device */
+ case LIBUSB_ERROR_ACCESS: /* Permission denied */
+ case LIBUSB_ERROR_IO: /* I/O error */
+ case LIBUSB_ERROR_NOT_FOUND: /* No such file or directory */
/* Uh oh, got to reconnect! */
usb->close(udev);
udev = NULL;
break;
- case -ETIMEDOUT: /* Connection timed out */
- case -EOVERFLOW: /* Value too large for defined data type */
-#ifdef EPROTO
- case -EPROTO: /* Protocol error */
-#endif
+ case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */
+ case LIBUSB_ERROR_OVERFLOW: /* Value too large for defined data type */
default:
break;
}
@@ -0,0 +1,53 @@
--- drivers/riello_usb.c.orig 2015-12-29 12:08:34 UTC
+++ drivers/riello_usb.c
@@ -346,42 +346,28 @@ int riello_command(uint8_t *cmd, uint8_t *buf, uint16_
switch (ret)
{
- case -EBUSY: /* Device or resource busy */
+ case LIBUSB_ERROR_BUSY: /* Device or resource busy */
fatal_with_errno(EXIT_FAILURE, "Got disconnected by another driver");
- case -EPERM: /* Operation not permitted */
- fatal_with_errno(EXIT_FAILURE, "Permissions problem");
-
- case -EPIPE: /* Broken pipe */
+ case LIBUSB_ERROR_PIPE: /* Broken pipe */
if (usb_clear_halt(udev, 0x81) == 0) {
upsdebugx(1, "Stall condition cleared");
break;
}
-#ifdef ETIME
- case -ETIME: /* Timer expired */
-#endif
if (usb_reset(udev) == 0) {
upsdebugx(1, "Device reset handled");
}
- case -ENODEV: /* No such device */
- case -EACCES: /* Permission denied */
- case -EIO: /* I/O error */
- case -ENXIO: /* No such device or address */
- case -ENOENT: /* No such file or directory */
+ case LIBUSB_ERROR_NO_DEVICE: /* No such device */
+ case LIBUSB_ERROR_ACCESS: /* Permission denied */
+ case LIBUSB_ERROR_IO: /* I/O error */
+ case LIBUSB_ERROR_NOT_FOUND: /* No such file or directory */
/* Uh oh, got to reconnect! */
usb->close(udev);
udev = NULL;
break;
- case -ETIMEDOUT: /* Connection timed out */
- upsdebugx (3, "riello_command err: Resource temporarily unavailable");
-
-
- case -EOVERFLOW: /* Value too large for defined data type */
-#ifdef EPROTO
- case -EPROTO: /* Protocol error */
-#endif
- break;
+ case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */
+ case LIBUSB_ERROR_OVERFLOW: /* Value too large for defined data type */
default:
break;
}
@@ -0,0 +1,20 @@
--- drivers/tripplite_usb.c.orig 2015-12-29 12:08:34 UTC
+++ drivers/tripplite_usb.c
@@ -499,7 +499,7 @@ void usb_comm_fail(int res, const char *msg)
static int try = 0;
switch(res) {
- case -EBUSY:
+ case LIBUSB_ERROR_BUSY:
upslogx(LOG_WARNING, "%s: Device claimed by another process", msg);
fatalx(EXIT_FAILURE, "Terminating: EBUSY");
break;
@@ -907,7 +907,7 @@ void upsdrv_initinfo(void)
if(tl_model != TRIPP_LITE_SMARTPRO ) {
ret = send_cmd(w_msg, sizeof(w_msg), w_value, sizeof(w_value)-1);
if(ret <= 0) {
- if(ret == -EPIPE) {
+ if(ret == LIBUSB_ERROR_PIPE) {
fatalx(EXIT_FAILURE, "Could not reset watchdog. Please check and"
"see if usbhid-ups(8) works with this UPS.");
} else {
@@ -0,0 +1,74 @@
--- drivers/usbhid-ups.c.orig 2015-12-29 12:08:34 UTC
+++ drivers/usbhid-ups.c
@@ -30,6 +30,7 @@
#define DRIVER_VERSION "0.41"
#include "main.h"
+#include "libusb.h"
#include "libhid.h"
#include "usbhid-ups.h"
#include "hidparser.h"
@@ -790,22 +790,14 @@ void upsdrv_updateinfo(void)
/* Get HID notifications on Interrupt pipe first */
if (use_interrupt_pipe == TRUE) {
evtCount = HIDGetEvents(udev, event, MAX_EVENT_NUM);
- switch (evtCount)
- {
- case -EBUSY: /* Device or resource busy */
- upslog_with_errno(LOG_CRIT, "Got disconnected by another driver");
- case -EPERM: /* Operation not permitted */
- case -ENODEV: /* No such device */
- case -EACCES: /* Permission denied */
- case -EIO: /* I/O error */
- case -ENXIO: /* No such device or address */
- case -ENOENT: /* No such file or directory */
+ if (evtCount < 0) {
+ if (evtCount == LIBUSB_ERROR_BUSY) {
+ upslog_with_errno(LOG_CRIT, "Got disconnected by another driver");
+ }
/* Uh oh, got to reconnect! */
hd = NULL;
- return;
- default:
+ } else {
upsdebugx(1, "Got %i HID objects...", (evtCount >= 0) ? evtCount : 0);
- break;
}
} else {
evtCount = 0;
@@ -1280,14 +1272,12 @@ static bool_t hid_ups_walk(walkmode_t mode)
switch (retcode)
{
- case -EBUSY: /* Device or resource busy */
+ case LIBUSB_ERROR_BUSY: /* Device or resource busy */
upslog_with_errno(LOG_CRIT, "Got disconnected by another driver");
- case -EPERM: /* Operation not permitted */
- case -ENODEV: /* No such device */
- case -EACCES: /* Permission denied */
- case -EIO: /* I/O error */
- case -ENXIO: /* No such device or address */
- case -ENOENT: /* No such file or directory */
+ case LIBUSB_ERROR_NO_DEVICE: /* No such device */
+ case LIBUSB_ERROR_ACCESS: /* Permission denied */
+ case LIBUSB_ERROR_IO: /* I/O error */
+ case LIBUSB_ERROR_NOT_FOUND: /* No such file or directory */
/* Uh oh, got to reconnect! */
hd = NULL;
return FALSE;
@@ -1298,12 +1288,9 @@ static bool_t hid_ups_walk(walkmode_t mode)
case 0:
continue;
- case -ETIMEDOUT: /* Connection timed out */
- case -EOVERFLOW: /* Value too large for defined data type */
-#ifdef EPROTO
- case -EPROTO: /* Protocol error */
-#endif
- case -EPIPE: /* Broken pipe */
+ case LIBUSB_ERROR_TIMEOUT: /* Connection timed out */
+ case LIBUSB_ERROR_OVERFLOW: /* Value too large for defined data type */
+ case LIBUSB_ERROR_PIPE: /* Broken pipe */
default:
/* Don't know what happened, try again later... */
continue;
@@ -0,0 +1,8 @@
--- scripts/Makefile.am.orig 2020-02-09 10:44:01.000000000 -0800
+++ scripts/Makefile.am 2020-03-24 19:40:01.084978000 -0700
@@ -25,4 +25,4 @@
Windows/halt.c \
Windows/Makefile
-SUBDIRS = augeas devd hotplug python systemd udev Solaris upsdrvsvcctl
+SUBDIRS = augeas devd hotplug python udev upsdrvsvcctl
+7
View File
@@ -0,0 +1,7 @@
This is a developing project to monitor a large assortment of UPS hardware.
Network communications are used so that multiple systems can monitor a
single physical UPS and shut down together if necessary without any
special "sharing hardware" on the UPS itself. CGI scripts are provided
to monitor UPS status via a WEB browser.
WWW: http://www.networkupstools.org/
+257
View File
@@ -0,0 +1,257 @@
%%NUT_CGI%%%%CGIDIR%%/upsimage.cgi
%%NUT_CGI%%%%CGIDIR%%/upsset.cgi
%%NUT_CGI%%%%CGIDIR%%/upsstats.cgi
%%NUT_CGI%%@sample %%CGIETCDIR%%hosts.conf.sample
%%NUT_CGI%%@sample %%CGIETCDIR%%upsset.conf.sample
%%NUT_CGI%%@sample %%CGIETCDIR%%upsstats.html.sample
%%NUT_CGI%%@sample %%CGIETCDIR%%upsstats-single.html.sample
%%NUT_CGI%%%%WWWDIR%%/bottom.html
%%NUT_CGI%%%%WWWDIR%%/header.html
%%NUT_CGI%%%%WWWDIR%%/index.html
%%NUT_CGI%%%%WWWDIR%%/nut-banner.png
%%ETCDIR%%/cmdvartab
%%ETCDIR%%/driver.list
@sample %%ETCDIR%%/nut.conf.sample
@sample %%ETCDIR%%/ups.conf.sample
@sample %%ETCDIR%%/upsd.conf.sample
@sample %%ETCDIR%%/upsd.users.sample
@sample %%ETCDIR%%/upsmon.conf.sample
@sample %%ETCDIR%%/upssched.conf.sample
@sample %%EXAMPLESDIR%%/newsyslog.sample etc/newsyslog.conf.d/nut.conf
@sample %%EXAMPLESDIR%%/syslog.sample etc/syslog.d/nut
%%NUT_USB%%etc/devd/nut-usb.conf
@stopdaemon nut_upsmon
@stopdaemon nut_upslog
@stopdaemon nut
bin/upsc
bin/upscmd
bin/upslog
bin/upsrw
bin/upssched-cmd
%%BASH%%etc/bash_completion.d/nut.bash_completion
include/nut-scan.h
include/nutclient.h
include/nutscan-device.h
include/nutscan-init.h
include/nutscan-ip.h
include/nutscan-serial.h
include/parseconf.h
include/upsclient.h
lib/libnutclient.a
lib/libnutclient.so
lib/libnutclient.so.1
lib/libnutclient.so.1.0.0
lib/libupsclient.a
lib/libupsclient.so
lib/libupsclient.so.5
lib/libupsclient.so.5.0.0
libdata/pkgconfig/libnutclient.pc
libdata/pkgconfig/libnutscan.pc
libdata/pkgconfig/libupsclient.pc
%%NUT_SERIAL%%libexec/nut/al175
%%NUT_SERIAL%%libexec/nut/apcupsd-ups
%%NUT_USB%%libexec/nut/nutdrv_atcl_usb
%%NUT_USB%%libexec/nut/nutdrv_qx
%%NUT_SERIAL%%libexec/nut/riello_ser
%%NUT_USB%%libexec/nut/riello_usb
%%NUT_SERIAL%%libexec/nut/apcsmart
%%NUT_SERIAL%%libexec/nut/apcsmart-old
%%NUT_SERIAL%%libexec/nut/bcmxcp
%%NUT_USB%%libexec/nut/bcmxcp_usb
%%NUT_SERIAL%%libexec/nut/belkin
%%NUT_SERIAL%%libexec/nut/belkinunv
%%NUT_SERIAL%%libexec/nut/bestfcom
%%NUT_SERIAL%%libexec/nut/bestfortress
%%NUT_SERIAL%%libexec/nut/bestuferrups
%%NUT_SERIAL%%libexec/nut/bestups
%%NUT_SERIAL%%libexec/nut/blazer_ser
%%NUT_USB%%libexec/nut/blazer_usb
%%NUT_SERIAL%%libexec/nut/clone
%%NUT_SERIAL%%libexec/nut/clone-outlet
%%NUT_SERIAL%%libexec/nut/dummy-ups
%%NUT_SERIAL%%libexec/nut/etapro
%%NUT_SERIAL%%libexec/nut/everups
%%NUT_SERIAL%%libexec/nut/gamatronic
%%NUT_SERIAL%%libexec/nut/genericups
%%NUT_SERIAL%%libexec/nut/isbmex
%%NUT_SERIAL%%libexec/nut/ivtscd
%%NUT_SERIAL%%libexec/nut/liebert
%%NUT_SERIAL%%libexec/nut/liebert-esp2
%%NUT_SERIAL%%libexec/nut/masterguard
%%NUT_SERIAL%%libexec/nut/metasys
%%NUT_SERIAL%%libexec/nut/mge-utalk
%%NUT_SERIAL%%libexec/nut/microdowell
%%NUT_SERIAL%%libexec/nut/mge-shut
%%NUT_NEON%%libexec/nut/netxml-ups
%%NUT_SERIAL%%libexec/nut/oneac
%%NUT_SERIAL%%libexec/nut/optiups
%%NUT_IPMIPSU%%libexec/nut/nut-ipmipsu
%%NUT_SERIAL%%libexec/nut/nutdrv_siemens-sitop
%%NUT_SERIAL%%libexec/nut/powercom
%%NUT_PDU%%libexec/nut/powerman-pdu
%%NUT_SERIAL%%libexec/nut/powerpanel
%%NUT_SERIAL%%libexec/nut/rhino
%%NUT_USB%%libexec/nut/richcomm_usb
%%NUT_SERIAL%%libexec/nut/safenet
%%NUT_SERIAL%%libexec/nut/skel
%%NUT_SNMP%%libexec/nut/snmp-ups
%%NUT_SERIAL%%libexec/nut/solis
%%NUT_SERIAL%%libexec/nut/tripplite
%%NUT_USB%%libexec/nut/tripplite_usb
%%NUT_SERIAL%%libexec/nut/tripplitesu
%%NUT_SERIAL%%libexec/nut/upscode2
%%NUT_USB%%libexec/nut/usbhid-ups
%%NUT_SERIAL%%libexec/nut/victronups
man/man3/libnutclient.3.gz
man/man3/libnutclient_commands.3.gz
man/man3/libnutclient_devices.3.gz
man/man3/libnutclient_general.3.gz
man/man3/libnutclient_misc.3.gz
man/man3/libnutclient_tcp.3.gz
man/man3/libnutclient_variables.3.gz
man/man3/nutclient_authenticate.3.gz
man/man3/nutclient_destroy.3.gz
man/man3/nutclient_device_forced_shutdown.3.gz
man/man3/nutclient_device_login.3.gz
man/man3/nutclient_device_master.3.gz
man/man3/nutclient_execute_device_command.3.gz
man/man3/nutclient_get_device_command_description.3.gz
man/man3/nutclient_get_device_commands.3.gz
man/man3/nutclient_get_device_description.3.gz
man/man3/nutclient_get_device_num_logins.3.gz
man/man3/nutclient_get_device_rw_variables.3.gz
man/man3/nutclient_get_device_variable_description.3.gz
man/man3/nutclient_get_device_variable_values.3.gz
man/man3/nutclient_get_device_variables.3.gz
man/man3/nutclient_get_devices.3.gz
man/man3/nutclient_has_device.3.gz
man/man3/nutclient_has_device_command.3.gz
man/man3/nutclient_has_device_variable.3.gz
man/man3/nutclient_logout.3.gz
man/man3/nutclient_set_device_variable_value.3.gz
man/man3/nutclient_set_device_variable_values.3.gz
man/man3/nutclient_tcp_create_client.3.gz
man/man3/nutclient_tcp_disconnect.3.gz
man/man3/nutclient_tcp_get_timeout.3.gz
man/man3/nutclient_tcp_is_connected.3.gz
man/man3/nutclient_tcp_reconnect.3.gz
man/man3/nutclient_tcp_set_timeout.3.gz
man/man3/nutscan.3.gz
man/man3/nutscan_add_device_to_device.3.gz
man/man3/nutscan_add_option_to_device.3.gz
man/man3/nutscan_cidr_to_ip.3.gz
man/man3/nutscan_display_parsable.3.gz
man/man3/nutscan_display_ups_conf.3.gz
man/man3/nutscan_free_device.3.gz
man/man3/nutscan_get_serial_ports_list.3.gz
man/man3/nutscan_init.3.gz
man/man3/nutscan_new_device.3.gz
man/man3/nutscan_scan_avahi.3.gz
man/man3/nutscan_scan_eaton_serial.3.gz
man/man3/nutscan_scan_ipmi.3.gz
man/man3/nutscan_scan_nut.3.gz
man/man3/nutscan_scan_snmp.3.gz
man/man3/nutscan_scan_usb.3.gz
man/man3/nutscan_scan_xml_http.3.gz
man/man3/upscli_add_host_cert.3.gz
man/man3/upscli_cleanup.3.gz
man/man3/upscli_connect.3.gz
man/man3/upscli_disconnect.3.gz
man/man3/upscli_fd.3.gz
man/man3/upscli_get.3.gz
man/man3/upscli_init.3.gz
man/man3/upscli_list_next.3.gz
man/man3/upscli_list_start.3.gz
man/man3/upscli_readline.3.gz
man/man3/upscli_readline_timeout.3.gz
man/man3/upscli_sendline.3.gz
man/man3/upscli_sendline_timeout.3.gz
man/man3/upscli_splitaddr.3.gz
man/man3/upscli_splitname.3.gz
man/man3/upscli_ssl.3.gz
man/man3/upscli_strerror.3.gz
man/man3/upscli_upserror.3.gz
man/man3/upsclient.3.gz
man/man5/nut.conf.5.gz
man/man5/ups.conf.5.gz
man/man5/upsd.conf.5.gz
man/man5/upsd.users.5.gz
man/man5/upsmon.conf.5.gz
man/man5/upssched.conf.5.gz
%%NUT_SERIAL%%man/man8/al175.8.gz
%%NUT_SERIAL%%man/man8/apcupsd-ups.8.gz
%%NUT_SERIAL%%man/man8/blazer_ser.8.gz
%%NUT_USB%%man/man8/blazer_usb.8.gz
%%NUT_NEON%%man/man8/netxml-ups.8.gz
man/man8/nut-driver-enumerator.8.gz
man/man8/nut-recorder.8.gz
man/man8/nut-scanner.8.gz
%%NUT_USB%%man/man8/nutdrv_atcl_usb.8.gz
%%NUT_USB%%man/man8/nutdrv_qx.8.gz
man/man8/nutupsdrv.8.gz
%%NUT_SERIAL%%man/man8/riello_ser.8.gz
%%NUT_USB%%man/man8/riello_usb.8.gz
man/man8/upsc.8.gz
man/man8/upscmd.8.gz
man/man8/upsd.8.gz
man/man8/upsdrvctl.8.gz
man/man8/upsdrvsvcctl.8.gz
man/man8/upslog.8.gz
man/man8/upsmon.8.gz
man/man8/upsrw.8.gz
man/man8/upssched.8.gz
%%NUT_CGI%%man/man5/hosts.conf.5.gz
%%NUT_CGI%%man/man5/upsset.conf.5.gz
%%NUT_CGI%%man/man5/upsstats.html.5.gz
%%NUT_CGI%%man/man8/upsset.cgi.8.gz
%%NUT_CGI%%man/man8/upsstats.cgi.8.gz
%%NUT_CGI%%man/man8/upsimage.cgi.8.gz
%%NUT_SERIAL%%man/man8/apcsmart.8.gz
%%NUT_SERIAL%%man/man8/apcsmart-old.8.gz
%%NUT_SERIAL%%man/man8/bestfortress.8.gz
%%NUT_SERIAL%%man/man8/bcmxcp.8.gz
%%NUT_SERIAL%%man/man8/belkin.8.gz
%%NUT_SERIAL%%man/man8/belkinunv.8.gz
%%NUT_SERIAL%%man/man8/bestuferrups.8.gz
%%NUT_SERIAL%%man/man8/bestups.8.gz
%%NUT_SERIAL%%man/man8/bestfcom.8.gz
%%NUT_SERIAL%%man/man8/clone.8.gz
%%NUT_SERIAL%%man/man8/dummy-ups.8.gz
%%NUT_SERIAL%%man/man8/etapro.8.gz
%%NUT_SERIAL%%man/man8/everups.8.gz
%%NUT_SERIAL%%man/man8/gamatronic.8.gz
%%NUT_SERIAL%%man/man8/genericups.8.gz
%%NUT_SERIAL%%man/man8/isbmex.8.gz
%%NUT_SERIAL%%man/man8/ivtscd.8.gz
%%NUT_SERIAL%%man/man8/liebert.8.gz
%%NUT_SERIAL%%man/man8/liebert-esp2.8.gz
%%NUT_SERIAL%%man/man8/masterguard.8.gz
%%NUT_SERIAL%%man/man8/metasys.8.gz
%%NUT_SERIAL%%man/man8/mge-shut.8.gz
%%NUT_SERIAL%%man/man8/mge-utalk.8.gz
%%NUT_SERIAL%%man/man8/microdowell.8.gz
%%NUT_SERIAL%%man/man8/oneac.8.gz
%%NUT_SERIAL%%man/man8/optiups.8.gz
%%NUT_SERIAL%%man/man8/powercom.8.gz
%%NUT_SERIAL%%man/man8/powerpanel.8.gz
%%NUT_SERIAL%%man/man8/rhino.8.gz
%%NUT_SERIAL%%man/man8/safenet.8.gz
%%NUT_SERIAL%%man/man8/solis.8.gz
%%NUT_SERIAL%%man/man8/tripplite.8.gz
%%NUT_SERIAL%%man/man8/tripplitesu.8.gz
%%NUT_SERIAL%%man/man8/upscode2.8.gz
%%NUT_SERIAL%%man/man8/victronups.8.gz
%%NUT_USB%%man/man8/bcmxcp_usb.8.gz
%%NUT_USB%%man/man8/richcomm_usb.8.gz
%%NUT_USB%%man/man8/tripplite_usb.8.gz
%%NUT_USB%%man/man8/usbhid-ups.8.gz
%%NUT_SNMP%%man/man8/snmp-ups.8.gz
%%NUT_IPMIPSU%%man/man8/nut-ipmipsu.8.gz
%%NUT_PDU%%man/man8/powerman-pdu.8.gz
sbin/upsd
sbin/upsdrvctl
sbin/upsmon
sbin/upssched
@dir(%%NUT_USER%%,%%NUT_GROUP%%,750) %%STATEDIR%%
@dir libexec/nut
@dir(%%NUT_USER%%,%%NUT_GROUP%%,) /var/log/nut