diff options
author | Cy Schubert <cy@FreeBSD.org> | 2022-08-21 15:21:51 +0000 |
---|---|---|
committer | Cy Schubert <cy@FreeBSD.org> | 2022-08-28 21:16:40 +0000 |
commit | 0b5e039674aa1f529e2ebc67da11bdadcb4db6e6 (patch) | |
tree | 8c897225f5a314a69db7aacd534386a39e958e51 | |
parent | dec4ecc3afecab035a4d4fa59c35093d9f53ffd5 (diff) | |
download | ports-0b5e039674aa1f529e2ebc67da11bdadcb4db6e6.tar.gz ports-0b5e039674aa1f529e2ebc67da11bdadcb4db6e6.zip |
sysutils/nut*: Alternate upslog support for multiple UPSs
Add sample rc script to allow a user to copy a sample rc script to
rc.d, allowing the user to use multiple instances of upslog(8) with
multiple instances of the rc script to log multiple UPSs on the same
system.
The sample rc script was provided by vvd@unislabs.com.
PR: 265963
Reported by: vvd@unislabs.com
Submitted by: vvd@unislabs.com
-rw-r--r-- | sysutils/nut-devel/Makefile | 3 | ||||
-rw-r--r-- | sysutils/nut-devel/files/nut_upslog.sample | 52 | ||||
-rw-r--r-- | sysutils/nut-devel/pkg-plist | 1 | ||||
-rw-r--r-- | sysutils/nut/Makefile | 3 | ||||
-rw-r--r-- | sysutils/nut/files/nut_upslog.sample | 52 | ||||
-rw-r--r-- | sysutils/nut/pkg-plist | 1 |
6 files changed, 110 insertions, 2 deletions
diff --git a/sysutils/nut-devel/Makefile b/sysutils/nut-devel/Makefile index e40b38582e55..d2d54676e8dc 100644 --- a/sysutils/nut-devel/Makefile +++ b/sysutils/nut-devel/Makefile @@ -1,6 +1,6 @@ PORTNAME= nut PORTVERSION= ${NUT_COMMIT_DATE} -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils PKGNAMESUFFIX= -devel # MASTER_SITES= http://www.networkupstools.org/source/${PORTVERSION:R}/ @@ -164,6 +164,7 @@ post-install: @${MKDIR} ${STAGEDIR}${EXAMPLESDIR} ${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample ${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample + ${INSTALL_DATA} ${PATCHDIR}/nut_upslog.sample ${STAGEDIR}${EXAMPLESDIR}/nut_upslog.sample ${MKDIR} ${STAGEDIR}/var/log/nut .include <bsd.port.post.mk> diff --git a/sysutils/nut-devel/files/nut_upslog.sample b/sysutils/nut-devel/files/nut_upslog.sample new file mode 100644 index 000000000000..126a47a70d3a --- /dev/null +++ b/sysutils/nut-devel/files/nut_upslog.sample @@ -0,0 +1,52 @@ +#!/bin/sh + +# Authored by vvd@unislabs.com. + +# PROVIDE: nut_upslog +# REQUIRE: NETWORKING nut +# BEFORE: LOGIN +# KEYWORD: shutdown + +. /etc/rc.subr + +case $0 in +/etc/rc*) + # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown), + # so get the name of the script from $_file + name=$_file + ;; +*) + name=$0 + ;; +esac + +name=${name##*/} +rcvar=${name}_enable + +load_rc_config "${name}" + +# Define these nut_upslog* variables in one of these files: +# /etc/rc.conf +# /etc/rc.conf.local +# /etc/rc.conf.d/nut_upslog +# +# If you want to log several different UPSes: +# ln -s nut_upslog /usr/local/etc/rc.d/NAME +# then set variables NAME_enable, NAME_ups, NAME_pidbase, NAME_logfile and etc. +# +# DO NOT CHANGE THESE DEFAULT VALUES HERE +# +eval "${rcvar}=\${${rcvar}:-'NO'}" +eval "_prefix=\${${name}_prefix:-'/usr/local'}" +eval "_logfile=\${${name}_logfile:-'/var/log/nut/ups.log'}" +eval "_interval=\${${name}_interval:-'300'}" +eval "_ups=\${${name}_ups:-'myups@localhost'}" +eval "_pidbase=\${${name}_pidbase:-'upslog'}" +eval "_format=\${${name}_format:+-f \${${name}_format}}" +eval "${name}_flags=\${${name}_flags:-'-s ${_ups} -l ${_logfile} -i ${_interval} -p ${_pidbase} ${_format}'}" + +required_dirs="%%STATEDIR%%" +pidfile="%%STATEDIR%%/${_pidbase}.pid" +command="${_prefix}/bin/upslog" + +run_rc_command "$1" diff --git a/sysutils/nut-devel/pkg-plist b/sysutils/nut-devel/pkg-plist index 66f4d6398ca9..d8fb87805dce 100644 --- a/sysutils/nut-devel/pkg-plist +++ b/sysutils/nut-devel/pkg-plist @@ -18,6 +18,7 @@ @sample %%ETCDIR%%/upsmon.conf.sample @sample %%ETCDIR%%/upssched.conf.sample @sample %%EXAMPLESDIR%%/newsyslog.sample etc/newsyslog.conf.d/nut.conf +@sample %%EXAMPLESDIR%%/nut_upslog.sample @sample %%EXAMPLESDIR%%/syslog.sample etc/syslog.d/nut %%USB%%etc/devd/nut-usb.conf bin/nut-scanner diff --git a/sysutils/nut/Makefile b/sysutils/nut/Makefile index e388164c19b6..4d5bacca82db 100644 --- a/sysutils/nut/Makefile +++ b/sysutils/nut/Makefile @@ -1,6 +1,6 @@ PORTNAME= nut PORTVERSION= 2.8.0 -PORTREVISION= 7 +PORTREVISION= 8 CATEGORIES= sysutils MASTER_SITES= http://www.networkupstools.org/source/${PORTVERSION:R}/ @@ -142,6 +142,7 @@ post-install: @${MKDIR} ${STAGEDIR}${EXAMPLESDIR} ${INSTALL_DATA} ${PATCHDIR}/nut.syslog ${STAGEDIR}${EXAMPLESDIR}/syslog.sample ${INSTALL_DATA} ${PATCHDIR}/nut.newsyslog ${STAGEDIR}${EXAMPLESDIR}/newsyslog.sample + ${INSTALL_DATA} ${PATCHDIR}/nut_upslog.sample ${STAGEDIR}${EXAMPLESDIR}/nut_upslog.sample ${MKDIR} ${STAGEDIR}/var/log/nut @${RM} ${STAGEDIR}${PREFIX}/etc/nut/solaris-init/nut @${RMDIR} ${STAGEDIR}${PREFIX}/etc/nut/solaris-init diff --git a/sysutils/nut/files/nut_upslog.sample b/sysutils/nut/files/nut_upslog.sample new file mode 100644 index 000000000000..126a47a70d3a --- /dev/null +++ b/sysutils/nut/files/nut_upslog.sample @@ -0,0 +1,52 @@ +#!/bin/sh + +# Authored by vvd@unislabs.com. + +# PROVIDE: nut_upslog +# REQUIRE: NETWORKING nut +# BEFORE: LOGIN +# KEYWORD: shutdown + +. /etc/rc.subr + +case $0 in +/etc/rc*) + # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown), + # so get the name of the script from $_file + name=$_file + ;; +*) + name=$0 + ;; +esac + +name=${name##*/} +rcvar=${name}_enable + +load_rc_config "${name}" + +# Define these nut_upslog* variables in one of these files: +# /etc/rc.conf +# /etc/rc.conf.local +# /etc/rc.conf.d/nut_upslog +# +# If you want to log several different UPSes: +# ln -s nut_upslog /usr/local/etc/rc.d/NAME +# then set variables NAME_enable, NAME_ups, NAME_pidbase, NAME_logfile and etc. +# +# DO NOT CHANGE THESE DEFAULT VALUES HERE +# +eval "${rcvar}=\${${rcvar}:-'NO'}" +eval "_prefix=\${${name}_prefix:-'/usr/local'}" +eval "_logfile=\${${name}_logfile:-'/var/log/nut/ups.log'}" +eval "_interval=\${${name}_interval:-'300'}" +eval "_ups=\${${name}_ups:-'myups@localhost'}" +eval "_pidbase=\${${name}_pidbase:-'upslog'}" +eval "_format=\${${name}_format:+-f \${${name}_format}}" +eval "${name}_flags=\${${name}_flags:-'-s ${_ups} -l ${_logfile} -i ${_interval} -p ${_pidbase} ${_format}'}" + +required_dirs="%%STATEDIR%%" +pidfile="%%STATEDIR%%/${_pidbase}.pid" +command="${_prefix}/bin/upslog" + +run_rc_command "$1" diff --git a/sysutils/nut/pkg-plist b/sysutils/nut/pkg-plist index 51fabcb8782c..d8fbf6fc4567 100644 --- a/sysutils/nut/pkg-plist +++ b/sysutils/nut/pkg-plist @@ -18,6 +18,7 @@ @sample %%ETCDIR%%/upsmon.conf.sample @sample %%ETCDIR%%/upssched.conf.sample @sample %%EXAMPLESDIR%%/newsyslog.sample etc/newsyslog.conf.d/nut.conf +@sample %%EXAMPLESDIR%%/nut_upslog.sample @sample %%EXAMPLESDIR%%/syslog.sample etc/syslog.d/nut %%USB%%etc/devd/nut-usb.conf bin/nut-scanner |