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

« back to all changes in this revision

Viewing changes to scripts/dld-6v0/ups

  • 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
 
#!/bin/sh
2
 
############################################################################## 
3
 
# Datei         :       /etc/init.d/smartups
4
 
# Beschreibung  :       Starten/Benden des UPS-Dienstes
5
 
# Datum         :       
6
 
# orig Autor    :       Based on /etc/init.d/lpd
7
 
# orig Autor    :       Taken in part from Miquel Smoorenburg's bcheckrc
8
 
############################################################################## 
9
 
# Ge�ndert von  :       Peter Bieringer <pb@bieringer.de> 
10
 
#  1999-06-25  
11
 
############################################################################## 
12
 
# Ge�ndert von  :       Ngo Than <than@delix.de> 
13
 
#       08.10.98      : Angepasst f�r delix
14
 
############################################################################## 
15
 
# Ge�ndert von  :       Erik Heim <erik@seitz.de> 
16
 
#       26.7.98 :       Angepasst f�r das startup.
17
 
############################################################################## 
18
 
# Possible changes:
19
 
#set -x
20
 
 
21
 
UPSPLACE=local
22
 
#UPSPLACE=remote
23
 
 
24
 
UPSMODEL=ups-trust425+625
25
 
UPSSERIALDEV=ttyS0
26
 
UPSMONITORHOST=some.where
27
 
 
28
 
UPSPATH=/usr/local/ups
29
 
 
30
 
############################################################################## 
31
 
 
32
 
subsys_parameter=$1
33
 
LOCKDIR=/var/lock/subsys
34
 
STARTUP_OK=0
35
 
STARTUP_FAIL=1
36
 
STARTUP_NA=2
37
 
 
38
 
if [ "$UPSPLACE" = "local" ]; then
39
 
    UPSMONITORHOST=localhost
40
 
fi
41
 
 
42
 
UPSMODELSTATE=/var/state/ups/$UPSMODEL-$UPSSERIALDEV
43
 
 
44
 
############################################################################## 
45
 
start_and_stop() {
46
 
   if [ -f /etc/init.d/functions ]
47
 
   then
48
 
      source /etc/init.d/functions
49
 
   else
50
 
      echo "FAIL: Datei /etc/init.d/functions ist nicht vorhanden!"
51
 
      exit $STARTUP_FAIL
52
 
   fi                                 
53
 
   source_file /etc/sysconfig/runservices               FAIL_ON_ERROR
54
 
   check_service "$UPS" UPS                             NA_ON_ERROR
55
 
 
56
 
if [ "$UPSPLACE" = "local" ]; then
57
 
   check_executable $UPSPATH/bin/$UPSMODEL              FAIL_ON_ERROR
58
 
   check_executable $UPSPATH/bin/upsd                   FAIL_ON_ERROR
59
 
fi
60
 
   check_executable $UPSPATH/bin/upsmon                 FAIL_ON_ERROR
61
 
   print_message
62
 
   check_lock $LOCKDIR/ups "$subsys_parameter"
63
 
}
64
 
############################################################################## 
65
 
# See how we were called.
66
 
############################################################################## 
67
 
case "$subsys_parameter" in
68
 
  start_msg)
69
 
       echo -n "Starte UPS..."
70
 
       ;;
71
 
  stop_msg)
72
 
       echo -n "Beende UPS..."
73
 
       ;;
74
 
  start)
75
 
        start_and_stop
76
 
        if [ "$UPSPLACE" = "local" ]; then
77
 
            logexec daemon $UPSPATH/bin/$UPSMODEL /dev/$UPSSERIALDEV
78
 
            logexec daemon $UPSPATH/bin/upsd $UPSMODELSTATE
79
 
        fi      
80
 
        logexec daemon $UPSPATH/bin/upsmon $UPSMONITORHOST
81
 
        logexec touch $LOCKDIR/ups
82
 
        logecho " "
83
 
        exit $FAIL
84
 
        ;;
85
 
  stop)
86
 
        start_and_stop
87
 
        logexec killproc upsmon
88
 
        if [ "$UPSPLACE" = "local" ]; then
89
 
            logexec killproc upsd
90
 
            logexec killproc $UPSMODEL
91
 
        fi
92
 
        logexec rm -f $LOCKDIR/ups
93
 
        logecho " "
94
 
        exit $FAIL
95
 
        ;;
96
 
  restart)
97
 
        $0 stop
98
 
        $0 start
99
 
        exit $?
100
 
        ;;
101
 
  *)
102
 
        echo "Usage: ups {start|stop|restart|start_msg|stop_msg}"
103
 
        exit $STARTUP_FAIL
104
 
        ;;
105
 
esac
106
 
 
107
 
exit $STARTUP_OK
108
 
##############################################################################