Last active
July 16, 2018 11:22
-
-
Save bejean/4fe04ed1c2f6131f3934b803bf47a184 to your computer and use it in GitHub Desktop.
Zookeeper init.d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# zookeeper Start/Stop | |
# | |
# change this value as necessary | |
RUNAS=zookeeper | |
APP=/home/zookeeper/zookeeper/bin/zkServer.sh | |
export JAVA_HOME=/usr/bin/java | |
if [ -n "$RUNAS" ]; then | |
# verify the specified run as user exists | |
runas_uid="`id -u "$RUNAS"`" | |
if [ $? -ne 0 ]; then | |
echo "Utilisteur $RUNAS non trouvé !" | |
exit 1 | |
fi | |
fi | |
start() { | |
echo -n "Démarrage de Zookeeper" | |
echo | |
if [ -n "$RUNAS" ]; then | |
su -c "$APP start" - "$RUNAS" | |
else | |
$APP start | |
fi | |
} | |
stop() { | |
echo -n "Arrêt de Zookeeper" | |
echo | |
if [ -n "$RUNAS" ]; then | |
su -c "$APP stop" - "$RUNAS" | |
else | |
$APP start | |
fi | |
} | |
restart() { | |
stop | |
sleep 5 | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart}" | |
exit 1 | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment