Added
Link Here
|
1 |
#!/bin/sh |
2 |
|
3 |
# Authored by vvd@unislabs.com. |
4 |
|
5 |
# PROVIDE: nut_upslog |
6 |
# REQUIRE: NETWORKING nut |
7 |
# BEFORE: LOGIN |
8 |
# KEYWORD: shutdown |
9 |
|
10 |
. /etc/rc.subr |
11 |
|
12 |
case $0 in |
13 |
/etc/rc*) |
14 |
# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown), |
15 |
# so get the name of the script from $_file |
16 |
name=$_file |
17 |
;; |
18 |
*) |
19 |
name=$0 |
20 |
;; |
21 |
esac |
22 |
|
23 |
name=${name##*/} |
24 |
rcvar=${name}_enable |
25 |
|
26 |
load_rc_config "${name}" |
27 |
|
28 |
# Define these nut_upslog* variables in one of these files: |
29 |
# /etc/rc.conf |
30 |
# /etc/rc.conf.local |
31 |
# /etc/rc.conf.d/nut_upslog |
32 |
# |
33 |
# If you want to log several different UPSes: |
34 |
# ln -s nut_upslog /usr/local/etc/rc.d/NAME |
35 |
# then set variables NAME_enable, NAME_ups, NAME_pidbase, NAME_logfile and etc. |
36 |
# |
37 |
# DO NOT CHANGE THESE DEFAULT VALUES HERE |
38 |
# |
39 |
eval "${rcvar}=\${${rcvar}:-'NO'}" |
40 |
eval "_prefix=\${${name}_prefix:-'/usr/local'}" |
41 |
eval "_logfile=\${${name}_logfile:-'/var/log/nut/ups.log'}" |
42 |
eval "_interval=\${${name}_interval:-'300'}" |
43 |
eval "_ups=\${${name}_ups:-'myups@localhost'}" |
44 |
eval "_pidbase=\${${name}_pidbase:-'upslog'}" |
45 |
eval "_format=\${${name}_format:+-f \${${name}_format}}" |
46 |
eval "${name}_flags=\${${name}_flags:-'-s ${_ups} -l ${_logfile} -i ${_interval} -p ${_pidbase} ${_format}'}" |
47 |
|
48 |
required_dirs="%%STATEDIR%%" |
49 |
pidfile="%%STATEDIR%%/${_pidbase}.pid" |
50 |
command="${_prefix}/bin/upslog" |
51 |
|
52 |
run_rc_command "$1" |