mirror of
https://github.com/elastic/logstash.git
synced 2025-04-19 20:27:23 -04:00
Create new artifacts with bundled JDK for the supported platforms on x86_64. Download JDK packages from AdoptOpenJDK site, the selected version is loaded from `versions.yml`. Changed also the launch scripts to give precedence to JAVA_HOME, then fallback on bundled JDK if present, as last resource go to the system Java. New artifacts produced with bundled JDK are: - tar.gz with JDK for Linux and Darwin - zip file for Windows - dep and rpm - Docker image All artifacts without JDK are now postfixed with '-no-jdk' while the ones with JDK included has the architecture extension. Covered with tests the touched parts Co-authored-by: Rob Bavey <robbavey@users.noreply.github.com>
99 lines
3.5 KiB
Bash
Executable file
99 lines
3.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
unset CDPATH
|
|
. "$(cd `dirname $0`/..; pwd)/bin/logstash.lib.sh"
|
|
setup
|
|
|
|
if [ -z "$1" ]; then
|
|
if [ -r /etc/logstash/startup.options ]; then
|
|
OPTIONS_PATH=/etc/logstash/startup.options
|
|
elif [ -r "${LOGSTASH_HOME}"/config/startup.options ]; then
|
|
OPTIONS_PATH="${LOGSTASH_HOME}"/config/startup.options
|
|
fi
|
|
elif [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
|
echo "Usage: system-install [OPTIONSFILE] [STARTUPTYPE] [VERSION]"
|
|
echo
|
|
echo "NOTE: These arguments are ordered, and co-dependent"
|
|
echo
|
|
echo "OPTIONSFILE: Full path to a startup.options file"
|
|
echo "OPTIONSFILE is required if STARTUPTYPE is specified, but otherwise looks first"
|
|
echo "in /etc/logstash/startup.options and then "
|
|
echo "in $LOGSTASH_HOME/config/startup.options "
|
|
echo
|
|
echo "STARTUPTYPE: e.g. sysv, upstart, systemd, etc."
|
|
echo "OPTIONSFILE is required to specify a STARTUPTYPE."
|
|
echo
|
|
echo "VERSION: The specified version of STARTUPTYPE to use. The default is usually"
|
|
echo "preferred here, so it can safely be omitted."
|
|
echo "Both OPTIONSFILE & STARTUPTYPE are required to specify a VERSION."
|
|
echo
|
|
echo "For more information, see https://github.com/jordansissel/pleaserun"
|
|
exit 0
|
|
else
|
|
if [ -r "$1" ]; then
|
|
echo "Using provided startup.options file: ${1}"
|
|
OPTIONS_PATH="$1"
|
|
else
|
|
echo "$1 is not a file path"
|
|
echo "To manually specify a startup style, put the path to startup.options as the "
|
|
echo "first argument, followed by the startup style (sysv, upstart, systemd)"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Read in the env vars in the selected startup.options file...
|
|
. "${OPTIONS_PATH}"
|
|
|
|
old_IFS=$IFS
|
|
IFS=$'\n'
|
|
lines=($(grep -v ^# ${OPTIONS_PATH} | tr -d '"' | grep -v '^LS_OPTS=' | grep \= | grep -v '\=$' | grep -v '\=\"\"$'))
|
|
IFS=$old_IFS
|
|
|
|
ENV_VAR_ARGS=()
|
|
|
|
for line in ${lines[@]}; do
|
|
var=$(echo $line | awk -F\= '{print $1}')
|
|
if [ "x${!var}" != "x" ]; then
|
|
ENV_VAR_ARGS+=('--environment-variables')
|
|
ENV_VAR_ARGS+=("${var}=${!var}")
|
|
fi
|
|
done
|
|
|
|
# bin/logstash-plugin is a short lived ruby script thus we can use aggressive "faster starting JRuby options"
|
|
# see https://github.com/jruby/jruby/wiki/Improving-startup-time
|
|
export JRUBY_OPTS="$JRUBY_OPTS $OPEN_JAVA_MODULES -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -X-C -Xcompile.invokedynamic=false"
|
|
|
|
tempfile=$(mktemp)
|
|
if [ "x${PRESTART}" == "x" ]; then
|
|
opts=("--log" "$tempfile" "--overwrite" "--install" "--name" "${SERVICE_NAME}" "--user" "${LS_USER}" "--group" "${LS_GROUP}" "--description" "${SERVICE_DESCRIPTION}" "--nice" "${LS_NICE}" "--limit-open-files" "${LS_OPEN_FILES}")
|
|
else
|
|
opts=("--log" "$tempfile" "--overwrite" "--install" "--name" "${SERVICE_NAME}" "--user" "${LS_USER}" "--group" "${LS_GROUP}" "--description" "${SERVICE_DESCRIPTION}" "--nice" "${LS_NICE}" "--limit-open-files" "${LS_OPEN_FILES}" "--prestart" "${PRESTART}")
|
|
fi
|
|
|
|
if [[ $2 ]]; then
|
|
echo "Manually creating startup for specified platform: ${2}"
|
|
opts+=('--platform')
|
|
opts+=($2)
|
|
fi
|
|
|
|
if [[ $3 ]]; then
|
|
echo "Manually creating startup for specified platform (${2}) version: ${3}"
|
|
opts+=('--version')
|
|
opts+=($3)
|
|
fi
|
|
|
|
allopts=("${ENV_VAR_ARGS[@]}" "${opts[@]}")
|
|
program="$(cd `dirname $0`/..; pwd)/bin/logstash"
|
|
|
|
$(ruby_exec "${LOGSTASH_HOME}/lib/systeminstall/pleasewrap.rb" "${allopts[@]}" ${program} ${LS_OPTS})
|
|
exit_code=$?
|
|
|
|
if [ $exit_code -ne 0 ]; then
|
|
cat $tempfile
|
|
echo "Unable to install system startup script for Logstash."
|
|
else
|
|
echo "Successfully created system startup script for Logstash"
|
|
fi
|
|
rm $tempfile
|
|
|
|
exit $exit_code
|