Fix 'gerrit.sh restart' for relative paths

Trying to restart gerrit using

  gerrit/site/bin/gerrit.sh restart

failed with

  ** ERROR: Cannot locate gerrit.sh

as gerrit.sh internally changed the current directory to the gerrit
site, while still trying to invoke itself using $0. We add a fallback
to also look for $0 in the initial directory.

Change-Id: I8ba9306cf875aa4ec8e5bb8c693360dafdcd16b9
This commit is contained in:
Christian Aistleitner
2013-03-19 08:41:08 +01:00
parent 47c4e459d3
commit 885799aecd

View File

@@ -175,6 +175,7 @@ if test -z "$GERRIT_SITE" ; then
exit 1
fi
INITIAL_DIR=`pwd`
if cd "$GERRIT_SITE" ; then
GERRIT_SITE=`pwd`
else
@@ -481,8 +482,13 @@ case "$ACTION" in
if test -f "$GERRIT_SH" ; then
: OK
else
echo >&2 "** ERROR: Cannot locate gerrit.sh"
exit 1
GERRIT_SH="$INITIAL_DIR/$GERRIT_SH"
if test -f "$GERRIT_SH" ; then
: OK
else
echo >&2 "** ERROR: Cannot locate gerrit.sh"
exit 1
fi
fi
$GERRIT_SH stop $*
sleep 5