diff --git a/kibana4_init b/kibana4_init index ddfa289..4768bf0 100755 --- a/kibana4_init +++ b/kibana4_init @@ -2,7 +2,6 @@ # # /etc/init.d/kibana4_init -- startup script for kibana4 # bsmith@the408.com 2015-02-20; used elasticsearch init script as template -# updated 2015-12-04 # https://github.com/akabdog/scripts/edit/master/kibana4_init # ### BEGIN INIT INFO @@ -26,8 +25,11 @@ DESC="Kibana4" USER=nobody ES_HOST="localhost" +# Define LSB log_* functions. +. /lib/lsb/init-functions + if [ `id -u` -ne 0 ]; then - echo "You need root privileges to run this script" + log_daemon_msg "You need root privileges to run this script" exit 1 fi @@ -43,8 +45,7 @@ case "$1" in pid=`pidofproc -p $PID_FILE kibana` if [ -n "$pid" ] ; then - log_begin_msg "Already running." - echo "Already running." + log_daemon_msg "Already running." log_end_msg 0 exit 0 fi @@ -57,15 +58,13 @@ case "$1" in response=$(curl -sLI "http://$ES_HOST:9200") if [ -z "$response" ]; then - log_begin_msg "Elasticsearch not running, waiting..." - echo "Elasticsearch not running, waiting 10 seconds..." - log_end_msg 0 + log_daemon_msg "Elasticsearch not running, waiting 10 seconds..." sleep 10 else # Start Daemon elasticsearchDOWN=false start-stop-daemon --start --user "$USER" -c "$USER" --pidfile "$PID_FILE" --make-pidfile --background --exec $DAEMON - echo "Is elasticsearch down? $elasticsearchDOWN" + log_daemon_msg "Is elasticsearch down? $elasticsearchDOWN" fi timer=$((timer+1)) done @@ -78,7 +77,7 @@ case "$1" in start-stop-daemon --stop --user "$USER" -c "$USER" --pidfile "$PID_FILE" \ --retry=TERM/20/KILL/5 >/dev/null if [ $? -eq 1 ]; then - log_progress_msg "$DESC is not running but pid file exists, cleaning up" + log_daemon_msg "$DESC is not running but pid file exists, cleaning up" elif [ $? -eq 3 ]; then PID="`cat $PID_FILE`" log_failure_msg "Failed to stop $DESC (pid $PID)" @@ -86,7 +85,7 @@ case "$1" in fi rm -f "$PID_FILE" else - log_progress_msg "(not running)" + log_daemon_msg "(not running)" fi log_end_msg 0 ;; @@ -101,7 +100,7 @@ case "$1" in $0 start ;; *) - log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}" + log_daemon_msg "Usage: $0 {start|stop|restart|force-reload|status}" exit 1 ;; esac