forked from id/zookeeper-rpm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zookeeper.init
77 lines (64 loc) · 1.25 KB
/
zookeeper.init
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# ZooKeeper
#
# chkconfig: 2345 89 9
# description: zookeeper
# Source function library.
. /etc/rc.d/init.d/functions
PROG=zookeeper
LOCKFILE="/var/lock/subsys/$PROG"
# override variables listed down below in /etc/sysconfig/kafka
[ -e /etc/sysconfig/$PROG ] && . /etc/sysconfig/$PROG
ZOOKEEPER_USER=${ZOOKEEPER_USER:-zookeeper}
ZOOKEEPER_HOME=${ZOOKEEPER_HOME:-$(getent passwd $ZOOKEEPER_USER | cut -d: -f6)}
export ZOOCFGDIR=${ZOOKEEPER_CONFIG_DIR:-/etc/zookeeper}
retval=0
start() {
echo -n $"Starting $PROG: "
daemon --user $ZOOKEEPER_USER $ZOOKEEPER_HOME/bin/zkServer.sh start
retval=$?
echo
[ $retval -eq 0 ] && touch $LOCKFILE
return $retval
}
stop() {
echo -n $"Stopping $PROG: "
daemon --user $ZOOKEEPER_USER $ZOOKEEPER_HOME/bin/zkServer.sh stop
retval=$?
sleep 5
echo
[ $retval -eq 0 ] && rm -f $LOCKFILE
}
restart() {
stop
start
}
checkstatus(){
$ZOOKEEPER_HOME/bin/zkServer.sh status
retval=$?
}
condrestart(){
[ -e $LOCKFILE ] && restart || :
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
checkstatus
;;
restart)
restart
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
exit 1
esac
exit $retval