Commit 02e1d669 authored by Andy Wilkinson's avatar Andy Wilkinson

Exit with a value of 1 when cd fails in the init script

Exiting with 0 when cd fails is likely to be incorrectly interpreted
as success so we should exit with a non-zero value. Ideally, the init
script status action would exit with 4 but, at the point when
the cd is performed, we don’t even know if we’re running as an init
script. Exiting with 1 seems to be a reasonable compromise as it’s
fine for the non init-script case as well as being correct for all
init script actions other than status.

See gh-4653
parent 81a47639
...@@ -29,16 +29,16 @@ WORKING_DIR="$(pwd)" ...@@ -29,16 +29,16 @@ WORKING_DIR="$(pwd)"
[[ -n "$APP_NAME" ]] && identity="$APP_NAME" [[ -n "$APP_NAME" ]] && identity="$APP_NAME"
# Follow symlinks to find the real jar and detect init.d script # Follow symlinks to find the real jar and detect init.d script
cd "$(dirname "$0")" || exit cd "$(dirname "$0")" || exit 1
[[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0") [[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0")
while [[ -L "$jarfile" ]]; do while [[ -L "$jarfile" ]]; do
[[ "$jarfile" =~ init\.d ]] && init_script=$(basename "$jarfile") [[ "$jarfile" =~ init\.d ]] && init_script=$(basename "$jarfile")
jarfile=$(readlink "$jarfile") jarfile=$(readlink "$jarfile")
cd "$(dirname "$jarfile")" || exit cd "$(dirname "$jarfile")" || exit 1
jarfile=$(pwd)/$(basename "$jarfile") jarfile=$(pwd)/$(basename "$jarfile")
done done
jarfolder="$(dirname "$jarfile")" jarfolder="$(dirname "$jarfile")"
cd "$WORKING_DIR" || exit cd "$WORKING_DIR" || exit 1
# Source any config file # Source any config file
configfile="$(basename "${jarfile%.*}.conf")" configfile="$(basename "${jarfile%.*}.conf")"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment