Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
6 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters