pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/ups-nut sysutils/nut: Add support for turning...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/c7f23bf5a4c9
branches:  trunk
changeset: 391325:c7f23bf5a4c9
user:      gdt <gdt%pkgsrc.org@localhost>
date:      Sun Jan 08 01:14:23 2023 +0000

description:
sysutils/nut: Add support for turning off UPS at shutdown

Add support for turning off the UPS as part of a shutdown caused by
low battery.  The actual poweroff is commented out for now, pending testing.

Move ups daemon startup slightly earlier in the startup sequence.

diffstat:

 sysutils/ups-nut/Makefile              |   6 ++--
 sysutils/ups-nut/files/upsd.sh         |   3 +-
 sysutils/ups-nut/files/upsdriver.sh    |   3 +-
 sysutils/ups-nut/files/upskillpower.sh |  37 ++++++++++++++++++++++++++++++++++
 sysutils/ups-nut/files/upslog.sh       |   3 +-
 sysutils/ups-nut/files/upsmon.sh       |   3 +-
 6 files changed, 47 insertions(+), 8 deletions(-)

diffs (122 lines):

diff -r 7308db620327 -r c7f23bf5a4c9 sysutils/ups-nut/Makefile
--- a/sysutils/ups-nut/Makefile Sun Jan 08 00:54:39 2023 +0000
+++ b/sysutils/ups-nut/Makefile Sun Jan 08 01:14:23 2023 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.68 2023/01/07 16:16:10 gdt Exp $
+# $NetBSD: Makefile,v 1.69 2023/01/08 01:14:23 gdt Exp $
 
-PKGREVISION= 3
+PKGREVISION= 4
 .include "Makefile.common"
 
 PKGNAME=               ups-${DISTNAME}
@@ -53,7 +53,7 @@
 CONF_FILES_PERMS+=     ${NUT_EGDIR}/upsmon.conf.sample                 \
                        ${NUT_CONFDIR}/upsmon.conf                      \
                        ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0600
-RCD_SCRIPTS=           ups upsd upsdriver upslog upsmon
+RCD_SCRIPTS=           ups upskillpower upsdriver upsd upsmon upslog
 
 OWN_DIRS=              ${NUT_CONFDIR}
 OWN_DIRS_PERMS=                ${NUT_STATEDIR} ${NUT_USER} ${NUT_GROUP} 0770
diff -r 7308db620327 -r c7f23bf5a4c9 sysutils/ups-nut/files/upsd.sh
--- a/sysutils/ups-nut/files/upsd.sh    Sun Jan 08 00:54:39 2023 +0000
+++ b/sysutils/ups-nut/files/upsd.sh    Sun Jan 08 01:14:23 2023 +0000
@@ -1,10 +1,9 @@
 #!@RCD_SCRIPTS_SHELL@
 #
-# $NetBSD: upsd.sh,v 1.8 2023/01/07 16:16:10 gdt Exp $
+# $NetBSD: upsd.sh,v 1.9 2023/01/08 01:14:23 gdt Exp $
 #
 # PROVIDE: upsd
 # REQUIRE: upsdriver
-# BEFORE: upsmon
 # KEYWORD: shutdown
 
 if [ -f /etc/rc.subr ]; then
diff -r 7308db620327 -r c7f23bf5a4c9 sysutils/ups-nut/files/upsdriver.sh
--- a/sysutils/ups-nut/files/upsdriver.sh       Sun Jan 08 00:54:39 2023 +0000
+++ b/sysutils/ups-nut/files/upsdriver.sh       Sun Jan 08 01:14:23 2023 +0000
@@ -1,9 +1,10 @@
 #!@RCD_SCRIPTS_SHELL@
 #
-# $NetBSD: upsdriver.sh,v 1.10 2023/01/07 16:16:10 gdt Exp $
+# $NetBSD: upsdriver.sh,v 1.11 2023/01/08 01:14:23 gdt Exp $
 #
 # PROVIDE: upsdriver
 # REQUIRE: NETWORK syslogd mountcritremote
+# KEYWORD: shutdown
 #
 # The standard approach is to leave "upsdriver_type" unset, so that
 # upsdrvctl is used to start and stop the driver(s).  (Note that a
diff -r 7308db620327 -r c7f23bf5a4c9 sysutils/ups-nut/files/upskillpower.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/ups-nut/files/upskillpower.sh    Sun Jan 08 01:14:23 2023 +0000
@@ -0,0 +1,37 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: upskillpower.sh,v 1.1 2023/01/08 01:14:23 gdt Exp $
+#
+# PROVIDE: upskillpower
+# REQUIRE: mountcritremote
+# BEFORE: upsdriver altq downinterfaces 
+# KEYWORD: shutdown
+
+# This script shuts off power, if upsmon has decided to shutdown
+# because of low battery/runtime.  This is logically part of upsmon
+# but should run later in shutdown.
+
+. /etc/rc.subr
+
+name="upskillpower"
+rcvar=upsmon
+
+start_empty()
+{
+    # This is a shutdown-only file.
+    true
+}
+
+killpower()
+{
+    if @PREFIX@/sbin/upsmon -K; then
+       echo "upskillpower: POWER OFF commanded"
+       echo TEST ONLY @PREFIX@/sbin/upsdrvctl shutdown
+    fi
+}
+
+start_cmd="start_empty"
+stop_cmd="killpower"
+
+load_rc_config $name
+run_rc_command "$1"
diff -r 7308db620327 -r c7f23bf5a4c9 sysutils/ups-nut/files/upslog.sh
--- a/sysutils/ups-nut/files/upslog.sh  Sun Jan 08 00:54:39 2023 +0000
+++ b/sysutils/ups-nut/files/upslog.sh  Sun Jan 08 01:14:23 2023 +0000
@@ -1,10 +1,11 @@
 #!@RCD_SCRIPTS_SHELL@
 #
-# $NetBSD: upslog.sh,v 1.7 2023/01/07 16:16:10 gdt Exp $
+# $NetBSD: upslog.sh,v 1.8 2023/01/08 01:14:23 gdt Exp $
 #
 # PROVIDE: upslog
 # REQUIRE: upsd DAEMON
 # BEFORE: LOGIN
+# KEYWORD: shutdown
 #
 # You will need to set some variables in /etc/rc.conf to start upslog
 # properly, e.g.
diff -r 7308db620327 -r c7f23bf5a4c9 sysutils/ups-nut/files/upsmon.sh
--- a/sysutils/ups-nut/files/upsmon.sh  Sun Jan 08 00:54:39 2023 +0000
+++ b/sysutils/ups-nut/files/upsmon.sh  Sun Jan 08 01:14:23 2023 +0000
@@ -1,8 +1,9 @@
 #!@RCD_SCRIPTS_SHELL@
 #
-# $NetBSD: upsmon.sh,v 1.8 2023/01/07 16:16:10 gdt Exp $
+# $NetBSD: upsmon.sh,v 1.9 2023/01/08 01:14:23 gdt Exp $
 #
 # PROVIDE: upsmon
+# REQUIRE: upsd
 # BEFORE: SERVERS
 # KEYWORD: shutdown
 



Home | Main Index | Thread Index | Old Index