slackbuilds/system/graylog-sidecar/rc.graylog-sidecar

51 lines
932 B
Bash

#!/bin/bash
PIDOF_CMD=/sbin/pidof
ECHO_CMD=/usr/bin/echo
SLEEP_CMD=/usr/bin/sleep
KILL_CMD=/bin/kill
NAME=graylog-sidecar
GRAYLOG_CMD=${GRAYLOG_CMD-/usr/bin/${NAME}}
graylog_sidecar_start() {
if [ -n "$($PIDOF_CMD graylog-sidecar)" ]; then
$ECHO_CMD "Graylog Sidecar seems to be already running."
return
fi
$ECHO_CMD "Starting Graylog Sidecar."
$GRAYLOG_CMD &
}
graylog_sidecar_stop() {
if [ -z "$($PIDOF_CMD graylog-sidecar)" ]; then
$ECHO_CMD "Graylog Sidecar does not seem to be running."
return
fi
$ECHO_CMD "Stopping Graylog Sidecar."
$KILL_CMD $($PIDOF_CMD graylog-sidecar)
}
graylog_sidecar_restart() {
$ECHO_CMD "Restarting Graylog Sidecar."
graylog_sidecar_stop
$SLEEP_CMD 5
graylog_sidecar_start
}
case "$1" in
'start')
graylog_sidecar_start
;;
'stop')
graylog_sidecar_stop
;;
'restart')
graylog_sidecar_restart
;;
*)
echo "usage: $0 start|stop|restart"
esac