Received: by mail.netbsd.org (Postfix, from userid 605) id C130884D67; Sun, 8 Jan 2023 01:14:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id F095184D50 for ; Sun, 8 Jan 2023 01:14:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id F50cbcsudhHY for ; Sun, 8 Jan 2023 01:14:24 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id 18A3C84D25 for ; Sun, 8 Jan 2023 01:14:24 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 0C473FA90; Sun, 8 Jan 2023 01:14:24 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_167314046480950" MIME-Version: 1.0 Date: Sun, 8 Jan 2023 01:14:24 +0000 From: "Greg Troxel" Subject: CVS commit: pkgsrc/sysutils/ups-nut To: pkgsrc-changes@NetBSD.org Reply-To: gdt@netbsd.org X-Mailer: log_accum Message-Id: <20230108011424.0C473FA90@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_167314046480950 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: gdt Date: Sun Jan 8 01:14:23 UTC 2023 Modified Files: pkgsrc/sysutils/ups-nut: Makefile pkgsrc/sysutils/ups-nut/files: upsd.sh upsdriver.sh upslog.sh upsmon.sh Added Files: pkgsrc/sysutils/ups-nut/files: upskillpower.sh Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 pkgsrc/sysutils/ups-nut/Makefile cvs rdiff -u -r1.8 -r1.9 pkgsrc/sysutils/ups-nut/files/upsd.sh \ pkgsrc/sysutils/ups-nut/files/upsmon.sh cvs rdiff -u -r1.10 -r1.11 pkgsrc/sysutils/ups-nut/files/upsdriver.sh cvs rdiff -u -r0 -r1.1 pkgsrc/sysutils/ups-nut/files/upskillpower.sh cvs rdiff -u -r1.7 -r1.8 pkgsrc/sysutils/ups-nut/files/upslog.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_167314046480950 Content-Disposition: inline Content-Length: 4312 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/sysutils/ups-nut/Makefile diff -u pkgsrc/sysutils/ups-nut/Makefile:1.68 pkgsrc/sysutils/ups-nut/Makefile:1.69 --- pkgsrc/sysutils/ups-nut/Makefile:1.68 Sat Jan 7 16:16:10 2023 +++ pkgsrc/sysutils/ups-nut/Makefile Sun Jan 8 01:14:23 2023 @@ -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}/upsd.use 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 Index: pkgsrc/sysutils/ups-nut/files/upsd.sh diff -u pkgsrc/sysutils/ups-nut/files/upsd.sh:1.8 pkgsrc/sysutils/ups-nut/files/upsd.sh:1.9 --- pkgsrc/sysutils/ups-nut/files/upsd.sh:1.8 Sat Jan 7 16:16:10 2023 +++ pkgsrc/sysutils/ups-nut/files/upsd.sh Sun Jan 8 01:14:23 2023 @@ -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 Index: pkgsrc/sysutils/ups-nut/files/upsmon.sh diff -u pkgsrc/sysutils/ups-nut/files/upsmon.sh:1.8 pkgsrc/sysutils/ups-nut/files/upsmon.sh:1.9 --- pkgsrc/sysutils/ups-nut/files/upsmon.sh:1.8 Sat Jan 7 16:16:10 2023 +++ pkgsrc/sysutils/ups-nut/files/upsmon.sh Sun Jan 8 01:14:23 2023 @@ -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 Index: pkgsrc/sysutils/ups-nut/files/upsdriver.sh diff -u pkgsrc/sysutils/ups-nut/files/upsdriver.sh:1.10 pkgsrc/sysutils/ups-nut/files/upsdriver.sh:1.11 --- pkgsrc/sysutils/ups-nut/files/upsdriver.sh:1.10 Sat Jan 7 16:16:10 2023 +++ pkgsrc/sysutils/ups-nut/files/upsdriver.sh Sun Jan 8 01:14:23 2023 @@ -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 Index: pkgsrc/sysutils/ups-nut/files/upslog.sh diff -u pkgsrc/sysutils/ups-nut/files/upslog.sh:1.7 pkgsrc/sysutils/ups-nut/files/upslog.sh:1.8 --- pkgsrc/sysutils/ups-nut/files/upslog.sh:1.7 Sat Jan 7 16:16:10 2023 +++ pkgsrc/sysutils/ups-nut/files/upslog.sh Sun Jan 8 01:14:23 2023 @@ -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. Added files: Index: pkgsrc/sysutils/ups-nut/files/upskillpower.sh diff -u /dev/null pkgsrc/sysutils/ups-nut/files/upskillpower.sh:1.1 --- /dev/null Sun Jan 8 01:14:23 2023 +++ pkgsrc/sysutils/ups-nut/files/upskillpower.sh Sun Jan 8 01:14:23 2023 @@ -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" --_----------=_167314046480950--