Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Added support for custom DATA path in shell scripts

luccioman17ad1f7e6547
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
+
+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 "<auth-method>BASIC</auth-method>" ../defaults/web.xml > /dev/null; then
+if grep "<auth-method>BASIC</auth-method>" "$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
+
+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 "<auth-method>BASIC</auth-method>" ../defaults/web.xml > /dev/null; then
+if grep "<auth-method>BASIC</auth-method>" "$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 "</html>"` ]; then
FLAG=1
@@ -15,7 +16,7 @@ if [ $FLAG -eq '0' ]; then
cd ..
timeout 30s ./stopYACY.sh
./killYACY.sh
- rm DATA/yacy.running
+ rm "$YACY_DATA_PATH/yacy.running"
./startYACY.sh
fi
exit
\ No newline at end of file
diff --git a/bin/checkindex.sh b/bin/checkindex.sh
index c93625080..083be6418 100755
--- a/bin/checkindex.sh
+++ b/bin/checkindex.sh
@@ -1,8 +1,12 @@
#!/usr/bin/env sh
-cd "`dirname $0`/.."
-for i in DATA/INDEX/* ; do
+cd "`dirname $0`"
+. ./checkDataFolder.sh
+
+
+for i in "$YACY_DATA_PATH/INDEX"/* ; do
if [ -d "$i" ]; then
- java -cp 'lib/*' org.apache.lucene.index.CheckIndex $i/SEGMENTS/solr_46/collection1/data/index/ -fix
+ echo "Checking Solr index at $i..."
+ java -cp "$YACY_APP_PATH/lib/*" org.apache.lucene.index.CheckIndex "$i/SEGMENTS/solr_6_6/collection1/data/index/" -exorcise
fi
done
cd ..
diff --git a/bin/down.sh b/bin/down.sh
index 8a83f40fc..994981cf1 100755
--- a/bin/down.sh
+++ b/bin/down.sh
@@ -1,6 +1,8 @@
#!/usr/bin/env sh
cd "`dirname $0`"
-port=$(grep ^port= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
+. ./checkDataFolder.sh
+
+port=$(grep ^port= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
if which curl > /dev/null; then
curl -s "http://localhost:$port/Network.xml?page=2&ip=" | awk '/<address>/{ gsub("<address>","" );gsub("<\/address>","" ); print $0 }' | awk '{print $1}'
diff --git a/bin/graphicstest.sh b/bin/graphicstest.sh
index 384d2d489..7467df984 100755
--- a/bin/graphicstest.sh
+++ b/bin/graphicstest.sh
@@ -1,4 +1,8 @@
-port=$(grep ^port= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
+#!/usr/bin/env sh
+cd "`dirname $0`"
+. ./checkDataFolder.sh
+
+port=$(grep ^port= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
while [ 1 = 1 ]
do
curl "http://localhost:$port/NetworkPicture.png?width=768&height=576&bgcolor=FFFFFF" > /dev/null
diff --git a/bin/protectedPostApiCall.sh b/bin/protectedPostApiCall.sh
index 652abdf35..a230754ab 100755
--- a/bin/protectedPostApiCall.sh
+++ b/bin/protectedPostApiCall.sh
@@ -3,6 +3,8 @@
# $1 : API path
# $2 : POST parameters (example : "param1=value1&param2=value2")
#
+# $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
@@ -13,13 +15,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
+
+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 "<auth-method>BASIC</auth-method>" ../defaults/web.xml > /dev/null; then
+if grep "<auth-method>BASIC</auth-method>" "$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/search.sh b/bin/search.sh
index 9a8bc645e..bec3e78e7 100755
--- a/bin/search.sh
+++ b/bin/search.sh
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
cd "`dirname $0`"
-port=$(grep ^port= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
+. ./checkDataFolder.sh
+
+port=$(grep ^port= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
./search1.sh -y localhost:$port "$1"
\ No newline at end of file
diff --git a/bin/searchall.sh b/bin/searchall.sh
index 86e9aa521..540b0703d 100755
--- a/bin/searchall.sh
+++ b/bin/searchall.sh
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
cd "`dirname $0`"
-port=$(grep ^port= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
+. ./checkDataFolder.sh
+
+port=$(grep ^port= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
./searchall1.sh -s localhost:$port $1
\ No newline at end of file
diff --git a/bin/up.sh b/bin/up.sh
index c0bbf41de..86b6b4b70 100755
--- a/bin/up.sh
+++ b/bin/up.sh
@@ -2,6 +2,6 @@
cd "`dirname $0`"
./apicall.sh "/Network.xml?page=1&ip=" | awk '/<address>/{ gsub("<address>","" );gsub("<\/address>","" ); print $0 }' | awk '{print $1}';
-#port=$(grep ^port= ../DATA/SETTINGS/yacy.conf |cut -d= -f2)
+#port=$(grep ^port= "$YACY_DATA_PATH/SETTINGS/yacy.conf" |cut -d= -f2)
#./up1.sh localhost:$port