bin/elasticsearch: add help, fix endless loop
This change adds command line help for all options to the es start script. Both '-h' and '--help' options are accepted. Also, an endless busy loop in the long options parser was fixed: running the script with a long opt parameter w/o value (e.g. "elasticsearch --buuuurrrnn") the long option parser would end up in an endless busy loop. Signed-off-by: Thilo Fromm <github@thilo-fromm.de>
This commit is contained in:
parent
942e752ac1
commit
e92ff00192
|
@ -1,8 +1,15 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# OPTIONS:
|
# OPTIONS:
|
||||||
# -d: daemonize, start in the background
|
# -d daemonize (run in background)
|
||||||
# -p <filename>: log the pid to a file (useful to kill it later)
|
# -p pidfile write PID to <pidfile>
|
||||||
|
# -h
|
||||||
|
# --help print command line options
|
||||||
|
# -v print elasticsearch version, then exit
|
||||||
|
# -D prop set JAVA system property
|
||||||
|
# -X prop set non-standard JAVA system property
|
||||||
|
# --prop=val
|
||||||
|
# --prop val set elasticsearch property (i.e. -Des.<prop>=<val>)
|
||||||
|
|
||||||
# CONTROLLING STARTUP:
|
# CONTROLLING STARTUP:
|
||||||
#
|
#
|
||||||
|
@ -156,16 +163,37 @@ launch_service()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Print command line usage / help
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [-vdh] [-p pidfile] [-D prop] [-X prop]"
|
||||||
|
echo "Start elasticsearch."
|
||||||
|
echo " -d daemonize (run in background)"
|
||||||
|
echo " -p pidfile write PID to <pidfile>"
|
||||||
|
echo " -h"
|
||||||
|
echo " --help print command line options"
|
||||||
|
echo " -v print elasticsearch version, then exit"
|
||||||
|
echo " -D prop set JAVA system property"
|
||||||
|
echo " -X prop set non-standard JAVA system property"
|
||||||
|
echo " --prop=val"
|
||||||
|
echo " --prop val set elasticsearch property (i.e. -Des.<prop>=<val>)"
|
||||||
|
}
|
||||||
|
|
||||||
# Parse any long getopt options and put them into properties before calling getopt below
|
# Parse any long getopt options and put them into properties before calling getopt below
|
||||||
# Be dash compatible to make sure running under ubuntu works
|
# Be dash compatible to make sure running under ubuntu works
|
||||||
ARGV=""
|
ARGV=""
|
||||||
while [ $# -gt 0 ]
|
while [ $# -gt 0 ]
|
||||||
do
|
do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
--help) ARGV="$ARGV -h"; shift;;
|
||||||
--*=*) properties="$properties -Des.${1#--}"
|
--*=*) properties="$properties -Des.${1#--}"
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
--*) properties="$properties -Des.${1#--}=$2"
|
--*) [ $# -le 1 ] && {
|
||||||
|
echo "Option requires an argument: '$1'."
|
||||||
|
shift
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
properties="$properties -Des.${1#--}=$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
*) ARGV="$ARGV $1" ; shift
|
*) ARGV="$ARGV $1" ; shift
|
||||||
|
@ -192,7 +220,7 @@ while true; do
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-h)
|
-h)
|
||||||
echo "Usage: $0 [-d] [-h] [-p pidfile]"
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-D)
|
-D)
|
||||||
|
@ -209,6 +237,7 @@ while true; do
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Error parsing argument $1!" >&2
|
echo "Error parsing argument $1!" >&2
|
||||||
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue