| @@ -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 | |
22 | if [ -f /etc/rc.subr ]; then | | 14 | if [ -f /etc/rc.subr ]; then |
23 | . /etc/rc.subr | | 15 | . /etc/rc.subr |
24 | fi | | 16 | fi |
25 | | | 17 | |
26 | name="upsdriver" | | 18 | name="upsdriver" |
27 | rcvar=$name | | 19 | rcvar=$name |
28 | | | 20 | |
29 | if [ -f /etc/rc.subr ]; then | | 21 | if [ -f /etc/rc.subr ]; then |
30 | load_rc_config $name | | 22 | load_rc_config $name |
31 | fi | | 23 | fi |
32 | | | 24 | |
33 | if [ "${upsdriver_type:-upsdrvctl}" = "upsdrvctl" ]; then | | 25 | ctl_command="@PREFIX@/sbin/upsdrvctl" |
34 | ctl_command="@PREFIX@/sbin/upsdrvctl" | | 26 | required_files="@NUT_CONFDIR@/ups.conf" |
35 | required_files="@NUT_CONFDIR@/ups.conf" | | 27 | start_cmd="${ctl_command} start" |
36 | start_cmd="${ctl_command} start" | | 28 | stop_cmd="${ctl_command} stop" |
37 | stop_cmd="${ctl_command} stop" | | 29 | # XXX implement status after upsdrvctl does |
38 | # XXX implement status after upsdrvctl does | | | |
39 | else | | | |
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" | | | |
45 | fi | | | |
46 | | | 30 | |
47 | if [ -f /etc/rc.subr ]; then | | 31 | if [ -f /etc/rc.subr ]; then |
48 | run_rc_command "$1" | | 32 | run_rc_command "$1" |
49 | else | | 33 | else |
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 |
56 | fi | | 40 | fi |