Skip to content

Commit

Permalink
migrating all echo statements to log_daemon_msg from /lib/lsb/init-fu…
Browse files Browse the repository at this point in the history
…nctions
  • Loading branch information
brian.smith committed Dec 5, 2015
1 parent 3284172 commit 4eec86b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions kibana4_init
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand All @@ -78,15 +77,15 @@ 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)"
exit 1
fi
rm -f "$PID_FILE"
else
log_progress_msg "(not running)"
log_daemon_msg "(not running)"
fi
log_end_msg 0
;;
Expand All @@ -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
Expand Down

0 comments on commit 4eec86b

Please sign in to comment.