~ubuntu-branches/ubuntu/saucy/nut/saucy

« back to all changes in this revision

Viewing changes to scripts/HP-UX/nut-upsmon.sh

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Quette
  • Date: 2004-05-28 13:10:01 UTC
  • mto: (16.1.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040528131001-yj2m9qcez4ya2w14
Tags: upstream-1.4.2
ImportĀ upstreamĀ versionĀ 1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/sbin/sh
 
2
 
 
3
#
 
4
# nut-upsmon: NUT ups monitor start-up and shutdown script
 
5
#
 
6
 
 
7
# Allowed exit values:
 
8
#       0 = success; causes "OK" to show up in checklist.
 
9
#       1 = failure; causes "FAIL" to show up in checklist.
 
10
#       2 = skip; causes "N/A" to show up in the checklist.
 
11
#           Use this value if execution of this script is overridden
 
12
#           by the use of a control variable, or if this script is not
 
13
#           appropriate to execute for some other reason.
 
14
#       3 = reboot; causes the system to be rebooted after execution.
 
15
 
 
16
# Input and output:
 
17
#       stdin is redirected from /dev/null
 
18
#
 
19
#       stdout and stderr are redirected to the /etc/rc.log file
 
20
#       during checklist mode, or to the console in raw mode.
 
21
 
 
22
umask 022
 
23
 
 
24
PATH=/usr/sbin:/usr/bin:/sbin
 
25
export PATH
 
26
 
 
27
WHAT='NUT UPS monitor (Network UPS Tools -- http://www.exploits.org/nut)'
 
28
WHAT_PATH=/opt/nut/sbin/upsmon
 
29
WHAT_CONFIG=/etc/rc.config.d/nut-upsmon
 
30
 
 
31
# NOTE: If your script executes in run state 0 or state 1, then /usr might
 
32
#       not be available.  Do not attempt to access commands or files in
 
33
#       /usr unless your script executes in run state 2 or greater.  Other
 
34
#       file systems typically not mounted until run state 2 include /var
 
35
#       and /opt.
 
36
 
 
37
rval=0
 
38
 
 
39
# Check the exit value of a command run by this script.  If non-zero, the
 
40
# exit code is echoed to the log file and the return value of this script
 
41
# is set to indicate failure.
 
42
 
 
43
set_return() {
 
44
        x=$?
 
45
        if [ $x -ne 0 ]; then
 
46
                echo "EXIT CODE: $x"
 
47
                rval=1  # script FAILed
 
48
        fi
 
49
}
 
50
 
 
51
case $1 in
 
52
'start_msg')
 
53
        echo "Starting $WHAT"
 
54
        ;;
 
55
 
 
56
'stop_msg')
 
57
        echo "Stopping $WHAT"
 
58
        ;;
 
59
 
 
60
'start')
 
61
        if [ -f $WHAT_CONFIG ] ; then
 
62
                . $WHAT_CONFIG
 
63
        else
 
64
                echo "ERROR: $WHAT_CONFIG defaults file MISSING"
 
65
        fi
 
66
        
 
67
 
 
68
        if [ "$NUT_START" -eq 1 -a -x $WHAT_PATH ]; then
 
69
                 $WHAT_PATH $UPSMON_ARGS && echo $WHAT $UPSMON_ARGS started
 
70
                set_return
 
71
        else
 
72
                rval=2
 
73
        fi
 
74
        ;;
 
75
 
 
76
'stop')
 
77
        $WHAT_PATH -c stop
 
78
        if [ $? -eq 0 ]; then
 
79
                echo "$WHAT stopped"
 
80
        else
 
81
                rval=1
 
82
                echo "Unable to stop $WHAT"
 
83
        fi
 
84
        ;;
 
85
 
 
86
*)
 
87
        echo "usage: $0 {start|stop|start_msg|stop_msg}"
 
88
        rval=1
 
89
        ;;
 
90
esac
 
91
 
 
92
exit $rval