File: ipp-shutdown-daemon.sh

package info (click to toggle)
nut 2.8.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,356 kB
  • sloc: ansic: 123,904; sh: 14,718; cpp: 12,558; makefile: 5,212; python: 1,114; perl: 855; xml: 47
file content (41 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#THIS IS WORK IN PROGRESS, THIS IS NOT FUNCTIONAL.
exit

#!/bin/sh
#       ipp-shutdown-daemon
#
#       Copyright (c) 2013-2017, by Eaton (R) Corporation. All rights reserved.
#
#       A shell script to detect shutdown from NMC cards IPP - Unix (NUT)
#       It needs ipp.conf file.
#

NUT_DIR="/usr/local/ups"
NUT_CFG_DIR=""
for D in "$NUT_DIR/etc" "/etc/nut" "/etc/ups" ; do
	if [ -d "$D" ] && [ -f "$D/ups.conf" ] && [ -f "$D/ipp.conf" ] ; then
		NUT_CFG_DIR="$D"
		break
	fi
done
unset D
CONFIG_IPP="$NUT_CFG_DIR/ipp.conf"

# Note: $NUT_DIR/xbin holds the wrappers to run NUT binaries with co-bundled
# third party libs and hopefully without conflicts induced for the OS binaries
PATH="$NUT_DIR/xbin:$NUT_DIR/sbin:$NUT_DIR/bin:$PATH"
export PATH

# Search for binaries under current PATH normally, no hardcoding
NUT_UPSC="upsc"
#NUT_UPSC="$NUT_DIR/xbin/upsc"

if [ -f "$CONFIG_IPP" ] ; then
	. "$CONFIG_IPP"
fi

# Convert to parsing of "ipp-status -p" which reports all needed details
for dev in `$NUT_UPSC -l 2>/dev/null`; do
	shutdown="`$NUT_UPSC "$dev"@localhost ups.timer.shutdown 2>/dev/null`"
	reboot="`$NUT_UPSC "$dev"@localhost ups.timer.reboot 2>/dev/null`"
done