Create logstash.wrapper

Fixed the problem with the plugins as this no longer works.

Original file taken from:
https://github.com/piojo/logstash-rpm/blob/lsb/SOURCES/logstash.wrapper
This commit is contained in:
Sjir Bagmeijer 2013-09-30 18:01:13 +02:00
parent bf6076ab54
commit 9f6257ed53

View file

@ -0,0 +1,105 @@
#!/bin/sh
SCRIPT=$0
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA=$JAVA_HOME/bin/java
else
JAVA=`which java`
fi
LOGSTASH_JAR="@@@JARPATH@@@/@@@NAME@@@.jar"
if [ ! -f $LOGSTASH_JAR ]
then
echo "jar file is not found."
exit 99
fi
function usage() {
echo "Usage: ${SCRIPT} SERVICE OPTIONS"
echo " SERVICE: agent, web"
echo " OPTIONS:"
echo -e " -f, --config CONFIGFILE (required)\tLoad the logstash config from a specific file or directory."
echo -e " \t\tIf a direcory is given instead of a file, all files in that directory will be concatonated in lexicographical order and then parsed as a single config file."
echo -e " -P, --pidfile PIDFILE\t\tPID file path."
echo -e " -l, --logfile LOGFILE\t\tLogfile path."
echo -e " -v, --verbose [info, debug]\t\tEnables more verbose logging"
}
function run_service() {
service=$1
config=$2
pidfile=$3
logfile=$4
verbose=$5
if [ "x$logfile" == "x" ]; then
exec "$JAVA" $JAVA_OPTS -jar $LOGSTASH_JAR $service $verbose -f "$config" &
rs=$?
else
exec "$JAVA" $JAVA_OPTS -jar $LOGSTASH_JAR $service $verbose -f "$config" -l "$logfile" 2>&1 >> $logfile &
rs=$?
[ $rs -eq 0 -a "x$pidfile" != "x" ] && printf '%d' $! > "$pidfile"
fi
return $rs
}
service=$1; shift
if [ "${service}" != "agent" -a "${service}" != "web" ]
then
echo "ERROR: no such service \`${service}'. Available services are: agent, web"
usage
exit 99
fi
while test $# -gt 0
do
case "$1" in
-V | --version )
"$JAVA" -jar $LOGSTASH_JAR --version
exit 0
;;
-f | --config )
config="$2"
if [ ! -f "$config" -a ! -d "$config" ]; then
echo "ERROR: config file or directory \`$config' does not exist."
usage
exit 1
fi
shift 2
;;
-P | --pidfile )
pidfile="$2"
shift 2
;;
-l | --logfile )
logfile="$2"
shift 2
;;
-v | --verbose )
if [ "$2" == "debug" ]; then
verbose="-vv"
elif [ "$2" == "info" ]; then
verbose="-v"
fi
shift 2
;;
-h | --help )
usage
exit 0
;;
* )
break
esac
done
if [ "x$config" == "x" ]; then
echo "ERROR: config file is required."
usage
exit 1
fi
run_service "$service" "$config" "$pidfile" "$logfile" "$verbose"
exit $?