|
9 | 9 | # is to just pick out some strings relevant for tracking config changes.
|
10 | 10 | #
|
11 | 11 | # Copyright (C) 2016-2020 Eaton
|
12 |
| -# Copyright (C) 2020-2022 Jim Klimov <jimklimov+nut@gmail.com> |
| 12 | +# Copyright (C) 2020-2023 Jim Klimov <jimklimov+nut@gmail.com> |
13 | 13 | #
|
14 | 14 | # This program is free software; you can redistribute it and/or modify
|
15 | 15 | # it under the terms of the GNU General Public License as published by
|
|
171 | 171 | # Cache needed bits of ups.conf to speed up later parsing. Note that these
|
172 | 172 | # data are needed for most operations, and populated by upslist_readFile()
|
173 | 173 | UPSCONF_DATA=""
|
174 |
| -# Subset of normalized data above that only has sections, drivers and ports |
| 174 | +# Subset of normalized data above that only has sections, drivers and ports (SDP) |
175 | 175 | UPSCONF_DATA_SDP=""
|
176 | 176 |
|
177 | 177 | # List of configured UPSes in the config-file
|
@@ -479,8 +479,45 @@ upsconf_getDriverMedia() {
|
479 | 479 | # particular system's physics, both serial and network media may need USB).
|
480 | 480 | CURR_DRV="`upsconf_getDriver "$1"`" || return $?
|
481 | 481 | case "$CURR_DRV" in
|
482 |
| - *netxml*|*snmp*|*ipmi*|*powerman*|*-mib*|*avahi*|*apcupsd*) |
| 482 | + *netxml*|*snmp*|*ipmi*|*powerman*|*-mib*|*avahi*) |
483 | 483 | printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;;
|
| 484 | + *apcupsd-ups*) |
| 485 | + # Relay from a nearby apcupsd network server into NUT ecosystem: |
| 486 | + CURR_PORT="`upsconf_getPort "$1"`" || CURR_PORT="" |
| 487 | + case "$CURR_PORT" in |
| 488 | + *localhost*|*127.0.0.1*|*::1*) |
| 489 | + printf '%s\n%s\n' "$CURR_DRV" "network-localhost" ; return ;; |
| 490 | + *) |
| 491 | + printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;; |
| 492 | + esac |
| 493 | + ;; |
| 494 | + *apc_modbus*) |
| 495 | + CURR_PORT="`upsconf_getPort "$1"`" || CURR_PORT="" |
| 496 | + CURR_PORTTYPE="`upsconf_getValue "$1" 'porttype'`" || CURR_PORTTYPE="" |
| 497 | + case "$CURR_PORTTYPE" in |
| 498 | + *usb*) |
| 499 | + printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;; |
| 500 | + *serial*) |
| 501 | + printf '%s\n%s\n' "$CURR_DRV" "serial" ; return ;; |
| 502 | + *) # default depends on driver build (against libmodbus |
| 503 | + # version with or without support for usb) |
| 504 | + # TOTHINK: Check for presence of config values like |
| 505 | + # vendorid (USB) or baud (Serial)? They are optional |
| 506 | + # with reasonable defaults anyway... |
| 507 | + case "$CURR_PORT" in |
| 508 | + *auto*) |
| 509 | + printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;; |
| 510 | + /*) |
| 511 | + printf '%s\n%s\n' "$CURR_DRV" "serial" ; return ;; |
| 512 | + *localhost*|*127.0.0.1*|*::1*) |
| 513 | + printf '%s\n%s\n' "$CURR_DRV" "network-localhost" ; return ;; |
| 514 | + *) |
| 515 | + printf '%s\n%s\n' "$CURR_DRV" "network" ; return ;; |
| 516 | + esac |
| 517 | + # returns are above, but just in case - have a fallback: |
| 518 | + printf '%s\n%s\n' "$CURR_DRV" "" ; return ;; |
| 519 | + esac |
| 520 | + ;; |
484 | 521 | *usb*)
|
485 | 522 | printf '%s\n%s\n' "$CURR_DRV" "usb" ; return ;;
|
486 | 523 | nutdrv_qx) # May be direct serial or USB
|
|
0 commit comments