From 1aa25b671de39e63c454251c14601ad076d60d30 Mon Sep 17 00:00:00 2001 From: Arnaud Quette Date: Sat, 28 Jan 2012 19:26:35 +0100 Subject: [PATCH] Debian release 2.6.3-2 --- debian/Makefile.am | 7 +- debian/changelog | 15 ++ debian/control | 6 +- debian/nut-client.init | 177 ++++++++++++++++++ debian/nut-client.links | 1 + debian/nut-server.init | 159 +++++++--------- debian/nut-server.links | 1 - ...server.README.Debian => nut.README.Debian} | 11 +- debian/nut.TODO.Debian | 1 - debian/rules | 3 +- 10 files changed, 280 insertions(+), 101 deletions(-) create mode 100755 debian/nut-client.init create mode 100644 debian/nut-client.links delete mode 100644 debian/nut-server.links rename debian/{nut-server.README.Debian => nut.README.Debian} (94%) diff --git a/debian/Makefile.am b/debian/Makefile.am index 031e44b..68fdb08 100644 --- a/debian/Makefile.am +++ b/debian/Makefile.am @@ -2,7 +2,8 @@ EXTRA_DIST = changelog control copyright description.subst hotplug \ nut-cgi.config nut-cgi.docs nut-cgi.examples nut-cgi.postinst nut-cgi.postrm \ nut-cgi.preinst nut-cgi.README.Debian nut-cgi.templates nut.config \ nut.default nut.dirs nut.docs nut.examples nut-hal-drivers.docs \ - nut.init nut.links nut.postinst nut.postrm nut.preinst nut.prerm \ - nut.README.Debian nut.templates nut.TODO.Debian \ - rules watch po/ca.po po/cs.po po/de.po po/fr.po po/POTFILES.in \ + nut-server.init nut-client.init nut-client.links \ + nut.postinst nut.postrm nut.preinst nut.prerm nut.README.Debian \ + nut.templates nut.TODO.Debian rules watch \ + po/ca.po po/cs.po po/de.po po/fr.po po/POTFILES.in \ po/pt.po po/pt_BR.po po/templates.pot po/vi.po diff --git a/debian/changelog b/debian/changelog index d5fe734..052d4c7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,18 @@ +nut (2.6.3-2) unstable; urgency=low + + * debian/nut-server.init: rewrite to match upsd / drivers startup scope + * debian/nut-client.init: created to match upsmon startup scope + (Closes: #634858) + * debian/nut.TODO.Debian, debian/Makefile.am: updated to reflect the above + * debian/rules: install nut-client.init, and update to reflect the above + * debian/control, debian/Makefile.am: updated to reflect the above + * debian/nut-client.links: renamed from debian/nut-server.links, since + ups-monitor is now provided by nut-client initscript + * debian/nut.README.Debian: renamed from nut-server.README.Debian, + to provide it with both client and server packages + + -- Arnaud Quette Tue, 24 Jan 2012 13:14:59 +0100 + nut (2.6.3-1) unstable; urgency=low * New upstream release (Closes: #635186, #598741, #633756, #638221) diff --git a/debian/control b/debian/control index b0e8188..50d49a4 100644 --- a/debian/control +++ b/debian/control @@ -38,8 +38,8 @@ Package: nut-server Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, lsb-base (>= 3.0-6), ${udev}, nut-client (= ${binary:Version}) Suggests: nut-cgi, nut-snmp, nut-dev, nut-xml -Provides: ups-monitor, nut-usb -Conflicts: ups-monitor, nut-hal-drivers, nut-usb (<< 2.1.0-3), nut-dev (<< 2.2.2) +Provides: nut-usb +Conflicts: nut-hal-drivers, nut-usb (<< 2.1.0-3), nut-dev (<< 2.2.2) Replaces: nut (<< 2.6.1-2~) Breaks: nut (<< 2.6.1-2~) Description: network UPS tools - core system @@ -56,6 +56,8 @@ Description: network UPS tools - core system Package: nut-client Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} +Provides: ups-monitor +Conflicts: ups-monitor, nut-server (<< 2.6.3-1) Recommends: bash-completion Replaces: nut (<< 2.6.1-2~) Breaks: nut (<< 2.6.1-2~) diff --git a/debian/nut-client.init b/debian/nut-client.init new file mode 100755 index 0000000..8aa663f --- /dev/null +++ b/debian/nut-client.init @@ -0,0 +1,177 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: nut-client upsmon ups-monitor +# Required-Start: $local_fs $syslog $network $remote_fs +# Required-Stop: $local_fs $syslog $network $remote_fs +# Should-Start: nut-server +# Should-Stop: nut-server +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Network UPS Tools monitor initscript +# Description: This script take care of starting and stopping the +# Network UPS Tools monitoring component (upsmon). +### END INIT INFO + +# Author: Arnaud Quette + +PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin + +NAME=nut-client +DESC="Network UPS Tools - power device monitor and shutdown controller" +CONFIG=/etc/nut/nut.conf +pid_dir=/var/run/nut +upsmon_pid=${pid_dir}/upsmon.pid +upsmon=/sbin/upsmon +log=">/dev/null 2>/dev/null" + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# set upsmon specific options. use "man upsmon" for more info +# this parameter is now located in nut.conf, and not in /etc/default/nut anymore +# FIXME: retrieved from 'nut' script during update +UPSMON_OPTIONS="" + +# Exit if the package is not installed +[ -x "$upsmon" ] || exit 0 + +# Include NUT nut.conf +[ -r $CONFIG ] && . $CONFIG + +# FIXME: put all common bits, between nut-client and nut-server, +# into a common nut-function + +# Explicitly require the configuration to be done in /etc/nut/nut.conf +if [ "x$MODE" = "xnone" -o -z "$MODE" ] ; then + log_action_msg "$NAME disabled, please adjust the configuration to your needs" + log_action_msg "Then set MODE to a suitable value in $CONFIG to enable it" + # exit success to avoid breaking the install process! + exit 0 +fi + +# Check if /var/run/nut exists and has the correct perms +check_var_directory() { + [ ! -d ${pid_dir} ] && mkdir -p ${pid_dir} \ + && chown root:nut ${pid_dir} \ + && chmod 770 ${pid_dir} +} + +# check if the right components are running +check_status() { + case "$MODE" in + standalone|netserver|netclient) + status_of_proc -p $upsmon_pid $upsmon upsmon + ;; + none|*) + ;; + esac +} + +start_stop_client () { + case "$MODE" in + standalone|netserver|netclient) + # FIXME: for standalone|netserver, ensure 'nut-server status' returns ? + case "$1" in + start) + start-stop-daemon -S -q -p $upsmon_pid -x $upsmon \ + -- $UPSMON_OPTIONS >/dev/null 2>&1 && + log_progress_msg "upsmon" || log_progress_msg "(upsmon failed)" + ;; + stop) + start-stop-daemon -K -o -q -p $upsmon_pid -n upsmon >/dev/null 2>&1 && + log_progress_msg "upsmon" || log_progress_msg "(upsmon failed)" + ;; + esac + ;; + none|*) + return 1 + ;; + esac +} + +case "$1" in + + start) + log_daemon_msg "Starting $DESC" + check_var_directory + start_stop_client start #&& log_progress_msg "upsmon" + log_end_msg 0 + ;; + + stop) + log_daemon_msg "Stopping $DESC" + start_stop_client stop && log_progress_msg "upsmon" + log_end_msg 0 + ;; + + reload) + $upsmon -c reload >/dev/null 2>&1 + ;; + + restart|force-reload) + # FIXME: lack consistency, due to initscript split. + # This only addresses partial reload. + # Full reload requires to: + # - stop nut-client + # - restart (Ie stop+start) nut-server + # - start nut-client + log_daemon_msg "Restarting $DESC" + start_stop_client stop + # should then 'start_stop_server stop', Ie /etc/init.d/nut-server stop + #sleep 5 + check_var_directory + # should first 'start_stop_server start', Ie /etc/init.d/nut-server start + start_stop_client start && log_progress_msg "upsmon" + log_end_msg 0 + ;; + + status) + #log_daemon_msg "Checking status of $DESC" + echo "Checking status of $DESC" + check_status + exit $? + ;; + + poweroff) + case "$MODE" in + standalone|netserver) + # Sanity check + flag=`sed -ne 's#^ *POWERDOWNFLAG *\(.*\)$#\1#p' /etc/nut/upsmon.conf` + if [ -z "$flag" ] ; then + log_action_msg "##########################################################" + log_action_msg "## POWERDOWNFLAG is not defined in /etc/nut/upsmon.conf ##" + log_action_msg "## ##" + log_action_msg "## Please read the Manual page upsmon.conf(5) ##" + log_action_msg "##########################################################" + exit 1 + fi + + # Defer to nut-server to actually poweroff the UPS, if needed + if $upsmon -K >/dev/null 2>&1 ; then + log_daemon_msg "UPS poweroff required..." + log_end_msg 0 + if [ -x /etc/init.d/nut-server ] ; then + exec /etc/init.d/nut-server poweroff + else + log_action_msg "Failure: /etc/init.d/nut-server script missing" + fi + else + log_action_msg "Power down flag is not set (UPS poweroff not needed)" + fi + ;; + none|netclient|*) + # nothing to do + log_action_msg "'$MODE' configuration does not require UPS poweroff" + ;; + esac + ;; + + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|reload|restart|force-reload|status|poweroff}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/nut-client.links b/debian/nut-client.links new file mode 100644 index 0000000..c8d27c5 --- /dev/null +++ b/debian/nut-client.links @@ -0,0 +1 @@ +etc/init.d/nut-client etc/init.d/ups-monitor diff --git a/debian/nut-server.init b/debian/nut-server.init index 158e127..bf924ac 100644 --- a/debian/nut-server.init +++ b/debian/nut-server.init @@ -1,8 +1,8 @@ #! /bin/sh ### BEGIN INIT INFO -# Provides: nut +# Provides: nut-server upsd # Required-Start: $local_fs $syslog $network $remote_fs udev -# Required-Stop: $local_fs $syslog $network $remote_fs udev +# Required-Stop: $local_fs $syslog $network $remote_fs udev nut-client # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Network UPS Tools initscript @@ -15,24 +15,32 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin -NAME=nut -DESC="Network UPS Tools" +NAME=nut-server +DESC="Network UPS Tools - power devices information server and drivers" CONFIG=/etc/nut/nut.conf +pid_dir=/var/run/nut +upsd_pid=${pid_dir}/upsd.pid +upsd=/sbin/upsd +upsdrvctl=/sbin/upsdrvctl +log=">/dev/null 2>/dev/null" +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # set upsd specific options. use "man upsd" for more info +# this parameter is now located in nut.conf, and not in /etc/default/nut anymore +# FIXME: retrieved from 'nut' script during update UPSD_OPTIONS="" -# set upsmon specific options. use "man upsmon" for more info -UPSMON_OPTIONS="" +# Exit if the package is not installed +[ -x "$upsd" ] || exit 0 # Include NUT nut.conf -if [ -f $CONFIG ] ; then - . $CONFIG -fi +[ -r $CONFIG ] && . $CONFIG # Explicitly require the configuration to be done in /etc/nut/nut.conf +# redundant with nut-client if [ "x$MODE" = "xnone" -o -z "$MODE" ] ; then log_action_msg "$NAME disabled, please adjust the configuration to your needs" log_action_msg "Then set MODE to a suitable value in $CONFIG to enable it" @@ -40,32 +48,23 @@ if [ "x$MODE" = "xnone" -o -z "$MODE" ] ; then exit 0 fi -pid_dir=/var/run/nut -upsmon_pid=${pid_dir}/upsmon.pid -upsd_pid=${pid_dir}/upsd.pid -upsd=/sbin/upsd -upsdrvctl=/sbin/upsdrvctl -upsmon=/sbin/upsmon -log=">/dev/null 2>/dev/null" - # Check if /var/run/nut exists and has the correct perms check_var_directory() { - [ ! -d ${pid_dir} ] && mkdir -p ${pid_dir} \ - && chown root:nut ${pid_dir} \ - && chmod 770 ${pid_dir} + [ ! -d ${pid_dir} ] && mkdir -p ${pid_dir} \ + && chown root:nut ${pid_dir} \ + && chmod 770 ${pid_dir} } # check if the right components are running check_status() { case "$MODE" in standalone|netserver) - status_of_proc -p $upsd_pid $upsd upsd - status_of_proc -p $upsmon_pid $upsmon upsmon + status_of_proc -p $upsd_pid $upsd upsd + # FIXME: need driver(s) status too! ;; - netclient) - status_of_proc -p $upsmon_pid $upsmon upsmon - ;; - none|*) + none|netclient|*) + # defered to nut-client + #status_of_proc -p $upsmon_pid $upsmon upsmon ;; esac } @@ -75,38 +74,25 @@ start_stop_server () { standalone|netserver) case "$1" in start) + # First, start driver(s) ! $upsdrvctl start >/dev/null 2>&1 && \ log_progress_msg "(driver(s) failed)" || log_progress_msg "driver(s)" - start-stop-daemon -S -q -p $upsd_pid -x $upsd \ - -- $UPSD_OPTIONS >/dev/null 2>&1 + # Then, data server (upsd) + start-stop-daemon -S -p $upsd_pid -x $upsd \ + -- $UPSD_OPTIONS >/dev/null 2>&1 && + log_progress_msg "upsd" || log_progress_msg "(upsd failed)" ;; stop) - start-stop-daemon -K -o -q -p $upsd_pid -n upsd >/dev/null 2>&1 + # Reverse order for stop + start-stop-daemon -K -o -p $upsd_pid -n upsd && #>/dev/null 2>&1 && + log_action_msg "upsd" || log_action_msg "(upsd failed)" ! /sbin/upsdrvctl stop >/dev/null 2>&1 && \ - log_progress_msg "(driver(s) failed)" || log_progress_msg "driver(s)" + log_action_msg "(driver(s) failed)" || log_action_msg "driver(s)" ;; esac ;; none|netclient|*) - return 1 - ;; - esac -} - -start_stop_client () { - case "$MODE" in - standalone|netserver|netclient) - case "$1" in - start) - start-stop-daemon -S -q -p $upsmon_pid -x $upsmon \ - -- $UPSMON_OPTIONS >/dev/null 2>&1 - ;; - stop) - start-stop-daemon -K -o -q -p $upsmon_pid -n upsmon >/dev/null 2>&1 - ;; - esac - ;; - none|*) + # now handled by nut-client return 1 ;; esac @@ -117,31 +103,31 @@ case "$1" in start) log_daemon_msg "Starting $DESC" check_var_directory - start_stop_server start && log_progress_msg "upsd" - start_stop_client start && log_progress_msg "upsmon" + start_stop_server start #&& log_progress_msg "upsd" + #start_stop_client start && log_progress_msg "upsmon" log_end_msg 0 ;; stop) log_daemon_msg "Stopping $DESC" - start_stop_server stop && log_progress_msg "upsd" - start_stop_client stop && log_progress_msg "upsmon" + start_stop_server stop #&& log_progress_msg "upsd" + #start_stop_client stop && log_progress_msg "upsmon" log_end_msg 0 ;; reload) $upsd -c reload >/dev/null 2>&1 - $upsmon -c reload >/dev/null 2>&1 + #$upsmon -c reload >/dev/null 2>&1 ;; restart|force-reload) log_daemon_msg "Restarting $DESC" - start_stop_client stop + #start_stop_client stop start_stop_server stop sleep 5 check_var_directory - start_stop_server start && log_progress_msg "upsd" - start_stop_client start && log_progress_msg "upsmon" + start_stop_server start #&& log_progress_msg "upsd" + #start_stop_client start && log_progress_msg "upsmon" log_end_msg 0 ;; @@ -153,44 +139,37 @@ case "$1" in ;; poweroff) - flag=`sed -ne 's#^ *POWERDOWNFLAG *\(.*\)$#\1#p' /etc/nut/upsmon.conf` wait_delay=`sed -ne 's#^ *POWEROFF_WAIT= *\(.*\)$#\1#p' /etc/nut/nut.conf` - if [ -f "$flag" ] ; then - if $upsmon -K >/dev/null 2>&1 ; then - log_daemon_msg "Shutting down the UPS ..." - sleep 1 - if $upsdrvctl shutdown ; then - sleep 5 - log_progress_msg "Waiting for UPS to cut the power" - log_end_msg 0 - else - log_progress_msg "Shutdown failed." - log_progress_msg "Waiting for UPS batteries to run down" - log_end_msg 0 - fi - if [ "$wait_delay" ] ; then - log_daemon_msg " (will reboot after $wait_delay) ..." - sleep "$wait_delay" - invoke-rc.d reboot stop - fi - else - log_daemon_msg "Power down flag is not set (UPS shutdown not needed)" - fi - else - if [ -z "$flag" ] ; then - log_daemon_msg "##########################################################" - log_progress_msg "## POWERDOWNFLAG is not defined in /etc/nut/upsmon.conf ##" - log_progress_msg "## ##" - log_progress_msg "## Please read the Manual page upsmon.conf(5) ##" - log_progress_msg "##########################################################" - log_end_msg 0 - fi - fi + # UPS poweroff action is actually done here. + # But nut-monitor (Ie nut-client) does the check and call nut-server if needed! + # This action MUST NOT be called directly, and thus is not exposed in 'Usage' + case "$MODE" in + standalone|netserver) + log_daemon_msg "Shutting down the UPS ..." + if $upsdrvctl shutdown ; then + # FIXME (needed?): sleep 5 + log_progress_msg "Waiting for UPS to cut the power" + log_end_msg 0 + else + log_progress_msg "Shutdown failed." + log_progress_msg "Waiting for UPS batteries to run down" + log_end_msg 0 + fi + if [ -n "$wait_delay" ] ; then + log_daemon_msg " (will reboot after $wait_delay) ..." + sleep "$wait_delay" + invoke-rc.d reboot stop + fi + ;; + none|netclient|*) + # nothing to do + ;; + esac ;; *) N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|reload|restart|force-reload|status|poweroff}" >&2 + echo "Usage: $N {start|stop|reload|restart|force-reload|status}" >&2 exit 1 ;; esac diff --git a/debian/nut-server.links b/debian/nut-server.links deleted file mode 100644 index a86f46f..0000000 --- a/debian/nut-server.links +++ /dev/null @@ -1 +0,0 @@ -etc/init.d/nut etc/init.d/ups-monitor diff --git a/debian/nut-server.README.Debian b/debian/nut.README.Debian similarity index 94% rename from debian/nut-server.README.Debian rename to debian/nut.README.Debian index ed4446c..882e2af 100644 --- a/debian/nut-server.README.Debian +++ b/debian/nut.README.Debian @@ -126,9 +126,14 @@ MODE. If you are running in "netclient" MODE, jump directly to section 6. nut.conf provides all the needed features to replace this file. (8) start the daemon - Invoke '/etc/init.d/nut start' to start the daemon(s). Check - /var/log/syslog to ensure that upsd, appropriate drivers, and upsmon - started up correctly. + If you use a "standalone" or "netserver" MODE, invoke: + - '/etc/init.d/nut-server start' to start upsd and appropriate driver(s), + - '/etc/init.d/nut-client start' to start upsmon. + + If you are running in "netclient" MODE, invoke: + - '/etc/init.d/nut-client start' to start upsmon. + + Check /var/log/syslog to ensure that daemon(s) started up correctly. Additional Notes for Sharing a UPS diff --git a/debian/nut.TODO.Debian b/debian/nut.TODO.Debian index 4efc003..b8fe9dd 100644 --- a/debian/nut.TODO.Debian +++ b/debian/nut.TODO.Debian @@ -1,4 +1,3 @@ -- split nut-server.init into nut-server.init + nut-client.init (upsmon) - how to distribute the nut-scanner and its library? Ie, a single package, or using the nut-{xml,snmp,...} packages. this requires libusb (0.1), Net SNMP, FreeIPMi, Avahi, libupsclient and Neon! diff --git a/debian/rules b/debian/rules index 9af3f0b..b9eef15 100755 --- a/debian/rules +++ b/debian/rules @@ -76,7 +76,8 @@ common-install-indep:: binary-install/nut-monitor:: dh_python2 -pnut-monitor -DEB_DH_INSTALLINIT_ARGS_nut-server := --init-script=nut -- start 50 2 3 4 5 . stop 50 0 1 6 . +DEB_DH_INSTALLINIT_ARGS_nut-server := --init-script=nut-server -- start 50 2 3 4 5 . stop 50 0 1 6 . +DEB_DH_INSTALLINIT_ARGS_nut-client := --init-script=nut-client -- start 51 2 3 4 5 . stop 51 0 1 6 . DEB_DH_COMPRESS_ARGS_nut-doc := -X.pdf ifeq (linux,$(DEB_HOST_ARCH_OS))