4
# Required-Start: $remote_fs
5
# Required-Stop: $remote_fs
6
# Default-Start: 2 3 4 5
8
# Short-Description: centralized coordination service
9
# Description: ZooKeeper is a centralized service for maintaining
10
# configuration information, naming, providing distributed
11
# synchronization, and providing group services.
14
# Author: Foo Bar <foobar@baz.org>
16
# Please remove the "Author" lines above and replace them
17
# with your own name if you copy and modify this script.
21
# Exit if the package is not installed
22
# Test that libzookeeper-java is installed
23
[ -r "/usr/share/java/zookeeper.jar" ] || exit 0
24
# Test that zookeeper is installed and not purged
25
[ -r "/etc/zookeeper/conf/environment" ] || exit 0
26
. /etc/zookeeper/conf/environment
28
# PATH should only include /usr/* if it runs after the mountnfs.sh script
29
PATH=/sbin:/usr/sbin:/bin:/usr/bin
30
DESC="centralized coordination service"
31
SCRIPTNAME=/etc/init.d/$NAME
33
# Read configuration variable file if it is present
34
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
36
# Load the VERBOSE setting and other rcS variables
39
# Define LSB log_* functions.
40
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
41
. /lib/lsb/init-functions
45
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $JAVA --user $USER --test > /dev/null \
51
# Function that starts the daemon/service
56
# 0 if daemon has been started
57
# 1 if daemon was already running
58
# 2 if daemon could not be started
59
is_running || return 1
65
chown $USER:$GROUP $PIDDIR
67
if [ ! -d $ZOO_LOG_DIR ]
71
chown $USER:$GROUP $ZOO_LOG_DIR
73
start-stop-daemon --start --quiet \
76
--chuid $USER:$GROUP \
81
-Dzookeeper.log.dir=${ZOO_LOG_DIR} \
82
-Dzookeeper.root.logger=${ZOO_LOG4J_PROP} \
88
# Function that stops the daemon/service
93
# 0 if daemon has been stopped
94
# 1 if daemon was already stopped
95
# 2 if daemon could not be stopped
96
# other if a failure occurred
97
is_running && return 1
99
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
101
[ "$RETVAL" = 2 ] && return 2
102
# Many daemons don't delete their pidfiles when they exit.
103
[ "$RETVAL" = 0 ] && rm -f $PIDFILE
109
if [ "x$JMXDISABLE" = "x" ]
111
[ "$VERBOSE" != no ] && log_action_msg "$NAME: JMX enabled by default"
112
# for some reason these two options are necessary on jdk6 on Ubuntu
113
# accord to the docs they are not necessary, but otw jconsole cannot
115
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=$JMXLOCALONLY"
117
[ "$VERBOSE" != no ] && log_action_msg "$NAME: JMX disabled by user request"
120
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
123
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
124
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
128
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
131
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
132
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
136
status_of_proc -p $PIDFILE "$NAME" "$NAME" && exit 0 || exit $?
138
restart|force-reload)
140
# If the "reload" option is implemented then remove the
141
# 'force-reload' alias
143
log_daemon_msg "Restarting $DESC" "$NAME"
150
1) log_end_msg 1 ;; # Old process is still running
151
*) log_end_msg 1 ;; # Failed to start
161
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2