File: ipp-event.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 (53 lines) | stat: -rw-r--r-- 1,195 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
42
43
44
45
46
47
48
49
50
51
52
53
#THIS IS WORK IN PROGRESS, THIS IS NOT FUNCTIONAL
exit

#!/bin/sh
#	ipp-event
#
#	Copyright (c) 2013-2017, by Eaton (R) Corporation. All rights reserved.
#
#	A shell script to manage event from 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. Scripts:
CMD_NOTIFIER="ipp-notifier.sh"
DAEMON="ipp-shutdown-daemon.sh"
#CMD_NOTIFIER="$NUT_DIR/bin/ipp-notifier.sh"
#DAEMON="$NUT_DIR/bin/ipp-shutdown-daemon.sh"

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

#call notifier script
$CMD_NOTIFIER "$*" &

PROC="`ps -ef | grep "$DAEMON" | awk   -F" " '{print $2}'`"
case "$1" in
	ONBATT)
		if [ $PROC = "" ];then
			$DAEMON &
		fi
	;;
	ONLINE)
		kill -9 $PROC
	;;
esac