Imported Upstream version 2.6.2

This commit is contained in:
Arnaud Quette 2011-09-29 20:14:46 +02:00
parent a367d9bc54
commit 45043b58d0
246 changed files with 18228 additions and 1415 deletions

View file

@ -1,4 +1,5 @@
EXTRA_DIST = README \
avahi/nut.service.in \
HP-UX/Makefile \
HP-UX/nut-drvctl \
HP-UX/nut-drvctl.sh \
@ -22,4 +23,4 @@ upower/95-upower-hid.rules \
Windows/halt.c \
Windows/Makefile
SUBDIRS = augeas hal hotplug python udev
SUBDIRS = augeas hal hotplug java python systemd udev

View file

@ -43,6 +43,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
@ -149,10 +151,14 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
@ -190,6 +196,10 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
@ -254,6 +264,8 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
@ -264,6 +276,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevdir = @udevdir@
EXTRA_DIST = README \
avahi/nut.service.in \
HP-UX/Makefile \
HP-UX/nut-drvctl \
HP-UX/nut-drvctl.sh \
@ -287,7 +300,7 @@ upower/95-upower-hid.rules \
Windows/halt.c \
Windows/Makefile
SUBDIRS = augeas hal hotplug python udev
SUBDIRS = augeas hal hotplug java python systemd udev
all: all-recursive
.SUFFIXES:

View file

@ -7,7 +7,9 @@ specific USB devices,
- UPower (previously DeviceKit-power) rules file,
- Python Client module and application,
- Perl client module,
- Augeas support lenses and modules for NUT.
- Augeas support lenses and modules for NUT,
- Java client library and test application,
- systemd support files.
They have either been contributed by users of the software, or by the NUT Team
itself.

View file

@ -48,6 +48,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
@ -116,10 +118,14 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
@ -157,6 +163,10 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
@ -221,6 +231,8 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@

View file

@ -203,3 +203,59 @@ Test the conformity testing module
Existing configuration files can be tested for conformity. To do so, use:
$ augparse -I ./ ./test_nut.aug
Complete configuration wizard example
-------------------------------------
Here is a Python example that generate a complete and usable standalone configuration:
--------------------------------------------------------------------------------
import augeas
device_name="dev1"
driver_name="usbhid-ups"
port_name="auto"
a = augeas.augeas()
# Generate nut.conf
a.set("/files/etc/nut/nut.conf/MODE", "standalone")
# Generate ups.conf
# FIXME: chroot, driverpath?
a.set(("/files/etc/nut/ups.conf/%s/driver" % device_name), driver_name)
a.set(("/files/etc/nut/ups.conf/%s/port" % device_name), port_name)
# Generate upsd.conf
a.set("/files/etc/nut/upsd.conf/#comment[1]", "just to touch the file!")
# Generate upsd.users
user = "admin"
a.set(("/files/etc/nut/upsd.users/%s/password" % user), "dummypass")
a.set(("/files/etc/nut/upsd.users/%s/actions/SET" % user), "")
# FIXME: instcmds lens should be fixed, as per the above rule
a.set(("/files/etc/nut/upsd.users/%s/instcmds" % user), "ALL")
monuser = "monuser"
monpasswd = "******"
a.set(("/files/etc/nut/upsd.users/%s/password" % monuser), monpasswd)
a.set(("/files/etc/nut/upsd.users/%s/upsmon" % monuser), "master")
# Generate upsmon.conf
a.set("/files/etc/nut/upsmon.conf/MONITOR/system/upsname", device_name)
# Note: we prefer to omit localhost, not to be bound to a specific
# entry in /etc/hosts, and thus be more generic
#a.set("/files/etc/nut/upsmon.conf/MONITOR/system/hostname", "localhost")
a.set("/files/etc/nut/upsmon.conf/MONITOR/powervalue", "1")
a.set("/files/etc/nut/upsmon.conf/MONITOR/username", monuser)
a.set("/files/etc/nut/upsmon.conf/MONITOR/password", monpasswd)
a.set("/files/etc/nut/upsmon.conf/MONITOR/type", "master")
# FIXME: glitch on the generated content
a.set("/files/etc/nut/upsmon.conf/SHUTDOWNCMD", "/sbin/shutdown -h +0")
# save config
a.save()
a.close()
--------------------------------------------------------------------------------

View file

@ -54,6 +54,8 @@ let ups_fields = "driver"
| "advorder"
| "authPassword"
| "authProtocol"
| "authtype"
| "awd"
| "batteryPercentage"
| "battext"
| "baud_rate"
@ -70,6 +72,7 @@ let ups_fields = "driver"
| "fake_lowbatt"
| "flash"
| "frequency"
| "fruid"
| "full_update"
| "houroff"
| "houron"
@ -120,6 +123,7 @@ let ups_fields = "driver"
| "sdtype"
| "secLevel"
| "secName"
| "sensorid"
| "serial"
| "serialnumber"
| "shutdownArguments"
@ -139,6 +143,7 @@ let ups_fields = "driver"
| "usd"
| "use_crlf"
| "use_pre_lf"
| "username"
| "validationSequence"
| "vendor"
| "vendorid"

View file

@ -0,0 +1,34 @@
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<!--
This file is part of NUT - Network UPS Tools
NUT is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
NUT is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with NUT; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
-->
<!-- See avahi.service(5) for more information about this configuration file -->
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_nut._tcp</type>
<port>@PORT@</port>
</service>
</service-group>

View file

@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
@ -134,10 +136,14 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
@ -175,6 +181,10 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
@ -239,6 +249,8 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@

View file

@ -194,6 +194,24 @@
<merge key="battery.type" type="string">ups</merge>
</match>
</match>
<match key="usb_device.vendor_id" int="0x05b8">
<!-- Agiler UPS -->
<match key="usb_device.product_id" int="0x0000">
<append key="info.category" type="string">battery</append>
<merge key="info.capabilities" type="strlist">battery</merge>
<merge key="info.addons" type="strlist">hald-addon-blazer_usb</merge>
<merge key="battery.type" type="string">ups</merge>
</match>
</match>
<match key="usb_device.vendor_id" int="0x0665">
<!-- Belkin F6C1200-UNV -->
<match key="usb_device.product_id" int="0x5161">
<append key="info.category" type="string">battery</append>
<merge key="info.capabilities" type="strlist">battery</merge>
<merge key="info.addons" type="strlist">hald-addon-blazer_usb</merge>
<merge key="battery.type" type="string">ups</merge>
</match>
</match>
<!-- Phoenixtec -->
<match key="usb_device.vendor_id" int="0x06da">
@ -255,6 +273,15 @@
<merge key="battery.type" type="string">ups</merge>
</match>
</match>
<match key="usb_device.vendor_id" int="0x0925">
<!-- Sweex 1000VA -->
<match key="usb_device.product_id" int="0x1234">
<append key="info.category" type="string">battery</append>
<merge key="info.capabilities" type="strlist">battery</merge>
<merge key="info.addons" type="strlist">hald-addon-richcomm_usb</merge>
<merge key="battery.type" type="string">ups</merge>
</match>
</match>
<!-- TrippLite -->
<match key="usb_device.vendor_id" int="0x09ae">
@ -515,6 +542,15 @@
<merge key="battery.type" type="string">ups</merge>
</match>
</match>
<match key="usb_device.vendor_id" int="0x0f03">
<!-- Unitek Alpha 1200Sx -->
<match key="usb_device.product_id" int="0x0001">
<append key="info.category" type="string">battery</append>
<merge key="info.capabilities" type="strlist">battery</merge>
<merge key="info.addons" type="strlist">hald-addon-blazer_usb</merge>
<merge key="battery.type" type="string">ups</merge>
</match>
</match>
<!-- Liebert -->
<match key="usb_device.vendor_id" int="0x10af">
@ -526,6 +562,15 @@
<merge key="battery.type" type="string">ups</merge>
</match>
</match>
<match key="usb_device.vendor_id" int="0x14f0">
<!-- GE EP series -->
<match key="usb_device.product_id" int="0x00c9">
<append key="info.category" type="string">battery</append>
<merge key="info.capabilities" type="strlist">battery</merge>
<merge key="info.addons" type="strlist">hald-addon-blazer_usb</merge>
<merge key="battery.type" type="string">ups</merge>
</match>
</match>
</match>
</device>
</deviceinfo>

View file

@ -47,6 +47,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
@ -139,10 +141,14 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
@ -180,6 +186,10 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
@ -244,6 +254,8 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@

View file

@ -64,6 +64,10 @@ libhidups 0x0003 0x051d 0x0003 0x0000 0x0000 0x00
libhidups 0x0003 0x0592 0x0002 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# PW 9140
libhidups 0x0003 0x0592 0x0004 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# Agiler UPS
libhidups 0x0003 0x05b8 0x0000 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# Belkin F6C1200-UNV
libhidups 0x0003 0x0665 0x5161 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# Phoenixtec
# various models
@ -84,6 +88,8 @@ libhidups 0x0003 0x0764 0x0005 0x0000 0x0000 0x00
libhidups 0x0003 0x0764 0x0501 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# OR2200LCDRM2U
libhidups 0x0003 0x0764 0x0601 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# Sweex 1000VA
libhidups 0x0003 0x0925 0x1234 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# TrippLite
# e.g. OMNIVS1000, SMART550USB, ...
@ -160,7 +166,11 @@ libhidups 0x0003 0x0d9f 0x00a4 0x0000 0x0000 0x00
libhidups 0x0003 0x0d9f 0x00a5 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# PowerCOM BNT - Black Knight Pro
libhidups 0x0003 0x0d9f 0x00a6 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# Unitek Alpha 1200Sx
libhidups 0x0003 0x0f03 0x0001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# Liebert
# Liebert PowerSure PSA UPS
libhidups 0x0003 0x10af 0x0001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
# GE EP series
libhidups 0x0003 0x14f0 0x00c9 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000

15
scripts/java/Makefile.am Normal file
View file

@ -0,0 +1,15 @@
# TODO: Java / Maven build integration
EXTRA_DIST = README \
jNut/pom.xml \
jNut/README \
jNut/src/main/java/org/networkupstools/jnut/Client.java \
jNut/src/main/java/org/networkupstools/jnut/Command.java \
jNut/src/main/java/org/networkupstools/jnut/Device.java \
jNut/src/main/java/org/networkupstools/jnut/NutException.java \
jNut/src/main/java/org/networkupstools/jnut/StringLineSocket.java \
jNut/src/main/java/org/networkupstools/jnut/Variable.java \
jNut/src/test/java/org/networkupstools/jnut/ClientTest.java \
jNutList/pom.xml \
jNutList/README \
jNutList/src/main/java/org/networkupstools/jnutlist/AppList.java

441
scripts/java/Makefile.in Normal file
View file

@ -0,0 +1,441 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# TODO: Java / Maven build integration
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = scripts/java
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
$(top_srcdir)/m4/nut_check_libpowerman.m4 \
$(top_srcdir)/m4/nut_check_libssl.m4 \
$(top_srcdir)/m4/nut_check_libusb.m4 \
$(top_srcdir)/m4/nut_check_libwrap.m4 \
$(top_srcdir)/m4/nut_check_os.m4 \
$(top_srcdir)/m4/nut_config_libhal.m4 \
$(top_srcdir)/m4/nut_report_feature.m4 \
$(top_srcdir)/m4/nut_type_socklen_t.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
A2X = @A2X@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
ASCIIDOC = @ASCIIDOC@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BINDIR = @BINDIR@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CONFPATH = @CONFPATH@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DBLATEX = @DBLATEX@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DOC_BUILD_LIST = @DOC_BUILD_LIST@
DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@
DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@
DRIVER_MAN_LIST = @DRIVER_MAN_LIST@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAL_CALLOUTS_PATH = @HAL_CALLOUTS_PATH@
HAL_DEVICE_MATCH_KEY = @HAL_DEVICE_MATCH_KEY@
HAL_FDI_PATH = @HAL_FDI_PATH@
HAL_USER = @HAL_USER@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
LIBNETSNMP_LIBS = @LIBNETSNMP_LIBS@
LIBOBJS = @LIBOBJS@
LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@
LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@
LIBS = @LIBS@
LIBSSL_CFLAGS = @LIBSSL_CFLAGS@
LIBSSL_LIBS = @LIBSSL_LIBS@
LIBTOOL = @LIBTOOL@
LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
LIBUSB_LIBS = @LIBUSB_LIBS@
LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@
LIBWRAP_LIBS = @LIBWRAP_LIBS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NETLIBS = @NETLIBS@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_NAME = @OS_NAME@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
SED = @SED@
SERLIBS = @SERLIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STATEPATH = @STATEPATH@
STRIP = @STRIP@
SUN_LIBUSB = @SUN_LIBUSB@
VERSION = @VERSION@
WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
cgiexecdir = @cgiexecdir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
driverexecdir = @driverexecdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
hotplugdir = @hotplugdir@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgconfigdir = @pkgconfigdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevdir = @udevdir@
EXTRA_DIST = README \
jNut/pom.xml \
jNut/README \
jNut/src/main/java/org/networkupstools/jnut/Client.java \
jNut/src/main/java/org/networkupstools/jnut/Command.java \
jNut/src/main/java/org/networkupstools/jnut/Device.java \
jNut/src/main/java/org/networkupstools/jnut/NutException.java \
jNut/src/main/java/org/networkupstools/jnut/StringLineSocket.java \
jNut/src/main/java/org/networkupstools/jnut/Variable.java \
jNut/src/test/java/org/networkupstools/jnut/ClientTest.java \
jNutList/pom.xml \
jNutList/README \
jNutList/src/main/java/org/networkupstools/jnutlist/AppList.java
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/java/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu scripts/java/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

14
scripts/java/README Normal file
View file

@ -0,0 +1,14 @@
Java NUT Client files
~~~~~~~~~~~~~~~~~~~~~
This directory contains various NUT Client related java source files, written by
Emilien Kia, sponsored by Eaton, and released under GPL v2.
* "jNut": this directory contains maven project and source files for jNut,
which is a Java abstraction bundle to access NUT server(s).
You can use it in Java programs to access NUT's upsd data server in a simple
way, without having to know the NUT protocol.
* "jNutList": this directory contains maven project and source files for
jNutList, a simple Java example program using jNut which connect to an UPSD,
lists its ups and their variables and commands.

71
scripts/java/jNut/README Normal file
View file

@ -0,0 +1,71 @@
jNut library
~~~~~~~~~~~~
This directory contains source files for the jNut library,
which is a Java abstraction bundle to access NUT server(s).
You can use it in Java programs to access NUT's upsd data server in a simple
way, without having to know the NUT protocol.
jNut building requirements
^^^^^^^^^^^^^^^^^^^^^^^^^^
jNut requires to be build :
- A Java JDK 6 correctly set in environment (ie bin folder in path)
- A Maven 3 installation set in environment (ie bin folder in path) with
sufficient configuration (internet connection, local repository) to let maven
get all plugins to make processes.
jNut is written in Java SE 1.4 and is tuned to be compiled to Java 1.4 code
level so most of environment can use it.
jNut building
^^^^^^^^^^^^^
Once JDK and Maven installed and configured, just go into the jNut directory
and type:
mvn install
The produced package called 'jNut-x.x-xxx.jar' is located in 'target'
subdirectory.
jNut javadoc
^^^^^^^^^^^^
You can generate jNut javadoc by typing:
mvn javadoc:javadoc
Documentation will be generated in 'target/site/apidocs' subdirectory and its
entry point is located at 'target/site/apidocs/index.html'.
Workspace cleaning
^^^^^^^^^^^^^^^^^^
The jNut workspace can be cleaned by removing the 'target' subdirectory or by
typing:
mvn clean
Unit test notes
^^^^^^^^^^^^^^^
jNut sources embed some unit tests in the 'src/test/java' subdirectory.
These tests are based on JUnit and are executed between compilation and
packaging phases at each build.
Implementation notes
^^^^^^^^^^^^^^^^^^^^
Currently, jNut is not thread safe. It is not protected against concurrent
queries but queries to different clients can be done in parallel as there are
done on different sockets.
Moreover, jNut have no connection preservation system so servers can break down
connections due to timeout.
Application using retrieved data must forget them when a disconnection occurs.
If the application want to maintain the connection, it must implement a
ping-pong mecanism itself.
At present time, jNut do not support SSL connection. It is planned for near
future.

40
scripts/java/jNut/pom.xml Normal file
View file

@ -0,0 +1,40 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.networkupstools</groupId>
<artifactId>jNut</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jNut</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,619 @@
/* Client.java
Copyright (C) 2011 Eaton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.networkupstools.jnut;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
/**
* A jNut client is start point to dialog to UPSD.
* It can connect to an UPSD then retrieve its device list.
* It support authentication by login/password.
* <p>
* You can directly create and connect a client by using the
* Client(String host, int port, String login, String passwd) constructor
* or use a three phase construction:
* <ul>
* <li>empty constructor
* <li>setting host, port, login and password with setters
* <li>call empty connect()
* </ul>
* <p>
* Objects retrieved by Client are attached (directly or indirectly) to it.
* If the connection is closed, attached objects must not be used anymore (GC).
* <p>
* Note: The jNut Client does not support any reconnection nor ping mechanism,
* so the calling application must know the UPSD can timeout the connection.
* <p>
* Note: Retrieved values are not valid along the time, they are valid at the
* precise moment they are retrieved.
*
* @author <a href="mailto:EmilienKia@eaton.com">Emilien Kia</a>
*/
public class Client {
/**
* Host to which connect.
* Network name or IP.
* Default to "127.0.0.1"
*/
private String host = "127.0.0.1";
/**
* IP port.
* Default to 3493
*/
private int port = 3493;
/**
* Login to use to connect to UPSD.
*/
private String login = null;
/**
* Password to use to connect to UPSD.
*/
private String passwd = null;
/**
* Communication socket
*/
private StringLineSocket socket = null;
/**
* Get the host name or address to which client is (or will be) connected.
* @return Host name or address.
*/
public String getHost() {
return host;
}
/**
* Set the host name (or address) to which the client will intend to connect to at next connection.
* @param host New host name or address.
*/
public void setHost(String host) {
this.host = host;
}
/**
* Get the login with which the client is (or will be connected).
* @return The login.
*/
public String getLogin() {
return login;
}
/**
* Set the login with which the client will intend to connect.
* @param login New login.
*/
public void setLogin(String login) {
this.login = login;
}
/**
* Get the password with which the client is (or will be connected).
* @return The password.
*/
public String getPasswd() {
return passwd;
}
/**
* Set the password with which the client will intend to connect.
* @param passwd New password.
*/
public void setPasswd(String passwd) {
this.passwd = passwd;
}
/**
* Get the port to which client is (or will be) connected.
* @return Port number.
*/
public int getPort() {
return port;
}
/**
* Set the port to which client is (or will be) connected.
* @param port Port number.
*/
public void setPort(int port) {
this.port = port;
}
/**
* Default constructor.
*/
public Client()
{
}
/**
* Connection constructor.
* Construct the Client object and intend to connect.
* Throw an exception if cannot connect.
* @param host Host to which connect.
* @param port IP port.
* @param login Login to use to connect to UPSD.
* @param passwd Password to use to connect to UPSD.
*/
public Client(String host, int port, String login, String passwd) throws IOException, UnknownHostException, NutException
{
connect(host, port, login, passwd);
}
/**
* Intent to connect and authenticate to an UPSD with specified parameters.
* Throw an exception if cannot connect.
* @param host Host to which connect.
* @param port IP port.
* @param login Login to use to connect to UPSD.
* @param passwd Password to use to connect to UPSD.
*/
public void connect(String host, int port, String login, String passwd) throws IOException, UnknownHostException, NutException
{
this.host = host;
this.port = port;
this.login = login;
this.passwd = passwd;
connect();
}
/**
* Intent to connect to an UPSD with specified parameters without authentication.
* Throw an exception if cannot connect.
* @param host Host to which connect.
* @param port IP port.
*/
public void connect(String host, int port) throws IOException, UnknownHostException, NutException
{
this.host = host;
this.port = port;
connect();
}
/**
* Connection to UPSD with already specified parameters.
* Throw an exception if cannot connect.
*/
public void connect() throws IOException, UnknownHostException, NutException
{
// Force disconnect if another connection is alive.
if(socket!=null)
disconnect();
socket = new StringLineSocket(host, port);
authenticate();
}
/**
* Intend to authenticate with specified login and password, overriding
* already defined ones.
* @param login
* @param passwd
* @throws IOException
* @throws NutException
*/
public void authenticate(String login, String passwd) throws IOException, NutException
{
this.login = login;
this.passwd = passwd;
authenticate();
}
/**
* Intend to authenticate with alread set login and password.
* @throws IOException
* @throws NutException
*/
public void authenticate() throws IOException, NutException
{
// Send login
if(login!=null && !login.isEmpty())
{
String res = query("USERNAME", login);
if(!res.startsWith("OK"))
{
// Normaly response should be OK or ERR and nothing else.
throw new NutException(NutException.UnknownResponse, "Unknown response in Client.connect (USERNAME) : " + res);
}
}
// Send password
if(passwd!=null && !passwd.isEmpty())
{
String res = query("PASSWORD", passwd);
if(!res.startsWith("OK"))
{
// Normaly response should be OK or ERR and nothing else.
throw new NutException(NutException.UnknownResponse, "Unknown response in Client.connect (PASSWORD) : " + res);
}
}
}
/**
* Test if the client is connected to the UPSD.
* Note: it does not detect if the connection have been closed by server.
* @return True if connected.
*/
public boolean isConnected()
{
return socket!=null && socket.isConnected();
}
/**
* Disconnect.
*/
public void disconnect()
{
if(socket!=null)
{
try
{
if(socket.isConnected())
socket.close();
}
catch(IOException e)
{
e.printStackTrace();
}
socket = null;
}
}
/**
* Log out.
*/
public void logout()
{
if(socket!=null)
{
try
{
if(socket.isConnected())
{
socket.write("LOGOUT");
socket.close();
}
}
catch(IOException e)
{
e.printStackTrace();
}
socket = null;
}
}
/**
* Merge an array of stings into on string, with a space ' ' separator.
* @param str First string to merge
* @param strings Additionnal strings to merge
* @param sep Separator.
* @return The merged string, empty if no source string.
*/
static String merge(String str, String[] strings)
{
String res = str;
if(strings!=null)
{
for(int n=0; n<strings.length; n++)
{
res += " " + strings[n];
}
}
return res;
}
/**
* Intend to split a name/value string of the form '<name> "<value>"'.
* @param source String source to split.
* @return String couple with name and value.
*/
static String[] splitNameValueString(String source)
{
int pos = source.indexOf(' ');
if(pos<1)
return null;
String name = source.substring(0, pos);
String value = extractDoublequotedValue(source.substring(pos+1));
if(value==null)
return null;
String[] res = new String[2];
res[0] = name;
res[1] = value;
return res;
}
/**
* Intend to extract a value from its doublequoted and escaped representation.
* @param source Source string to convert.
* @return Extracted value
*/
static String extractDoublequotedValue(String source)
{
// Test doublequote at begin and end of string, then remove them.
if(!(source.startsWith("\"") && source.endsWith("\"")))
return null;
source = source.substring(1, source.length()-1);
// Unescape it.
return unescape(source);
}
/**
* Escape string with backslashes.
* @param str String to escape.
* @return Escaped string.
*/
static String escape(String str)
{
// Replace a backslash by two backslash (regexp)
str = str.replaceAll("\\\\", "\\\\\\\\");
// Replace a doublequote by backslash-doublequote (regexp)
str = str.replaceAll("\"", "\\\\\"");
return str;
}
/**
* Unescape string with backslashes.
* @param str String to unescape.
* @return Unescaped string.
*/
static String unescape(String str)
{
// Replace a backslash-doublequote by doublequote (regexp)
str = str.replaceAll("\\\\\"", "\"");
// Replace two backslash by a backslash (regexp)
str = str.replaceAll("\\\\\\\\", "\\\\");
return str;
}
/**
* Detect an UPSD ERR line.
* If found, parse it, construct and throw an NutException
* @param str Line to analyse.
* @throws NutException
*/
private void detectError(String str) throws NutException
{
if(str.startsWith("ERR "))
{
String[] arr = str.split(" ", 3);
switch(arr.length)
{
case 2:
throw new NutException(arr[1]);
case 3:
throw new NutException(arr[1], arr[2]);
default:
throw new NutException();
}
}
}
/**
* Send a query line then read the response.
* Helper around query(String).
* @param query Query to send.
* @param subquery Sub query to send.
* @return The reply.
* @throws IOException
*/
protected String query(String query, String subquery) throws IOException, NutException
{
return query(query + " " + subquery);
}
/**
* Send a query line then read the response.
* Helper around query(String, String ...).
* @param query Query to send.
* @param subquery Sub query to send.
* @param params Optionnal additionnal parameters.
* @return The reply.
* @throws IOException
*/
protected String query(String query, String subquery, String[] params) throws IOException, NutException
{
return query(query + " " + subquery, params);
}
/**
* Send a query line then read the response.
* @param query Query to send.
* @param params Optionnal additionnal parameters.
* @return The reply.
* @throws IOException
*/
protected String query(String query, String [] params) throws IOException, NutException
{
query = merge(query, params);
return query(query);
}
/**
* Send a query line then read the response.
* @param query Query to send.
* @return The reply.
* @throws IOException
*/
protected String query(String query) throws IOException, NutException
{
if(!isConnected())
return null;
socket.write(query);
String res = socket.read();
detectError(res);
return res;
}
/**
* Send a GET query line then read the reply and validate the response.
* @param subcmd GET subcommand to send.
* @param param Extra parameters
* @return GET result return by UPSD, without the subcommand and param prefix.
* @throws IOException
*/
protected String get(String subcmd, String param) throws IOException, NutException
{
String[] params = {param};
return get(subcmd, params);
}
/**
* Send a GET query line then read the reply and validate the response.
* @param subcmd GET subcommand to send.
* @param params Eventual extra parameters.
* @return GET result return by UPSD, without the subcommand and param prefix.
* @throws IOException
*/
protected String get(String subcmd, String [] params) throws IOException, NutException
{
if(!isConnected())
return null;
subcmd = merge(subcmd, params);
socket.write("GET " + subcmd);
String res = socket.read();
if(res==null)
return null;
detectError(res);
if(res.startsWith(subcmd + " "))
{
return res.substring(subcmd.length()+1);
}
else
{
return null;
}
}
/**
* Send a LIST query line then read replies and validate them.
* @param subcmd LIST subcommand to send.
* @return LIST results return by UPSD, without the subcommand and param prefix.
* @throws IOException
*/
protected String[] list(String subcmd) throws IOException, NutException
{
return list(subcmd, (String[])null);
}
/**
* Send a LIST query line then read replies and validate them.
* @param subcmd LIST subcommand to send.
* @param param Extra parameters.
* @return LIST results return by UPSD, without the subcommand and param prefix.
* @throws IOException
*/
protected String[] list(String subcmd, String param) throws IOException, NutException
{
String[] params = {param};
return list(subcmd, params);
}
/**
* Send a LIST query line then read replies and validate them.
* @param subcmd LIST subcommand to send.
* @param params Eventual extra parameters.
* @return LIST results return by UPSD, without the subcommand and param prefix.
* @throws IOException
*/
protected String[] list(String subcmd, String [] params) throws IOException, NutException
{
if(!isConnected())
return null;
subcmd = merge(subcmd, params);
socket.write("LIST " + subcmd);
String res = socket.read();
if(res==null)
return null;
detectError(res);
if(!res.startsWith("BEGIN LIST " + subcmd))
return null;
ArrayList/*<String>*/ list = new ArrayList/*<String>*/();
int sz = subcmd.length()+1;
while(true)
{
res = socket.read();
detectError(res);
if(!res.startsWith(subcmd + " "))
break;
list.add(res.substring(sz));
}
if(!res.equals("END LIST " + subcmd))
return null;
return (String[])list.toArray(new String[list.size()]);
}
/**
* Returns the list of available devices from the NUT server.
* @return List of devices, empty if nothing,
* null if not connected or failed.
*
*/
public Device[] getDeviceList() throws IOException, NutException
{
String[] res = list("UPS");
if(res==null)
return null;
ArrayList/*<Device>*/ list = new ArrayList/*<Device>*/();
for(int i=0; i<res.length; i++)
{
String[] arr = splitNameValueString(res[i]);
if(arr!=null)
{
list.add(new Device(arr[0], this));
}
}
return (Device[])list.toArray(new Device[list.size()]);
}
/**
* Intend to retrieve a device by its name.
* @param name Name of the device to look at.
* @return Device
* @throws IOException
* @throws NutException
*/
public Device getDevice(String name)throws IOException, NutException
{
// Note: an exception "DRIVER-NOT-CONNECT" should not prevent Device creation.
try{
get("UPSDESC", name);
}catch(NutException ex){
if(!ex.is(NutException.DriverNotConnected)){
throw ex;
}
}
return new Device(name, this);
}
}

View file

@ -0,0 +1,100 @@
/* Command.java
Copyright (C) 2011 Eaton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.networkupstools.jnut;
import java.io.IOException;
/**
* Class representing a command of a device.
* <p>
* It can be used to retrieve description and execute commands.
* A Command object can be retrieved from Device instance and can not be constructed directly.
*
* @author <a href="mailto:EmilienKia@eaton.com">Emilien Kia</a>
*/
public class Command {
/**
* Device to which command is attached
*/
Device device = null;
/**
* Command name
*/
String name = null;
/**
* Internally create a command.
* @param name Command name.
* @param device Device to which the command is attached.
*/
protected Command(String name, Device device)
{
this.device = device;
this.name = name;
}
/**
* Return the device to which the command can be executed.
* @return Attached device.
*/
public Device getDevice() {
return device;
}
/**
* Return the command name.
* @return Command name.
*/
public String getName() {
return name;
}
/**
* Retrieve the command description from UPSD and store it in cache.
* @return Command description
* @throws IOException
*/
public String getDescription() throws IOException, NutException {
if(device!=null && device.getClient()!=null)
{
String[] params = {device.getName(), name};
String res = device.getClient().get("CMDDESC", params);
return res!=null?Client.extractDoublequotedValue(res):null;
}
return null;
}
/**
* Execute the instant command.
* @throws IOException
*/
public void execute() throws IOException, NutException {
if(device!=null && device.getClient()!=null)
{
String[] params = {device.getName(), name};
String res = device.getClient().query("INSTCMD", params);
if(!res.equals("OK"))
{
// Normaly response should be OK or ERR and nothing else.
throw new NutException(NutException.UnknownResponse, "Unknown response in Command.execute : " + res);
}
}
}
}

View file

@ -0,0 +1,279 @@
/* Device.java
Copyright (C) 2011 Eaton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.networkupstools.jnut;
import java.io.IOException;
import java.util.ArrayList;
/**
* Class representing a device attached to a Client.
* <p>
* It can retrieve its description, its number of logins, its variable and command lists.
* A Device object can be retrieved from Client instance and can not be constructed directly.
*
* @author <a href="mailto:EmilienKia@eaton.com">Emilien Kia</a>
*/
public class Device {
/**
* Client to which device is attached
*/
Client client = null;
/**
* Device name
*/
String name = null;
/**
* Internally create a device.
* @param name Device name.
* @param client Client to which the device is attached.
*/
protected Device(String name, Client client)
{
this.client = client;
this.name = name;
}
/**
* Return the client to which the device is connected.
* @return Attached client.
*/
public Client getClient() {
return client;
}
/**
* Return the device name.
* @return Device name.
*/
public String getName() {
return name;
}
/**
* Retrieve the device description from UPSD and store it in cache.
* @return Device description
* @throws IOException
*/
public String getDescription() throws IOException, NutException {
if(client!=null)
{
return client.get("UPSDESC", name);
}
return null;
}
/**
* Log in to the ups.
* <p>
* Use this to log the fact that a system is drawing power from this UPS.
* The <i>upsmon</i> master will wait until the count of attached systems reaches
* 1 - itself. This allows the slaves to shut down first.
* <p>
* NOTE: You probably shouldn't send this command unless you are upsmon,
* or a upsmon replacement.
* @throws IOException
* @throws NutException
*/
public void login() throws IOException, NutException {
if(client!=null)
{
String res = client.query("LOGIN", name);
if(!res.startsWith("OK"))
{
// Normaly response should be OK or ERR and nothing else.
throw new NutException(NutException.UnknownResponse, "Unknown response in Device.login : " + res);
}
}
}
/**
* This function doesn't do much by itself. It is used by <i>upsmon</i> to make
* sure that master-level functions like FSD are available if necessary
* @throws IOException
* @throws NutException
*/
public void master() throws IOException, NutException {
if(client!=null)
{
String res = client.query("MASTER", name);
if(!res.startsWith("OK"))
{
// Normaly response should be OK or ERR and nothing else.
throw new NutException(NutException.UnknownResponse, "Unknown response in Device.master : " + res);
}
}
}
/**
* Set the "forced shutdown" flag.
* <p>
* <i>upsmon</i> in master mode is the primary user of this function. It sets this
* "forced shutdown" flag on any UPS when it plans to power it off. This is
* done so that slave systems will know about it and shut down before the
* power disappears.
* <p>
* Setting this flag makes "FSD" appear in a STATUS request for this UPS.
* Finding "FSD" in a status request should be treated just like a "OB LB".
* <p>
* It should be noted that FSD is currently a latch - once set, there is
* no way to clear it short of restarting upsd or dropping then re-adding
* it in the ups.conf. This may cause issues when upsd is running on a
* system that is not shut down due to the UPS event.
* @throws IOException
* @throws NutException
*/
public void setForcedShutdown() throws IOException, NutException {
if(client!=null)
{
String res = client.query("FSD", name);
if(!res.startsWith("OK"))
{
// Normaly response should be OK or ERR and nothing else.
throw new NutException(NutException.UnknownResponse, "Unknown response in Device.setForcedShutdown : " + res);
}
}
}
/**
* Return the number of clients which have done LOGIN for this UPS.
* Force to retrieve it from UPSD and store it in cache.
* @return Number of clients, -1 if error.
* @throws IOException
*/
public int getNumLogin() throws IOException, NutException {
if(client!=null)
{
String res = client.get("NUMLOGINS", name);
return res!=null?Integer.parseInt(res):-1;
}
return -1;
}
/**
* Return the list of device variables from the NUT server.
* @return List of variables, empty if nothing,
* null if not connected or failed.
* @throws IOException
*/
public Variable[] getVariableList() throws IOException, NutException {
if(client==null)
return null;
String[] res = client.list("VAR", name);
if(res==null)
return null;
ArrayList/*<Variable>*/ list = new ArrayList/*<Variable>*/();
for(int i=0; i<res.length; i++)
{
String[] arr = Client.splitNameValueString(res[i]);
if(arr!=null)
{
list.add(new Variable(arr[0], this));
}
}
return (Variable[])list.toArray(new Variable[list.size()]);
}
/**
* Return the list of device RW variables from the NUT server.
* @return List of variables, empty if nothing,
* null if not connected or failed.
* @throws IOException
*/
public Variable[] getRWVariableList() throws IOException, NutException {
if(client==null)
return null;
String[] res = client.list("RW", name);
if(res==null)
return null;
ArrayList/*<Variable>*/ list = new ArrayList/*<Variable>*/();
for(int i=0; i<res.length; i++)
{
String[] arr = Client.splitNameValueString(res[i]);
if(arr!=null)
{
list.add(new Variable(arr[0], this));
}
}
return (Variable[])list.toArray(new Variable[list.size()]);
}
/**
* Return a variable from its name.
* @param name Name of the queried variable.
* @return The corresponding variable object if exists.
* @throws IOException
* @throws NutException
*/
public Variable getVariable(String name) throws IOException, NutException {
if(client==null)
return null;
String[] params = {this.name, name};
client.get("VAR", params);
return new Variable(name, this);
}
/**
* Return the list of device commands from the NUT server.
* @return List of commands, empty if nothing,
* null if not connected or failed.
* @throws IOException
*/
public Command[] getCommandList() throws IOException, NutException {
if(client==null)
return null;
String[] res = client.list("CMD", name);
if(res==null)
return null;
ArrayList/*<Command>*/ list = new ArrayList/*<Command>*/();
for(int i=0; i<res.length; i++)
{
list.add(new Command(res[i], this));
}
return (Command[])list.toArray(new Command[list.size()]);
}
/**
* Return a command from its name.
* @param name Name of the queried command.
* @return The corresponding command object if exists.
* @throws IOException
* @throws NutException
*/
public Command getCommand(String name)throws IOException, NutException {
if(client==null)
return null;
String[] params = {this.name, name};
String res = client.get("CMDDESC", params);
// Note: there is no way to test if the command is really available or not
// because a GET CMDDESC ups badcmdname does not return an error.
return new Command(name, this);
}
}

View file

@ -0,0 +1,107 @@
/* NutException.java
Copyright (C) 2011 Eaton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.networkupstools.jnut;
/**
* Class representing a NUT exception.
* <p>
* Instance are thrown when an UPSD returns an error with an "ERR" directive.
* Moreover it can ben thrown with some extra errors like:
* <ul>
* <li>UNKNOWN-RESPONSE : The response is not understood
* </ul>
* <p>
* A Nut exception has a (standard java exception message) message which correspond
* to error code returns by UPSD (like 'ACCESS-DENIED', 'UNKNOWN-UPS' ...).
* An extra string embed a more descriptive english message.
*
* @author <a href="mailto:EmilienKia@eaton.com">Emilien Kia</a>
*/
public class NutException extends java.lang.Exception{
public static String UnknownResponse = "UNKNOWN-RESPONSE";
public static String DriverNotConnected = "DRIVER-NOT-CONNECTED";
public String extra = "";
public NutException()
{
}
public NutException(String message)
{
super(message);
}
public NutException(String message, String extra)
{
super(message);
this.extra = extra;
}
public NutException(Throwable cause)
{
super(cause);
}
public NutException(String message, Throwable cause)
{
super(message, cause);
}
public NutException(String message, String extra, Throwable cause)
{
super(message, cause);
this.extra = extra;
}
/**
* Returns the extra message.
* @return Extra message if any.
*/
public String getExtra() {
return extra;
}
/**
* Set the extra message.
* @param extra The new extra message.
*/
public void setExtra(String extra) {
this.extra = extra;
}
/**
* Test is the exception corresponds to the specified name.
* @param name Name to test
* @return True if exception corresponds.
*/
public boolean is(String name) {
return getMessage()!=null&&getMessage().equals(name);
}
/**
* Format an exception message.
* @return Exception message
*/
public String toString() {
return "[" + getClass().getSimpleName() + "]" + getMessage() + " : " + getExtra();
}
}

View file

@ -0,0 +1,137 @@
/* StringLineSocket.java
Copyright (C) 2011 Eaton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.networkupstools.jnut;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;
/**
* Class representing a socket, internally used to communicate with UPSD.
* Abstract some stream mechanisms.
*
* @author <a href="mailto:EmilienKia@eaton.com">Emilien Kia</a>
*/
class StringLineSocket {
/**
* Real internal TCP socket.
*/
Socket socket = null;
/**
* Writer to the socket.
*/
private OutputStreamWriter writer = null;
/**
* Reader from the socket.
*/
private BufferedReader reader = null;
/**
* Create a new line socket.
*/
public StringLineSocket(){
}
/**
* Create a new line socket and connect it.
* @param host Host to connect to
* @param port Port to connect to
* @throws UnknownHostException
* @throws IOException
*/
public StringLineSocket(String host, int port) throws UnknownHostException, IOException{
connect(host, port);
}
/**
* Connect a new line socket.
* @param host Host to connect to
* @param port Port to connect to
* @throws UnknownHostException
* @throws IOException
*/
public void connect(String host, int port) throws UnknownHostException, IOException{
socket = new Socket(host, port);
if(socket!=null)
{
reader = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
writer = new OutputStreamWriter(socket.getOutputStream());
}
}
/**
* Close the socket.
*/
public void close() throws IOException{
if(socket!=null){
writer.close();
reader.close();
socket.close();
socket = null;
writer = null;
reader = null;
}
}
/**
* Test if the soecket is connected.
* @return True if connected.
*/
public boolean isConnected() {
return socket!=null && socket.isConnected() && !socket.isClosed();
}
/**
* Write a line follow by a '\n' character.
* @param line
* @throws IOException
*/
public void write(String line) throws IOException
{
if(isConnected())
{
writer.write(line + "\n");
writer.flush();
}
}
/**
* Read a line terminated by a '\n'.
* @return The line without the ending '\n'
* @throws IOException
*/
public String read() throws IOException
{
if(isConnected())
{
String res = reader.readLine();
return res;
}
return "";
}
}

View file

@ -0,0 +1,120 @@
/* Variable.java
Copyright (C) 2011 Eaton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.networkupstools.jnut;
import java.io.IOException;
/**
* Class representing a variable of a device.
* <p>
* It can be used to get and set its value (if possible).
* A Variable object can be retrieved from Device instance and can not be constructed directly.
*
* @author <a href="mailto:EmilienKia@eaton.com">Emilien Kia</a>
*/
public class Variable {
/**
* Device to which variable is attached
*/
Device device = null;
/**
* Variable name
*/
String name = null;
/**
* Internally create a variable.
* @param name Variable name.
* @param device Device to which the variable is attached.
*/
protected Variable(String name, Device device)
{
this.device = device;
this.name = name;
}
/**
* Return the device to which the variable is related.
* @return Attached device.
*/
public Device getDevice() {
return device;
}
/**
* Return the variable name.
* @return Command name.
*/
public String getName() {
return name;
}
/**
* Retrieve the variable value from UPSD and store it in cache.
* @return Variable value
* @throws IOException
*/
public String getValue() throws IOException, NutException {
if(device!=null && device.getClient()!=null)
{
String[] params = {device.getName(), name};
String res = device.getClient().get("VAR", params);
return res!=null?Client.extractDoublequotedValue(res):null;
}
return null;
}
/**
* Retrieve the variable description from UPSD and store it in cache.
* @return Variable description
* @throws IOException
*/
public String getDescription() throws IOException, NutException {
if(device!=null && device.getClient()!=null)
{
String[] params = {device.getName(), name};
String res = device.getClient().get("DESC", params);
return res!=null?Client.extractDoublequotedValue(res):null;
}
return null;
}
/**
* Set the variable value.
* Note the new value can be applied with a little delay depending of UPSD and connection.
* @param value New value for the variable
* @throws IOException
*/
public void setValue(String value) throws IOException, NutException {
if(device!=null && device.getClient()!=null)
{
String[] params = {"VAR", device.getName(),
name, " \"" + Client.escape(value) + "\""};
String res = device.getClient().query("SET", params);
if(!res.equals("OK"))
{
// Normaly response should be OK or ERR and nothing else.
throw new NutException(NutException.UnknownResponse, "Unknown response in Variable.setValue : " + res);
}
}
}
// TODO Add query for type and enum values
}

View file

@ -0,0 +1,95 @@
package org.networkupstools.jnut;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class ClientTest extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public ClientTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( ClientTest.class );
}
/**
* Escape function test.
*/
public void testEscape()
{
assertEquals("Empty string", "", Client.escape(""));
assertEquals("Simple string", "hello", Client.escape("hello"));
assertEquals("Internal doublequote", "he\\\"llo", Client.escape("he\"llo"));
assertEquals("Internal backslash", "he\\\\llo", Client.escape("he\\llo"));
assertEquals("Internal backslash and doublequote", "he\\\\\\\"llo", Client.escape("he\\\"llo"));
assertEquals("Initial and final doublequote", "\\\"hello\\\"", Client.escape("\"hello\""));
}
/**
* Unescape function test.
*/
public void testUnescape()
{
assertEquals("Empty string", "", Client.unescape(""));
assertEquals("Simple string", "hello", Client.unescape("hello"));
assertEquals("Internal doublequote", "he\"llo", Client.unescape("he\\\"llo"));
assertEquals("Internal backslash", "he\\llo", Client.unescape("he\\\\llo"));
assertEquals("Internal backslash and doublequote", "he\\\"llo", Client.unescape("he\\\\\\\"llo"));
assertEquals("Initial and final doublequote", "\"hello\"", Client.unescape("\\\"hello\\\""));
}
/**
* extractDoublequotedValue function test.
*/
public void testExtractDoublequotedValue()
{
assertNull("Empty string", Client.extractDoublequotedValue(""));
assertNull("Non doublequoted string", Client.extractDoublequotedValue("hello"));
assertNull("No begining doublequote", Client.extractDoublequotedValue("hello\""));
assertNull("No ending doublequote", Client.extractDoublequotedValue("\"hello"));
assertEquals("Simple string", "hello", Client.extractDoublequotedValue("\"hello\""));
assertEquals("String with doublequote", "he\"llo", Client.extractDoublequotedValue("\"he\\\"llo\""));
assertEquals("String with backslash", "he\\llo", Client.extractDoublequotedValue("\"he\\\\llo\""));
assertEquals("String with backslash and doublequote", "he\\\"llo", Client.extractDoublequotedValue("\"he\\\\\\\"llo\""));
}
/**
* splitNameValueString function test.
*/
public void testSplitNameValueString()
{
String[] res;
assertNull("Empty string", Client.splitNameValueString(""));
assertNull("One word string", Client.splitNameValueString("name"));
assertNull("Non doublequoted string", Client.extractDoublequotedValue("name value"));
assertNull("No begining doublequote", Client.extractDoublequotedValue("name value\""));
assertNull("No ending doublequote", Client.extractDoublequotedValue("name \"value"));
res = Client.splitNameValueString("name \"value\"");
assertEquals("Simple name/value (name)", "name", res[0]);
assertEquals("Simple name/value (value)", "value", res[1]);
res = Client.splitNameValueString("name \"complex value\"");
assertEquals("Simple name / complex value (name)", "name", res[0]);
assertEquals("Simple name / complex value (value)", "complex value", res[1]);
res = Client.splitNameValueString("name \"complex\\\\value\"");
assertEquals("Simple name / backslash value (name)", "name", res[0]);
assertEquals("Simple name / backslash value (value)", "complex\\value", res[1]);
res = Client.splitNameValueString("name \"complex\\\"value\"");
assertEquals("Simple name / doublequote value (name)", "name", res[0]);
assertEquals("Simple name / doublequote value (value)", "complex\"value", res[1]);
}
}

View file

@ -0,0 +1,30 @@
jNutList example application
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This directory contains source files for the jNutList application.
It allows to connect to an UPSD then retrieve devices and their variables.
It is a little example application to show how to use jNut.
jNutList building
^^^^^^^^^^^^^^^^^
As jNut, jNutList is a maven project so a maven environment must be set.
Please reffer to jNut building notes.
jNutList running
^^^^^^^^^^^^^^^^
jNutList can be run launching it in a console:
java -jar jNutList-x.x-xxx-jar-with-dependencies.jar
Some parameters can be passed :
java -jar jNutList-x.x-jar-with-dependencies.jar host port login password
For example:
java -jar jNutList-x.x-jar-with-dependencies.jar localhost 3493 admin passwd
By default, host is localhost, port is 3493 and login and password are not
specified.

View file

@ -0,0 +1,62 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.networkupstools</groupId>
<artifactId>jNutList</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jNutList</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jNut</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default.
-->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.networkupstools.jnutlist.AppList</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,112 @@
/* AppList.java
Copyright (C) 2011 Eaton
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.networkupstools.jnutlist;
import java.io.IOException;
import java.net.UnknownHostException;
import org.networkupstools.jnut.*;
public class AppList
{
public static void main( String[] args )
{
String host = args.length>=1?args[0]:"localhost";
int port = args.length>=2?Integer.valueOf(args[1]).intValue():3493;
String login = args.length>=3?args[2]:"";
String pass = args.length>=4?args[3]:"";
System.out.println( "jNutList connecting to " + login+":"+pass+"@"+host+":"+port );
Client client = new Client();
try {
client.connect(host, port, login, pass);
Device[] devs = client.getDeviceList();
if(devs!=null)
{
for(int d=0; d<devs.length; d++)
{
Device dev = devs[d];
String desc = "";
try {
desc = " : " + dev.getDescription();
} catch(NutException e) {
e.printStackTrace();
}
System.out.println("DEV " + dev.getName() + desc);
try {
Variable[] vars = dev.getVariableList();
if(vars!=null)
{
if(vars.length==0)
System.out.println(" NO VAR");
for(int v=0; v<vars.length; v++)
{
Variable var = vars[v];
String res = "";
try {
res = " = " + var.getValue() + " (" + var.getDescription() + ")";
} catch(NutException e) {
e.printStackTrace();
}
System.out.println(" VAR " + var.getName() + res );
}
}
else
System.out.println(" NULL VAR");
} catch(NutException e) {
e.printStackTrace();
}
try {
Command[] cmds = dev.getCommandList();
if(cmds!=null)
{
if(cmds.length==0)
System.out.println(" NO CMD");
for(int c=0; c<cmds.length; c++)
{
Command cmd = cmds[c];
String res = "";
try {
res = " : " + cmd.getDescription();
} catch(NutException e) {
e.printStackTrace();
}
System.out.println(" CMD " + cmd.getName() + res);
}
}
else
System.out.println(" NULL CMD");
} catch(NutException e) {
e.printStackTrace();
}
}
}
client.disconnect();
}catch(Exception e){
e.printStackTrace();
}
}
}

View file

@ -45,6 +45,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
@ -111,10 +113,14 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
@ -152,6 +158,10 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
@ -216,6 +226,8 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@

View file

@ -0,0 +1,21 @@
EXTRA_DIST = README
if HAVE_SYSTEMD
%.service: %.service.in
sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
nutshutdown: nutshutdown.in
sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
systemdsystemunit_DATA = \
nut-driver.service \
nut-monitor.service \
nut-server.service
systemdsystemshutdown_SCRIPTS = nutshutdown
else
EXTRA_DIST += nut-driver.service.in nut-monitor.service.in \
nut-server.service.in nutshutdown.in
endif

531
scripts/systemd/Makefile.in Normal file
View file

@ -0,0 +1,531 @@
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
@HAVE_SYSTEMD_FALSE@am__append_1 = nut-driver.service.in nut-monitor.service.in \
@HAVE_SYSTEMD_FALSE@ nut-server.service.in nutshutdown.in
subdir = scripts/systemd
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
$(top_srcdir)/m4/nut_check_libpowerman.m4 \
$(top_srcdir)/m4/nut_check_libssl.m4 \
$(top_srcdir)/m4/nut_check_libusb.m4 \
$(top_srcdir)/m4/nut_check_libwrap.m4 \
$(top_srcdir)/m4/nut_check_os.m4 \
$(top_srcdir)/m4/nut_config_libhal.m4 \
$(top_srcdir)/m4/nut_report_feature.m4 \
$(top_srcdir)/m4/nut_type_socklen_t.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__installdirs = "$(DESTDIR)$(systemdsystemshutdowndir)" \
"$(DESTDIR)$(systemdsystemunitdir)"
SCRIPTS = $(systemdsystemshutdown_SCRIPTS)
SOURCES =
DIST_SOURCES =
DATA = $(systemdsystemunit_DATA)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
A2X = @A2X@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
ASCIIDOC = @ASCIIDOC@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BINDIR = @BINDIR@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CONFPATH = @CONFPATH@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DBLATEX = @DBLATEX@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DOC_BUILD_LIST = @DOC_BUILD_LIST@
DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@
DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@
DRIVER_MAN_LIST = @DRIVER_MAN_LIST@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAL_CALLOUTS_PATH = @HAL_CALLOUTS_PATH@
HAL_DEVICE_MATCH_KEY = @HAL_DEVICE_MATCH_KEY@
HAL_FDI_PATH = @HAL_FDI_PATH@
HAL_USER = @HAL_USER@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
LIBNETSNMP_LIBS = @LIBNETSNMP_LIBS@
LIBOBJS = @LIBOBJS@
LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@
LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@
LIBS = @LIBS@
LIBSSL_CFLAGS = @LIBSSL_CFLAGS@
LIBSSL_LIBS = @LIBSSL_LIBS@
LIBTOOL = @LIBTOOL@
LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
LIBUSB_LIBS = @LIBUSB_LIBS@
LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@
LIBWRAP_LIBS = @LIBWRAP_LIBS@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NETLIBS = @NETLIBS@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_NAME = @OS_NAME@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
SED = @SED@
SERLIBS = @SERLIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STATEPATH = @STATEPATH@
STRIP = @STRIP@
SUN_LIBUSB = @SUN_LIBUSB@
VERSION = @VERSION@
WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
cgiexecdir = @cgiexecdir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
driverexecdir = @driverexecdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
hotplugdir = @hotplugdir@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgconfigdir = @pkgconfigdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevdir = @udevdir@
EXTRA_DIST = README $(am__append_1)
@HAVE_SYSTEMD_TRUE@systemdsystemunit_DATA = \
@HAVE_SYSTEMD_TRUE@ nut-driver.service \
@HAVE_SYSTEMD_TRUE@ nut-monitor.service \
@HAVE_SYSTEMD_TRUE@ nut-server.service
@HAVE_SYSTEMD_TRUE@systemdsystemshutdown_SCRIPTS = nutshutdown
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/systemd/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu scripts/systemd/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-systemdsystemshutdownSCRIPTS: $(systemdsystemshutdown_SCRIPTS)
@$(NORMAL_INSTALL)
test -z "$(systemdsystemshutdowndir)" || $(MKDIR_P) "$(DESTDIR)$(systemdsystemshutdowndir)"
@list='$(systemdsystemshutdown_SCRIPTS)'; test -n "$(systemdsystemshutdowndir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n' \
-e 'h;s|.*|.|' \
-e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) { files[d] = files[d] " " $$1; \
if (++n[d] == $(am__install_max)) { \
print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
else { print "f", d "/" $$4, $$1 } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(systemdsystemshutdowndir)$$dir'"; \
$(INSTALL_SCRIPT) $$files "$(DESTDIR)$(systemdsystemshutdowndir)$$dir" || exit $$?; \
} \
; done
uninstall-systemdsystemshutdownSCRIPTS:
@$(NORMAL_UNINSTALL)
@list='$(systemdsystemshutdown_SCRIPTS)'; test -n "$(systemdsystemshutdowndir)" || exit 0; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 's,.*/,,;$(transform)'`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(systemdsystemshutdowndir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(systemdsystemshutdowndir)" && rm -f $$files
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-systemdsystemunitDATA: $(systemdsystemunit_DATA)
@$(NORMAL_INSTALL)
test -z "$(systemdsystemunitdir)" || $(MKDIR_P) "$(DESTDIR)$(systemdsystemunitdir)"
@list='$(systemdsystemunit_DATA)'; test -n "$(systemdsystemunitdir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(systemdsystemunitdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(systemdsystemunitdir)" || exit $$?; \
done
uninstall-systemdsystemunitDATA:
@$(NORMAL_UNINSTALL)
@list='$(systemdsystemunit_DATA)'; test -n "$(systemdsystemunitdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(systemdsystemunitdir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(systemdsystemunitdir)" && rm -f $$files
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(SCRIPTS) $(DATA)
installdirs:
for dir in "$(DESTDIR)$(systemdsystemshutdowndir)" "$(DESTDIR)$(systemdsystemunitdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-systemdsystemshutdownSCRIPTS \
install-systemdsystemunitDATA
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-systemdsystemshutdownSCRIPTS \
uninstall-systemdsystemunitDATA
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
install-systemdsystemshutdownSCRIPTS \
install-systemdsystemunitDATA installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am uninstall uninstall-am \
uninstall-systemdsystemshutdownSCRIPTS \
uninstall-systemdsystemunitDATA
@HAVE_SYSTEMD_TRUE@%.service: %.service.in
@HAVE_SYSTEMD_TRUE@ sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
@HAVE_SYSTEMD_TRUE@nutshutdown: nutshutdown.in
@HAVE_SYSTEMD_TRUE@ sed -e 's,@sbindir\@,$(sbindir),g' $< > $@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

8
scripts/systemd/README Normal file
View file

@ -0,0 +1,8 @@
This directory contains the NUT support files for systemd, the System and
Service Manager.
These files are automatically installed, upon detection (at configure time)
of a systemd enabled system.
Contributed by Michal Hlavinka <mhlavink@redhat.com>

View file

@ -0,0 +1,10 @@
[Unit]
Description=Network UPS Tools - power device driver controller
After=local-fs.target network.target
StopWhenUnneeded=yes
[Service]
ExecStart=/sbin/upsdrvctl start
ExecStop=/sbin/upsdrvctl stop
Type=forking

View file

@ -0,0 +1,11 @@
[Unit]
Description=Network UPS Tools - power device monitor and shutdown controller
After=local-fs.target network.target nut-server.service
[Service]
ExecStart=/usr/sbin/upsmon
PIDFile=/var/run/nut/upsmon.pid
Type=forking
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,12 @@
[Unit]
Description=Network UPS Tools - power devices information server
After=local-fs.target network.target nut-driver.service
Requires=nut-driver.service
Before=nut-monitor.service
[Service]
ExecStart=/usr/sbin/upsd
Type=forking
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,2 @@
#!/bin/sh
upsmon -K >/dev/null 2>&1 && upsdrvctl shutdown

View file

@ -1,7 +1,13 @@
if WITH_UDEV
udevrulesdir = $(udevdir)/rules.d
udevrules_DATA = 52-nut-usbups.rules
udevrules_DATA =
if WITH_USB
udevrules_DATA += 52-nut-usbups.rules
endif
if WITH_IPMI
udevrules_DATA += 52-nut-ipmipsu.rules
endif
endif
EXTRA_DIST = README
@ -9,7 +15,10 @@ EXTRA_DIST = README
52-nut-usbups.rules: nut-usbups.rules
cp nut-usbups.rules 52-nut-usbups.rules
DISTCLEANFILES = nut-usbups.rules
CLEANFILES = 52-nut-usbups.rules
52-nut-ipmipsu.rules: nut-ipmipsu.rules
cp nut-ipmipsu.rules 52-nut-ipmipsu.rules
DISTCLEANFILES = nut-usbups.rules nut-ipmipsu.rules
CLEANFILES = 52-nut-usbups.rules 52-nut-ipmipsu.rules
# we should never remove this one, apart from a distclean-check
#MAINTAINERCLEANFILES = nut-usbups.rules.in

View file

@ -35,9 +35,11 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
@WITH_UDEV_TRUE@@WITH_USB_TRUE@am__append_1 = 52-nut-usbups.rules
@WITH_IPMI_TRUE@@WITH_UDEV_TRUE@am__append_2 = 52-nut-ipmipsu.rules
subdir = scripts/udev
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/nut-usbups.rules.in
$(srcdir)/nut-ipmipsu.rules.in $(srcdir)/nut-usbups.rules.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@ -45,6 +47,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libhal.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
@ -62,7 +66,7 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES = nut-usbups.rules
CONFIG_CLEAN_FILES = nut-ipmipsu.rules nut-usbups.rules
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
@ -134,10 +138,14 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
LIBHAL_LIBS = @LIBHAL_LIBS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
@ -175,6 +183,10 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
@ -239,6 +251,8 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
@ -249,10 +263,10 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevdir = @udevdir@
@WITH_UDEV_TRUE@udevrulesdir = $(udevdir)/rules.d
@WITH_UDEV_TRUE@udevrules_DATA = 52-nut-usbups.rules
@WITH_UDEV_TRUE@udevrules_DATA = $(am__append_1) $(am__append_2)
EXTRA_DIST = README
DISTCLEANFILES = nut-usbups.rules
CLEANFILES = 52-nut-usbups.rules
DISTCLEANFILES = nut-usbups.rules nut-ipmipsu.rules
CLEANFILES = 52-nut-usbups.rules 52-nut-ipmipsu.rules
all: all-am
.SUFFIXES:
@ -286,6 +300,8 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
nut-ipmipsu.rules: $(top_builddir)/config.status $(srcdir)/nut-ipmipsu.rules.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
nut-usbups.rules: $(top_builddir)/config.status $(srcdir)/nut-usbups.rules.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
@ -468,6 +484,9 @@ uninstall-am: uninstall-udevrulesDATA
52-nut-usbups.rules: nut-usbups.rules
cp nut-usbups.rules 52-nut-usbups.rules
52-nut-ipmipsu.rules: nut-ipmipsu.rules
cp nut-ipmipsu.rules 52-nut-ipmipsu.rules
# we should never remove this one, apart from a distclean-check
#MAINTAINERCLEANFILES = nut-usbups.rules.in

View file

@ -1,17 +1,18 @@
Desc: Udev script for NUT USB drivers
Desc: Udev script for NUT USB and IPMI drivers
File: scripts/udev/README
Date: 27 January 2008
Date: 25 July 2011
Auth: Arnaud Quette <aquette.dev@gmail.com>
This document introduces the Linux udev script for NUT USB
drivers (usbhid-ups, bcmxcp_usb, tripplite_usb, ...).
drivers (usbhid-ups, bcmxcp_usb, tripplite_usb, ...) and IPMI driver
(nut-ipmipsu).
These are needed on Linux systems running udev (recommended
as of kernel 2.6.3, and mandatory as of 2.6.14 and higher).
This script ensure that the right privileges are set on the
usb devices files to allow the NUT driver to operate (ie
allowing the nut user to read AND write to the UPS device).
USB and IPMI devices files to allow the NUT driver to operate (ie
allowing the nut user to read AND write to the device).
Note that the old style hotplug files, available in the
scripts/hotplug directory, are not needed if your kernel supports
@ -21,21 +22,23 @@ Installation
------------
For most users, these files will be automatically installed in
/etc/udev (or /lib/udev) upon "make install", if that directory exists. You can
/etc/udev (or /lib/udev) upon "make install", if that directory exists and if
the feature (USB and / or IPMI) has been enabled at configure time. You can
specify an alternate directory with ./configure --with-udev-dir=DIR.
Manual installation
-------------------
To install them manually, copy nut-usbups.rules to /etc/udev/rules.d
(or /lib/udev/rules.d on newer systems) using the command
To install them manually, copy the rules file(s) to /etc/udev/rules.d
(or /lib/udev/rules.d on newer systems) using the command(s):
$ cp -f nut-usbups.rules /etc/udev/rules.d/52-nut-usbups.rules
$ cp -f nut-ipmipsu.rules /etc/udev/rules.d/52-nut-ipmipsu.rules
You will need to refresh the bus to avoid a reboot for these rules to be
active. You can do so using:
$ udevadm trigger --subsystem-match=usb_device
You can then plug your UPS USB cord, or unplug / replug it to
refresh the device permission, and start NUT.
For USB devices, you can then plug your UPS USB cord, or unplug / replug
it to refresh the device permission, and start NUT.

View file

@ -0,0 +1,4 @@
# This file is generated and installed by the Network UPS Tools package.
# It sets the correct device permissions for nut-ipmipsu driver.
KERNEL=="ipmi*", MODE="664", GROUP="@RUN_AS_GROUP@"

View file

@ -66,6 +66,10 @@ ATTR{idVendor}=="051d", ATTR{idProduct}=="0003", MODE="664", GROUP="@RUN_AS_GROU
ATTR{idVendor}=="0592", ATTR{idProduct}=="0002", MODE="664", GROUP="@RUN_AS_GROUP@"
# PW 9140 - usbhid-ups
ATTR{idVendor}=="0592", ATTR{idProduct}=="0004", MODE="664", GROUP="@RUN_AS_GROUP@"
# Agiler UPS - blazer_usb
ATTR{idVendor}=="05b8", ATTR{idProduct}=="0000", MODE="664", GROUP="@RUN_AS_GROUP@"
# Belkin F6C1200-UNV - blazer_usb
ATTR{idVendor}=="0665", ATTR{idProduct}=="5161", MODE="664", GROUP="@RUN_AS_GROUP@"
# Phoenixtec
# various models - bcmxcp_usb
@ -86,6 +90,8 @@ ATTR{idVendor}=="0764", ATTR{idProduct}=="0005", MODE="664", GROUP="@RUN_AS_GROU
ATTR{idVendor}=="0764", ATTR{idProduct}=="0501", MODE="664", GROUP="@RUN_AS_GROUP@"
# OR2200LCDRM2U - usbhid-ups
ATTR{idVendor}=="0764", ATTR{idProduct}=="0601", MODE="664", GROUP="@RUN_AS_GROUP@"
# Sweex 1000VA - richcomm_usb
ATTR{idVendor}=="0925", ATTR{idProduct}=="1234", MODE="664", GROUP="@RUN_AS_GROUP@"
# TrippLite
# e.g. OMNIVS1000, SMART550USB, ... - tripplite_usb
@ -162,9 +168,13 @@ ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a4", MODE="664", GROUP="@RUN_AS_GROU
ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a5", MODE="664", GROUP="@RUN_AS_GROUP@"
# PowerCOM BNT - Black Knight Pro - usbhid-ups
ATTR{idVendor}=="0d9f", ATTR{idProduct}=="00a6", MODE="664", GROUP="@RUN_AS_GROUP@"
# Unitek Alpha 1200Sx - blazer_usb
ATTR{idVendor}=="0f03", ATTR{idProduct}=="0001", MODE="664", GROUP="@RUN_AS_GROUP@"
# Liebert
# Liebert PowerSure PSA UPS - usbhid-ups
ATTR{idVendor}=="10af", ATTR{idProduct}=="0001", MODE="664", GROUP="@RUN_AS_GROUP@"
# GE EP series - blazer_usb
ATTR{idVendor}=="14f0", ATTR{idProduct}=="00c9", MODE="664", GROUP="@RUN_AS_GROUP@"
LABEL="nut-usbups_rules_end"