Sun Jan 8 01:32:55 2023 UTC ()
sysutils/ups-nut: Simplify upsdriver

Drop option to specify driver and args manually.  upsdrvctl is now the
only approach.

(Raised to 3 usual suspects who have helped with nut, with 2
supporting the simplification.)


(gdt)
diff -r1.69 -r1.70 pkgsrc/sysutils/ups-nut/Makefile
diff -r1.11 -r1.12 pkgsrc/sysutils/ups-nut/files/upsdriver.sh

cvs diff -r1.69 -r1.70 pkgsrc/sysutils/ups-nut/Makefile (expand / switch to unified diff)

--- pkgsrc/sysutils/ups-nut/Makefile 2023/01/08 01:14:23 1.69
+++ pkgsrc/sysutils/ups-nut/Makefile 2023/01/08 01:32:54 1.70
@@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
1# $NetBSD: Makefile,v 1.69 2023/01/08 01:14:23 gdt Exp $ 1# $NetBSD: Makefile,v 1.70 2023/01/08 01:32:54 gdt Exp $
2 2
3PKGREVISION= 4 3PKGREVISION= 5
4.include "Makefile.common" 4.include "Makefile.common"
5 5
6PKGNAME= ups-${DISTNAME} 6PKGNAME= ups-${DISTNAME}
7COMMENT= Network UPS Tools 7COMMENT= Network UPS Tools
8 8
9SUBST_CLASSES+= man-so 9SUBST_CLASSES+= man-so
10SUBST_MESSAGE.man-so= Fixing manpage .so references. 10SUBST_MESSAGE.man-so= Fixing manpage .so references.
11SUBST_STAGE.man-so= pre-build 11SUBST_STAGE.man-so= pre-build
12SUBST_FILES.man-so= docs/man/*.[0-9] 12SUBST_FILES.man-so= docs/man/*.[0-9]
13SUBST_SED.man-so= -e 's,^\.so \([^/]*\)\.\([0-9]\)$$,.so man\2/\1.\2,' 13SUBST_SED.man-so= -e 's,^\.so \([^/]*\)\.\([0-9]\)$$,.so man\2/\1.\2,'
14SUBST_NOOP_OK.man-so= yes 14SUBST_NOOP_OK.man-so= yes
15 15
16# Don't regenerate any files in tools/. 16# Don't regenerate any files in tools/.

cvs diff -r1.11 -r1.12 pkgsrc/sysutils/ups-nut/files/upsdriver.sh (expand / switch to unified diff)

--- pkgsrc/sysutils/ups-nut/files/upsdriver.sh 2023/01/08 01:14:23 1.11
+++ pkgsrc/sysutils/ups-nut/files/upsdriver.sh 2023/01/08 01:32:55 1.12
@@ -1,56 +1,40 @@ @@ -1,56 +1,40 @@
1#!@RCD_SCRIPTS_SHELL@ 1#!@RCD_SCRIPTS_SHELL@
2# 2#
3# $NetBSD: upsdriver.sh,v 1.11 2023/01/08 01:14:23 gdt Exp $ 3# $NetBSD: upsdriver.sh,v 1.12 2023/01/08 01:32:55 gdt Exp $
4# 4#
5# PROVIDE: upsdriver 5# PROVIDE: upsdriver
6# REQUIRE: NETWORK syslogd mountcritremote 6# REQUIRE: NETWORK syslogd mountcritremote
7# KEYWORD: shutdown 7# KEYWORD: shutdown
8# 8#
9# The standard approach is to leave "upsdriver_type" unset, so that 9# This script calls upsdrvctl to start and stop the driver(s). (Note
10# upsdrvctl is used to start and stop the driver(s). (Note that a 10# that a system might have more than one UPS, and upsdrvctl should
11# system might have more than one UPS, and upsdrvctl should support 11# support this.) See nutupsdrv(8), but upsdrvctl will invoke the
12# this.) See nutupsdrv(8), but upsdrvctl will invoke the driver 12# driver properly.
13# properly. 
14# 
15# An alternative is to set the driver type and flags. This only works 
16# for a single driver. This approach is deprecated and may be removed. 
17# 
18# upsdriver=YES 
19# upsdriver_type="newapc" 
20# upsdriver_flags="-a smartups" 
21 13
22if [ -f /etc/rc.subr ]; then 14if [ -f /etc/rc.subr ]; then
23 . /etc/rc.subr 15 . /etc/rc.subr
24fi 16fi
25 17
26name="upsdriver" 18name="upsdriver"
27rcvar=$name 19rcvar=$name
28 20
29if [ -f /etc/rc.subr ]; then 21if [ -f /etc/rc.subr ]; then
30 load_rc_config $name 22 load_rc_config $name
31fi 23fi
32 24
33if [ "${upsdriver_type:-upsdrvctl}" = "upsdrvctl" ]; then 25ctl_command="@PREFIX@/sbin/upsdrvctl"
34 ctl_command="@PREFIX@/sbin/upsdrvctl" 26required_files="@NUT_CONFDIR@/ups.conf"
35 required_files="@NUT_CONFDIR@/ups.conf" 27start_cmd="${ctl_command} start"
36 start_cmd="${ctl_command} start" 28stop_cmd="${ctl_command} stop"
37 stop_cmd="${ctl_command} stop" 29# XXX implement status after upsdrvctl does
38 # XXX implement status after upsdrvctl does 
39else 
40 command="@PREFIX@/libexec/nut/${upsdriver_type}" 
41 # XXX Restructure upsname into variable, but really just 
42 # delete this option. 
43 #upsname=`echo $upsdriver_flags | sed -e 's/^-a //' 
44 #pidfile="@NUT_STATEDIR@/${upsdriver_type}-${upsname}.pid" 
45fi 
46 30
47if [ -f /etc/rc.subr ]; then 31if [ -f /etc/rc.subr ]; then
48 run_rc_command "$1" 32 run_rc_command "$1"
49else 33else
50 @ECHO@ -n " ${name}" 34 @ECHO@ -n " ${name}"
51 if [ -n "${start_cmd}" ]; then 35 if [ -n "${start_cmd}" ]; then
52 ${start_cmd} 36 ${start_cmd}
53 else 37 else
54 ${command} ${upsdriver_flags} ${command_args} 38 ${command} ${upsdriver_flags} ${command_args}
55 fi 39 fi
56fi 40fi