Skip to content

Instantly share code, notes, and snippets.

@bejean
Created December 12, 2019 13:49
Show Gist options
  • Save bejean/40eb96506a9b4b2f5a564809034264f9 to your computer and use it in GitHub Desktop.
Save bejean/40eb96506a9b4b2f5a564809034264f9 to your computer and use it in GitHub Desktop.
kinana init.d script
#!/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