Browse Source

utils/searx.sh & filtron.sh: misc changes from first tests (WIP)

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Markus Heiser 5 years ago
parent
commit
6274a54746
4 changed files with 30 additions and 3 deletions
  1. 9 1
      utils/filtron.sh
  2. 5 1
      utils/lib.sh
  3. 3 0
      utils/searx.sh
  4. 13 1
      utils/templates/etc/apache2/sites-available/searx.conf:filtron

+ 9 - 1
utils/filtron.sh

@@ -11,6 +11,10 @@ source_dot_config
 # config
 # ----------------------------------------------------------------------------
 
+FILTRON_URL_PATH="${FILTRON_URL_PATH:-$(echo "${PUBLIC_URL}" \
+| sed -e 's,^.*://[^/]*\(/.*\),\1,g')}"
+[[ "${FILTRON_URL_PATH}" == "${PUBLIC_URL}" ]] && FILTRON_URL_PATH=/
+
 FILTRON_ETC="/etc/filtron"
 
 FILTRON_RULES="$FILTRON_ETC/rules.json"
@@ -192,7 +196,9 @@ installations that were installed with this script."
     wait_key
     remove_user
     rm -r "$FILTRON_ETC" 2>&1 | prefix_stdout
-    wait_key
+    if service_is_available "${PUBLIC_URL}"; then
+        MSG="** Don't forget to remove your public site! (${PUBLIC_URL}) **" wait_key 10
+    fi
 }
 
 install_service() {
@@ -329,6 +335,7 @@ inspect_service() {
 sourced ${DOT_CONFIG#"$REPO_ROOT/"} :
 
   PUBLIC_URL          : ${PUBLIC_URL}
+  FILTRON_URL_PATH    : ${FILTRON_URL_PATH}
   FILTRON_API         : ${FILTRON_API}
   FILTRON_LISTEN      : ${FILTRON_LISTEN}
   FILTRON_TARGET      : ${FILTRON_TARGET}
@@ -395,6 +402,7 @@ This installs a reverse proxy (ProxyPass) into apache site (${APACHE_FILTRON_SIT
         return
     fi
 
+    a2enmod headers
     a2enmod proxy
     a2enmod proxy_http
 

+ 5 - 1
utils/lib.sh

@@ -121,10 +121,11 @@ wait_key(){
 
     clean_stdin
     local _t=$1
+    local msg="${MSG:-** press any [KEY] to continue **}"
     [[ ! -z $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
     [[ ! -z $_t ]] && _t="-t $_t"
     # shellcheck disable=SC2086
-    read -r -s -n1 $_t -p "** press any [KEY] to continue **"
+    read -r -s -n1 $_t -p "$msg"
     echo
     clean_stdin
 }
@@ -436,6 +437,9 @@ service_is_available() {
     if [[ $exit_val = 0 ]]; then
         info_msg "got $http_code from ${URL}"
     fi
+    case "$http_code" in
+        404|410|423) exit_val=$http_code;;
+    esac
     return $exit_val
 }
 

+ 3 - 0
utils/searx.sh

@@ -275,6 +275,9 @@ installations that were installed with this script."
     remove_searx_uwsgi
     wait_key
     remove_user
+    if service_is_available "${PUBLIC_URL}"; then
+        MSG="** Don't forgett to remove your public site! (${PUBLIC_URL}) **" wait_key 10
+    fi
 }
 
 user_is_available() {

+ 13 - 1
utils/templates/etc/apache2/sites-available/searx.conf:filtron

@@ -1,3 +1,15 @@
 # -*- coding: utf-8; mode: apache -*-
 
-ProxyPass "/searx" "http://127.0.0.1:4004/"
+<Location ${FILTRON_URL_PATH} >
+
+    Require all granted
+    Allow from all
+
+    Order deny,allow
+    Deny from all
+    #Allow from fd00::/8 192.168.0.0/16 fe80::/10 127.0.0.0/8 ::1
+
+    ProxyPass "http://127.0.0.1:4004"
+    RequestHeader set "X-Script-Name" "${FILTRON_URL_PATH}"
+
+</Location>