Created
December 12, 2019 13:49
-
-
Save bejean/40eb96506a9b4b2f5a564809034264f9 to your computer and use it in GitHub Desktop.
kinana init.d script
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 | |
# | |
# kibana Start/Stop kibana server. | |
# | |
# chkconfig: 35 99 01 | |
# description: kibana server | |
# | |
# processname: kibana | |
# | |
# change this value as necessary | |
RUNAS=elasticsearch | |
KB_HOME=/opt/kibana/kibana | |
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 kibana serveur" | |
echo | |
if [ -f $KB_HOME/kibana.pid ]; then | |
echo "Fichier $KB_HOME/kibana.pid existe déjà !" | |
exit 1 | |
else | |
cd $KB_HOME | |
if [ -n "$RUNAS" ] && [ "$(whoami)" != "$RUNAS" ]; then | |
su -c "$KB_HOME/bin/kibana >> $KB_HOME/../logs/kibana.out 2>&1 &" - "$RUNAS" | |
else | |
$KB_HOME/bin/kibana >> $KB_HOME/../logs/kibana.out 2>&1 & | |
fi | |
ps -ax | grep "kibana" | grep -v "start" | grep -v "grep" | awk '{print $1}' > $KB_HOME/kibana.pid | |
fi | |
} | |
stop() { | |
echo -n $"Arrêt kibana serveur" | |
echo | |
if [ -f $KB_HOME/kibana.pid ]; then | |
kill -9 `cat $KB_HOME/kibana.pid` | |
rm -f $KB_HOME/kibana.pid | |
else | |
echo "Fichier $KB_HOME/kibana.pid non trouvé !" | |
exit 1 | |
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