Skip to content
Snippets Groups Projects
Commit 76eebfe2 authored by Vít Novotný's avatar Vít Novotný Committed by Demian Katz
Browse files

Always set $VUFIND_HOME to an absolute path. (#1224)

- This makes all scripts more robust and fixes a specific problem with index-alphabetic-browse.sh where it would not resolve VUFIND_HOME correctly when invoked from within the VuFind directory with no environment variable set.
parent b86dad2e
No related merge requests found
......@@ -3,8 +3,13 @@
# Make sure VUFIND_HOME is set:
if [ -z "$VUFIND_HOME" ]
then
echo "Please set the VUFIND_HOME environment variable."
exit 1
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)"/..
if [ "$VUFIND_HOME" = /.. ]
then
exit 1
fi
fi
SKIP_OPTIMIZE=0
......
......@@ -3,8 +3,13 @@
# Make sure VUFIND_HOME is set:
if [ -z "$VUFIND_HOME" ]
then
echo "Please set the VUFIND_HOME environment variable."
exit 1
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
export VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)"/..
if [ "$VUFIND_HOME" = /.. ]
then
exit 1
fi
fi
# Find harvest directory for future use
......
......@@ -3,8 +3,13 @@
# Make sure VUFIND_HOME is set:
if [ -z "$VUFIND_HOME" ]
then
echo "Please set the VUFIND_HOME environment variable."
exit 1
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
export VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)"/..
if [ "$VUFIND_HOME" = /.. ]
then
exit 1
fi
fi
# Find harvest directory for future use
......
......@@ -3,10 +3,16 @@
# Make sure VUFIND_HOME is set:
if [ -z "$VUFIND_HOME" ]
then
echo "Please set the VUFIND_HOME environment variable."
exit 1
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)"/..
if [ "$VUFIND_HOME" = /.. ]
then
exit 1
fi
fi
SKIP_OPTIMIZE=0
while getopts ":s" OPT
......
......@@ -12,6 +12,21 @@ then
exit $E_BADARGS
fi
##################################################
# Set VUFIND_HOME
##################################################
if [ -z "$VUFIND_HOME" ]
then
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
export VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)"
if [ -z "$VUFIND_HOME" ]
then
exit 1
fi
fi
# Always use the standard authority mappings; if the user specified an override
# file, add that to the setting.
if [ -f "$VUFIND_LOCAL_DIR/import/marc_auth.properties" ]
......
......@@ -67,7 +67,11 @@ if [ -z "$VUFIND_HOME" ]
then
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
export VUFIND_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
export VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)"
if [ -z "$VUFIND_HOME" ]
then
exit 1
fi
fi
if [ -z "$VUFIND_LOCAL_DIR" ]
......
......@@ -43,20 +43,29 @@ fi
##################################################
# Set SOLR_HOME
# Set VUFIND_HOME
##################################################
if [ -z "$SOLR_HOME" ]
if [ -z "$VUFIND_HOME" ]
then
if [ -z "$VUFIND_HOME" ]
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)"/../..
if [ "$VUFIND_HOME" = /../.. ]
then
echo "You need to set the VUFIND_HOME environmental variable before running this script."
exit 1
else
SOLR_HOME="$VUFIND_HOME/solr"
fi
fi
##################################################
# Set SOLR_HOME
##################################################
if [ -z "$SOLR_HOME" ]
then
SOLR_HOME="$VUFIND_HOME/solr"
fi
##################################################
# Set SOLRMARC_HOME
##################################################
......
......@@ -10,11 +10,22 @@ else
JAVA="java"
fi
##################################################
# Set VUFIND_HOME
##################################################
if [ -z "$VUFIND_HOME" ]
then
VUFIND_HOME=`dirname $0`
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)"
if [ -z "$VUFIND_HOME" ]
then
exit 1
fi
fi
if [ -z "$SOLR_HOME" ]
then
SOLR_HOME="$VUFIND_HOME/solr/vufind"
......
......@@ -42,9 +42,16 @@ usage()
# Set VUFIND_HOME
if [ -z "$VUFIND_HOME" ]
then
VUFIND_HOME=$(dirname "$0")
# set VUFIND_HOME to the absolute path of the directory containing this script
# https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
VUFIND_HOME="$(cd "$(dirname "$0")" && pwd -P)"
if [ -z "$VUFIND_HOME" ]
then
exit 1
fi
fi
if [ -z "$SOLR_HOME" ]
then
SOLR_HOME="$VUFIND_HOME/solr/vufind"
......
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