From 81bba4486916dbca4467a7e8c8b839a7c55c2a09 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 27 May 2022 18:41:08 +0200 Subject: [install scripts] rename SEARX_ variables to SEARXNG_ Signed-off-by: Markus Heiser --- utils/lib_install.sh | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'utils/lib_install.sh') diff --git a/utils/lib_install.sh b/utils/lib_install.sh index 5d84c066f..04bec5d9a 100755 --- a/utils/lib_install.sh +++ b/utils/lib_install.sh @@ -8,7 +8,7 @@ # Initialize installation procedures: # # - Modified source_dot_config function that -# - loads .config.sh from an existing installation (at SEARX_SRC). +# - loads .config.sh from an existing installation (at SEARXNG_SRC). # - initialize **SEARX_SRC_INIT_FILES** # - functions like: # - install_log_searx_instance() @@ -25,13 +25,13 @@ # - utils/morty.sh # - utils/filtron.sh # -# If '${SEARX_SRC}/.config.sh' exists, the modified source_dot_config() function +# If '${SEARXNG_SRC}/.config.sh' exists, the modified source_dot_config() function # loads this configuration (instead of './.config.sh'). # **SEARX_SRC_INIT_FILES** # -# Array of file names to sync into a installation at $SEARX_SRC. The file names -# are relative to the $REPO_ROOT. Set by function init_SEARX_SRC_INIT_FILES(). +# Array of file names to sync into a installation at $SEARXNG_SRC. The file names +# are relative to the $REPO_ROOT. Set by function init_SEARXNG_SRC_INIT_FILES(). # Most often theses are files like: # - .config.sh # - searx/settings.yml @@ -46,25 +46,25 @@ eval orig_"$(declare -f source_dot_config)" source_dot_config() { # Modified source_dot_config function that - # - loads .config.sh from an existing installation (at SEARX_SRC). + # - loads .config.sh from an existing installation (at SEARXNG_SRC). # - initialize SEARX_SRC_INIT_FILES - if [ -z "$eval_SEARX_SRC" ]; then - export eval_SEARX_SRC='true' - SEARX_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_SRC) - SEARX_PYENV=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARX_PYENV) + if [ -z "$eval_SEARXNG_SRC" ]; then + export eval_SEARXNG_SRC='true' + SEARXNG_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_SRC) + SEARXNG_PYENV=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_PYENV) SEARXNG_SETTINGS_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_SETTINGS_PATH) - if [ ! -r "${SEARX_SRC}" ]; then - info_msg "not yet cloned: ${SEARX_SRC}" + if [ ! -r "${SEARXNG_SRC}" ]; then + info_msg "not yet cloned: ${SEARXNG_SRC}" orig_source_dot_config return 0 fi - info_msg "using instance at: ${SEARX_SRC}" + info_msg "using instance at: ${SEARXNG_SRC}" # set and log DOT_CONFIG - if [ -r "${SEARX_SRC}/.config.sh" ]; then - info_msg "switching to ${SEARX_SRC}/.config.sh" - DOT_CONFIG="${SEARX_SRC}/.config.sh" + if [ -r "${SEARXNG_SRC}/.config.sh" ]; then + info_msg "switching to ${SEARXNG_SRC}/.config.sh" + DOT_CONFIG="${SEARXNG_SRC}/.config.sh" else info_msg "using local config: ${DOT_CONFIG}" fi @@ -86,7 +86,7 @@ init_SEARX_SRC_INIT_FILES(){ # keep list empty if there is no installation SEARX_SRC_INIT_FILES=() - if [ ! -r "$SEARX_SRC" ]; then + if [ ! -r "$SEARXNG_SRC" ]; then return 0 fi @@ -104,9 +104,9 @@ init_SEARX_SRC_INIT_FILES(){ if [ -z "$fname" ]; then continue fi - if [ -r "${SEARX_SRC}/${fname}" ]; then - # diff "${REPO_ROOT}/${fname}" "${SEARX_SRC}/${fname}" - if ! cmp --silent "${REPO_ROOT}/${fname}" "${SEARX_SRC}/${fname}"; then + if [ -r "${SEARXNG_SRC}/${fname}" ]; then + # diff "${REPO_ROOT}/${fname}" "${SEARXNG_SRC}/${fname}" + if ! cmp --silent "${REPO_ROOT}/${fname}" "${SEARXNG_SRC}/${fname}"; then SEARX_SRC_INIT_FILES+=("${fname}") info_msg "local clone (workingtree), modified file: ./$fname" msg="to update use: sudo -H ./utils/searx.sh install init-src" @@ -120,8 +120,8 @@ install_log_searx_instance() { echo -e "---- SearXNG instance setup ${_BBlue}(status: $(install_searx_get_state))${_creset}" echo -e " SEARXNG_SETTINGS_PATH : ${_BBlue}${SEARXNG_SETTINGS_PATH}${_creset}" - echo -e " SEARX_PYENV : ${_BBlue}${SEARX_PYENV}${_creset}" - echo -e " SEARX_SRC : ${_BBlue}${SEARX_SRC:-none}${_creset}" + echo -e " SEARXNG_PYENV : ${_BBlue}${SEARXNG_PYENV}${_creset}" + echo -e " SEARXNG_SRC : ${_BBlue}${SEARXNG_SRC:-none}${_creset}" echo -e " SEARXNG_URL : ${_BBlue}${SEARXNG_URL:-none}${_creset}" if in_container; then @@ -148,26 +148,26 @@ install_searx_get_state(){ # Prompts a string indicating the status of the installation procedure # # missing-searx-clone: - # There is no clone at ${SEARX_SRC} + # There is no clone at ${SEARXNG_SRC} # missing-searx-pyenv: - # There is no pyenv in ${SEARX_PYENV} + # There is no pyenv in ${SEARXNG_PYENV} # installer-modified: # There are files modified locally in the installer (clone), # see ${SEARX_SRC_INIT_FILES} description. # python-installed: # Scripts can be executed in instance's environment # - user: ${SERVICE_USER} - # - pyenv: ${SEARX_PYENV} + # - pyenv: ${SEARXNG_PYENV} if [ -f /etc/searx/settings.yml ]; then err_msg "settings.yml in /etc/searx/ is deprecated, move file to folder /etc/searxng/" fi - if ! [ -r "${SEARX_SRC}" ]; then + if ! [ -r "${SEARXNG_SRC}" ]; then echo "missing-searx-clone" return fi - if ! [ -f "${SEARX_PYENV}/bin/activate" ]; then + if ! [ -f "${SEARXNG_PYENV}/bin/activate" ]; then echo "missing-searx-pyenv" return fi -- cgit v1.2.3 From 782f73540e2d383ea122716507ccd9582918ab51 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Fri, 27 May 2022 18:43:14 +0200 Subject: [utils/searxng.sh] implement new script to install SearXNG Signed-off-by: Markus Heiser --- utils/lib_install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'utils/lib_install.sh') diff --git a/utils/lib_install.sh b/utils/lib_install.sh index 04bec5d9a..44734e165 100755 --- a/utils/lib_install.sh +++ b/utils/lib_install.sh @@ -126,7 +126,7 @@ install_log_searx_instance() { if in_container; then # SearXNG is listening on 127.0.0.1 and not available from outside container - # in containers the service is listening on 0.0.0.0 (see lxc-searx.env) + # in containers the service is listening on 0.0.0.0 (see lxc-searxng.env) echo -e "---- container setup" echo -e " ${_BBlack}HINT:${_creset} SearXNG only listen on loopback device" \ "${_BBlack}inside${_creset} the container." @@ -198,10 +198,11 @@ if in_container; then # hint: Linux containers do not have DNS entries, lets use IPs SEARXNG_URL="http://$(primary_ip)" fi +# shellcheck disable=SC2034 PUBLIC_URL="${SEARXNG_URL}" source_dot_config -# shellcheck source=utils/lxc-searx.env -source "${REPO_ROOT}/utils/lxc-searx.env" +# shellcheck source=utils/lxc-searxng.env +source "${REPO_ROOT}/utils/lxc-searxng.env" in_container && lxc_set_suite_env -- cgit v1.2.3 From 692708aa771c1f4927a3037ecc5aa9c06f1a2494 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 16 Jun 2022 16:30:18 +0200 Subject: [clean up] drop obsolete searx, filtron and morty install scripts Since ./utils/searxng.sh is implemented, the old installation procedures from filtron, morty and searx can be removed. For users who want to upgrade, the procedures for removing old installations have still been retained. Signed-off-by: Markus Heiser --- utils/lib_install.sh | 208 --------------------------------------------------- 1 file changed, 208 deletions(-) delete mode 100755 utils/lib_install.sh (limited to 'utils/lib_install.sh') diff --git a/utils/lib_install.sh b/utils/lib_install.sh deleted file mode 100755 index 44734e165..000000000 --- a/utils/lib_install.sh +++ /dev/null @@ -1,208 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: AGPL-3.0-or-later - -# https://github.com/koalaman/shellcheck/issues/356#issuecomment-853515285 -# shellcheck source=utils/lib.sh -. /dev/null - -# Initialize installation procedures: -# -# - Modified source_dot_config function that -# - loads .config.sh from an existing installation (at SEARXNG_SRC). -# - initialize **SEARX_SRC_INIT_FILES** -# - functions like: -# - install_log_searx_instance() -# - install_searx_get_state() -# -# usage: -# source lib_install.sh -# -# **Installation scripts** -# -# The utils/lib_install.sh is sourced by the installations scripts: -# -# - utils/searx.sh -# - utils/morty.sh -# - utils/filtron.sh -# -# If '${SEARXNG_SRC}/.config.sh' exists, the modified source_dot_config() function -# loads this configuration (instead of './.config.sh'). - -# **SEARX_SRC_INIT_FILES** -# -# Array of file names to sync into a installation at $SEARXNG_SRC. The file names -# are relative to the $REPO_ROOT. Set by function init_SEARXNG_SRC_INIT_FILES(). -# Most often theses are files like: -# - .config.sh -# - searx/settings.yml -# - utils/brand.env -# - ... - - -SEARX_SRC_INIT_FILES=() - -eval orig_"$(declare -f source_dot_config)" - -source_dot_config() { - - # Modified source_dot_config function that - # - loads .config.sh from an existing installation (at SEARXNG_SRC). - # - initialize SEARX_SRC_INIT_FILES - - if [ -z "$eval_SEARXNG_SRC" ]; then - export eval_SEARXNG_SRC='true' - SEARXNG_SRC=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_SRC) - SEARXNG_PYENV=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_PYENV) - SEARXNG_SETTINGS_PATH=$("${REPO_ROOT}/utils/searx.sh" --getenv SEARXNG_SETTINGS_PATH) - if [ ! -r "${SEARXNG_SRC}" ]; then - info_msg "not yet cloned: ${SEARXNG_SRC}" - orig_source_dot_config - return 0 - fi - info_msg "using instance at: ${SEARXNG_SRC}" - - # set and log DOT_CONFIG - if [ -r "${SEARXNG_SRC}/.config.sh" ]; then - info_msg "switching to ${SEARXNG_SRC}/.config.sh" - DOT_CONFIG="${SEARXNG_SRC}/.config.sh" - else - info_msg "using local config: ${DOT_CONFIG}" - fi - init_SEARX_SRC_INIT_FILES - fi -} - -init_SEARX_SRC_INIT_FILES(){ - # init environment SEARX_SRC_INIT_FILES - - # Monitor modified files in the working-tree from the local repository, only - # if the local file differs to the corresponding file in the instance. Most - # often theses are files like: - # - # - .config.sh - # - searx/settings.yml - # - utils/brand.env - # - ... - - # keep list empty if there is no installation - SEARX_SRC_INIT_FILES=() - if [ ! -r "$SEARXNG_SRC" ]; then - return 0 - fi - - local fname - local msg="" - local _prefix="" - if [[ -n ${SUDO_USER} ]]; then - _prefix="sudo -u ${SUDO_USER}" - fi - - # Monitor local modified files from the repository, only if the local file - # differs to the corresponding file in the instance - - while IFS= read -r fname; do - if [ -z "$fname" ]; then - continue - fi - if [ -r "${SEARXNG_SRC}/${fname}" ]; then - # diff "${REPO_ROOT}/${fname}" "${SEARXNG_SRC}/${fname}" - if ! cmp --silent "${REPO_ROOT}/${fname}" "${SEARXNG_SRC}/${fname}"; then - SEARX_SRC_INIT_FILES+=("${fname}") - info_msg "local clone (workingtree), modified file: ./$fname" - msg="to update use: sudo -H ./utils/searx.sh install init-src" - fi - fi - done <<< "$($_prefix git diff --name-only)" - [ -n "$msg" ] && info_msg "$msg" -} - -install_log_searx_instance() { - - echo -e "---- SearXNG instance setup ${_BBlue}(status: $(install_searx_get_state))${_creset}" - echo -e " SEARXNG_SETTINGS_PATH : ${_BBlue}${SEARXNG_SETTINGS_PATH}${_creset}" - echo -e " SEARXNG_PYENV : ${_BBlue}${SEARXNG_PYENV}${_creset}" - echo -e " SEARXNG_SRC : ${_BBlue}${SEARXNG_SRC:-none}${_creset}" - echo -e " SEARXNG_URL : ${_BBlue}${SEARXNG_URL:-none}${_creset}" - - if in_container; then - # SearXNG is listening on 127.0.0.1 and not available from outside container - # in containers the service is listening on 0.0.0.0 (see lxc-searxng.env) - echo -e "---- container setup" - echo -e " ${_BBlack}HINT:${_creset} SearXNG only listen on loopback device" \ - "${_BBlack}inside${_creset} the container." - for ip in $(global_IPs) ; do - if [[ $ip =~ .*:.* ]]; then - echo " container (IPv6): [${ip#*|}]" - else - # IPv4: - echo " container (IPv4): ${ip#*|}" - fi - done - fi -} - -install_searx_get_state(){ - - # usage: install_searx_get_state - # - # Prompts a string indicating the status of the installation procedure - # - # missing-searx-clone: - # There is no clone at ${SEARXNG_SRC} - # missing-searx-pyenv: - # There is no pyenv in ${SEARXNG_PYENV} - # installer-modified: - # There are files modified locally in the installer (clone), - # see ${SEARX_SRC_INIT_FILES} description. - # python-installed: - # Scripts can be executed in instance's environment - # - user: ${SERVICE_USER} - # - pyenv: ${SEARXNG_PYENV} - - if [ -f /etc/searx/settings.yml ]; then - err_msg "settings.yml in /etc/searx/ is deprecated, move file to folder /etc/searxng/" - fi - - if ! [ -r "${SEARXNG_SRC}" ]; then - echo "missing-searx-clone" - return - fi - if ! [ -f "${SEARXNG_PYENV}/bin/activate" ]; then - echo "missing-searx-pyenv" - return - fi - if ! [ -r "${SEARXNG_SETTINGS_PATH}" ]; then - echo "missing-settings" - return - fi - if ! [ ${#SEARX_SRC_INIT_FILES[*]} -eq 0 ]; then - echo "installer-modified" - return - fi - echo "python-installed" -} - -# Initialization of the installation procedure -# -------------------------------------------- - -# shellcheck source=utils/brand.env -source "${REPO_ROOT}/utils/brand.env" - -# SEARXNG_URL aka PUBLIC_URL: the public URL of the instance (e.g. -# "https://example.org/searx"). The value is taken from environment $SEARXNG_URL -# in ./utils/brand.env. This variable is a empty string if server.base_url in -# the settings.yml is set to 'false'. - -SEARXNG_URL="${SEARXNG_URL:-http://$(uname -n)}" -if in_container; then - # hint: Linux containers do not have DNS entries, lets use IPs - SEARXNG_URL="http://$(primary_ip)" -fi -# shellcheck disable=SC2034 -PUBLIC_URL="${SEARXNG_URL}" - -source_dot_config - -# shellcheck source=utils/lxc-searxng.env -source "${REPO_ROOT}/utils/lxc-searxng.env" -in_container && lxc_set_suite_env -- cgit v1.2.3