Skip to content

Instantly share code, notes, and snippets.

@mjiderhamn
Forked from thisismitch/kibana-4.x-default
Last active October 21, 2015 14:35
Show Gist options
  • Save mjiderhamn/204c766caecb66ffbeae to your computer and use it in GitHub Desktop.
Save mjiderhamn/204c766caecb66ffbeae to your computer and use it in GitHub Desktop.
ELK Kibana4
#!/bin/sh
#
# /etc/init.d/kibana -- startup script for kibana
# bsmith@the408.com 2015-02-20; used elasticsearch init script as template
# https://github.com/akabdog/scripts/edit/master/kibana4_init
#
### BEGIN INIT INFO
# Provides: kibana
# Required-Start: $network $remote_fs $named
# Required-Stop: $network $remote_fs $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts kibana4
# Description: Starts kibana4 using start-stop-daemon
### END INIT INFO
#configure this with wherever you unpacked kibana:
KIBANA_BIN=/local/java/kibana-4.1.2-linux-x64/bin
PATH=/bin:/usr/bin:/sbin:/usr/sbin:$KIBANA_BIN
DAEMON=$KIBANA_BIN/kibana
NAME=kibana
DESC="Kibana"
PID_FILE=/var/run/$NAME.pid
KIBANA_USER=kibana
if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 1
fi
#
# Source function library.
#
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
case "$1" in
start)
echo "Starting $DESC"
pid=`pidofproc -p $PID_FILE kibana`
if [ -n "$pid" ] ; then
echo "Already running."
exit 0
fi
# Start Daemon
# --user $ES_USER
daemon --user $KIBANA_USER --pidfile "$PID_FILE" $DAEMON > /dev/null 2>&1 & echo $! > "$PID_FILE"
echo "$DESC started"
# start-stop-daemon --start --pidfile "$PID_FILE" --make-pidfile --background --exec $DAEMON
# log_end_msg $?
;;
stop)
echo -n "Stopping $DESC: "
if [ -f "$PID_FILE" ]; then
killproc -p $PID_FILE -d 20 $DESC
killall --process-group --user $KIBANA_USER
# start-stop-daemon --stop --pidfile "$PID_FILE" \
# --retry=TERM/20/KILL/5 >/dev/null
if [ $? -eq 1 ]; then
echo "$DESC is not running but pid file exists, cleaning up"
elif [ $? -eq 3 ]; then
PID="`cat $PID_FILE`"
echo "Failed to stop $DESC (pid $PID)"
exit 1
fi
rm -f "$PID_FILE"
else
echo "(not running)"
fi
# log_end_msg 0
;;
status)
status_of_proc -p $PID_FILE kibana kibana && exit 0 || exit $?
;;
restart|force-reload)
if [ -f "$PID_FILE" ]; then
$0 stop
sleep 1
fi
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
;;
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment