diff --git a/bin/apicall.sh b/bin/apicall.sh
index b1864a7f8..a8e797560 100755
--- a/bin/apicall.sh
+++ b/bin/apicall.sh
@@ -1,5 +1,8 @@
#!/usr/bin/env sh
# Call an HTTP API on the local YaCy peer, authenticated as administrator
+# $1 : API path
+#
+# $YACY_DATA_PATH : path to the YaCy DATA folder to use. When not set, the relative ../DATA path is used as a default.
#
# Authentication options :
# - enable unauthenticated local access as administrator : set adminAccountForLocalhost=true in the DATA/SETTINGS/yacy.conf file
@@ -11,13 +14,15 @@
#
cd "`dirname $0`"
-port=$(grep ^port= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
-admin=$(grep ^adminAccountUserName= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
-adminAccountForLocalhost=$(grep ^adminAccountForLocalhost= ../DATA/SETTINGS/yacy.conf | cut -d= -f2)
+. ./checkDataFolder.sh
-if grep "BASIC" ../defaults/web.xml > /dev/null; then
+port=$(grep ^port= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
+admin=$(grep ^adminAccountUserName= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
+adminAccountForLocalhost=$(grep ^adminAccountForLocalhost= "$YACY_DATA_PATH/SETTINGS/yacy.conf" | cut -d= -f2)
+
+if grep "BASIC" "$YACY_APP_PATH/defaults/web.xml" > /dev/null; then
# When authentication method is in basic mode, use directly the password hash from the configuration file
- YACY_ADMIN_PASSWORD=$(grep ^adminAccountBase64MD5= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
+ YACY_ADMIN_PASSWORD=$(grep ^adminAccountBase64MD5= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
fi
if which curl > /dev/null; then
diff --git a/bin/apicat.sh b/bin/apicat.sh
index b0b3fcda9..31659e320 100755
--- a/bin/apicat.sh
+++ b/bin/apicat.sh
@@ -2,6 +2,10 @@
# Call an HTTP API on the local YaCy peer, authenticated as administrator, then print the result on the standard output
# Almost the same as apicall.sh, except that wget doesn't print information messages to the standard output, only the result
#
+# $1 : API path
+#
+# $YACY_DATA_PATH : path to the YaCy DATA folder to use. When not set, the relative ../DATA path is used as a default.
+#
# Authentication options :
# - enable unauthenticated local access as administrator : set adminAccountForLocalhost=true in the DATA/SETTINGS/yacy.conf file
# - OR use the legacy Basic HTTP authentication mode (unsecured for remote access): set the "auth-method" to BASIC in the defaults/web.xml file
@@ -12,13 +16,15 @@
#
cd "`dirname $0`"
-port=$(grep ^port= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
-admin=$(grep ^adminAccountUserName= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
-adminAccountForLocalhost=$(grep ^adminAccountForLocalhost= ../DATA/SETTINGS/yacy.conf | cut -d= -f2)
+. ./checkDataFolder.sh
-if grep "BASIC" ../defaults/web.xml > /dev/null; then
+port=$(grep ^port= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
+admin=$(grep ^adminAccountUserName= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
+adminAccountForLocalhost=$(grep ^adminAccountForLocalhost= "$YACY_DATA_PATH/SETTINGS/yacy.conf" | cut -d= -f2)
+
+if grep "BASIC" "$YACY_APP_PATH/defaults/web.xml" > /dev/null; then
# When authentication method is in basic mode, use directly the password hash from the configuration file
- YACY_ADMIN_PASSWORD=$(grep ^adminAccountBase64MD5= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
+ YACY_ADMIN_PASSWORD=$(grep ^adminAccountBase64MD5= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
fi
if which curl > /dev/null; then
diff --git a/bin/checkDataFolder.sh b/bin/checkDataFolder.sh
new file mode 100755
index 000000000..7dd45079a
--- /dev/null
+++ b/bin/checkDataFolder.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env sh
+# Fill the YACY_BIN_PATH, YACY_APP_PATH and the YACY_DATA_PATH (when empty) relatively to the current working directory
+# Then check that the provided YaCy DATA folder exists
+# Exits with an error message and status 2 when the DATA folder is not found
+
+YACY_BIN_PATH="`pwd`"
+YACY_APP_PATH="`dirname $YACY_BIN_PATH`"
+
+if [ -z "$YACY_DATA_PATH" ]; then
+ YACY_DATA_PATH="$YACY_APP_PATH/DATA"
+fi
+
+if [ ! -d "$YACY_DATA_PATH" ]; then
+ echo "Invalid YaCy DATA folder path : $YACY_DATA_PATH"
+ echo "Please fill the YACY_DATA_PATH environment variable with a valid YaCy DATA folder path."
+ exit 2
+fi
\ No newline at end of file
diff --git a/bin/checkalive.sh b/bin/checkalive.sh
index 5650b16a0..d1f88fd53 100755
--- a/bin/checkalive.sh
+++ b/bin/checkalive.sh
@@ -1,11 +1,12 @@
#!/usr/bin/env sh
-cd "`dirname $0`"
-
# for a production environment with high-availability requirement,
# (and if you are using the debian version of yacy)
# add the following line in /etc/crontab
# 0 * * * * root cd /usr/share/yacy/bin && ./checkalive.sh
+cd "`dirname $0`"
+. ./checkDataFolder.sh
+
FLAG=0
if [ `./apicall.sh /Status.html | grep "