Subversion Repositories configs

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 - 1
#!/bin/sh
2
#
3
# Copyright (C) 1998-2010 VMware, Inc.  All Rights Reserved.
4
#
5
# This script manages the services needed to run VMware software
6
 
7
# Basic support for IRIX style chkconfig
8
# chkconfig: 235 25 6
9
# description: This service starts and stops vmamqpd
10
 
11
 
12
SCRIPTNAME="$(basename $(readlink -f "$0"))"
13
MODNAME="vmamqpd"
14
ETCDIR=/etc/vmware
15
 
16
. $ETCDIR/bootstrap
17
libdir="$LIBDIR"/vmware
18
 
19
. "$libdir"/scripts/util.sh
20
 
21
load_settings "$libdir" || exit 1
22
 
23
# This comment is a hack to prevent RedHat distributions from outputing
24
# "Starting <basename of this script>" when running this startup script.
25
# We just need to write the word daemon followed by a space
26
 
27
SYSTEM_DAEMON=vmamqpd
28
PIDFILE=/var/run/vmamqpd.pid
29
 
30
# Make sure the ESC byte is literal: Ash does not support echo -e
31
rc_done=' done'
32
rc_failed='failed'
33
 
34
#
35
# Utilities
36
#
37
 
38
upperCase() {
39
  echo "`echo $1|tr '[:lower:]' '[:upper:]'`"
40
}
41
 
42
vmware_start_daemon() {
43
   "$libdir/bin/$1" -d $PIDFILE
44
   return $?
45
}
46
 
47
vmware_stop_daemon() {
48
   if [ ! -e "$PIDFILE" ]; then
49
      return 0
50
   fi
51
 
52
   pid=`cat $PIDFILE`
53
 
54
   if [ "$pid" = "" ]; then
55
      return 0
56
   fi
57
 
58
   # Kill the process
59
   kill -15 $pid
60
   # Give it a few seconds to shut down properly
61
   for f in '1 2 3 4 5 6 7 8 9 10'; do
62
      if ! ps $pid >/dev/null; then
63
         # No need to wait if it's already down
64
         break
65
      fi
66
      sleep 1
67
   done
68
 
69
   # Give it a few seconds to shut down after the kill
70
   for f in '1 2 3 4 5 6 7 8 9 10'; do
71
      if ! ps $pid >/dev/null; then
72
         # No need to wait if it's already down
73
         break
74
      fi
75
      sleep 1
76
   done
77
 
78
   if ps $pid >/dev/null; then
79
      # Failed to kill it...
80
      return 1
81
   else
82
      # Success!
83
      rm -v $PIDFILE
84
      return 0
85
   fi
86
}
87
 
88
vmware_daemon_status() {
89
   echo -n "$1 "
90
   if vmware_check_pidfile "/var/run/$1.pid"; then
91
      echo 'is running'
92
   else
93
      echo 'is not running'
94
      exitcode=$(($exitcode + 1))
95
   fi
96
}
97
 
98
main()
99
{
100
   # See how we were called.
101
   case "$1" in
102
      start)
103
         exitcode='0'
104
 
105
         vmware_exec 'Starting VMware AMQP Service:' vmware_start_daemon $SYSTEM_DAEMON
106
         exitcode=$(($exitcode + $?))
107
 
108
 
109
         if [ "$exitcode" -gt 0 ]; then
110
            exit 1
111
         fi
112
         ;;
113
 
114
      stop)
115
         exitcode='0'
116
 
117
         vmware_exec 'Stopping VMware AMQP Service:' vmware_stop_daemon
118
         exitcode=$(($exitcode + $?))
119
 
120
         if [ "$exitcode" -gt 0 ]; then
121
            exit 1
122
         fi
123
         ;;
124
 
125
      status)
126
         exitcode='0'
127
 
128
         vmware_daemon_status $SYSTEM_DAEMON
129
         exitcode=$(($exitcode + $?))
130
 
131
         if [ "$exitcode" -ne 0 ]; then
132
            exit 1
133
         fi
134
         ;;
135
 
136
      restart | force-reload)
137
         "$0" stop && "$0" start
138
         ;;
139
 
140
      source)
141
         # Used to source the script so that functions can be
142
         # selectively overridden.
143
         return 0
144
         ;;
145
 
146
      *)
147
         echo "Usage: `basename "$0"` {start|stop|status|restart|force-reload}"
148
         exit 1
149
   esac
150
 
151
   exit 0
152
}
153
 
154
main "$@"