mirror of
https://github.com/searxng/searxng.git
synced 2025-08-04 19:06:44 +02:00
[fix] sh: apply format
Related https://github.com/searxng/searxng/issues/4803
This commit is contained in:
parent
2311d16497
commit
e9ecdcc350
18 changed files with 644 additions and 548 deletions
24
manage
24
manage
|
@ -113,7 +113,6 @@ environment ...
|
|||
EOF
|
||||
}
|
||||
|
||||
|
||||
if [ "$VERBOSE" = "1" ]; then
|
||||
SPHINX_VERBOSE="-v"
|
||||
PYLINT_VERBOSE="-v"
|
||||
|
@ -143,7 +142,8 @@ gecko.driver() {
|
|||
|
||||
build_msg INSTALL "gecko.driver"
|
||||
# run installation in a subprocess and activate pyenv
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
|
||||
INSTALLED_VERSION=$(geckodriver -V 2>/dev/null | head -1 | awk '{ print "v" $2}') || INSTALLED_VERSION=""
|
||||
|
@ -160,7 +160,7 @@ gecko.driver() {
|
|||
"windows 64 bit") ARCH="win64" ;;
|
||||
"mac 64bit") ARCH="macos" ;;
|
||||
esac
|
||||
GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz";
|
||||
GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz"
|
||||
|
||||
build_msg GECKO "Installing ${PY_ENV_BIN}/geckodriver from $GECKODRIVER_URL"
|
||||
|
||||
|
@ -181,7 +181,8 @@ py.build() {
|
|||
|
||||
py.clean() {
|
||||
build_msg CLEAN pyenv
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.drop
|
||||
[ "$VERBOSE" = "1" ] && set -x
|
||||
rm -rf "${PYDIST}" "${PYBUILD}" "${PY_ENV}" ./.tox ./*.egg-info
|
||||
|
@ -207,7 +208,8 @@ pyenv.install() {
|
|||
return 0
|
||||
fi
|
||||
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv
|
||||
build_msg PYENV "[install] pip install --use-pep517 --no-build-isolation -e 'searx${PY_SETUP_EXTRAS}'"
|
||||
"${PY_ENV_BIN}/python" -m pip install --use-pep517 --no-build-isolation -e ".${PY_SETUP_EXTRAS}"
|
||||
|
@ -220,8 +222,8 @@ pyenv.install() {
|
|||
|
||||
pyenv.uninstall() {
|
||||
build_msg PYENV "[pyenv.uninstall] uninstall packages: ${PYOBJECTS}"
|
||||
pyenv.cmd python setup.py develop --uninstall 2>&1 \
|
||||
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||
pyenv.cmd python setup.py develop --uninstall 2>&1 |
|
||||
prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||
|
||||
}
|
||||
|
||||
|
@ -253,7 +255,8 @@ docs.prebuild() {
|
|||
main() {
|
||||
|
||||
local _type
|
||||
local cmd="$1"; shift
|
||||
local cmd="$1"
|
||||
shift
|
||||
|
||||
if [ "$cmd" == "" ]; then
|
||||
help
|
||||
|
@ -262,7 +265,10 @@ main() {
|
|||
fi
|
||||
|
||||
case "$cmd" in
|
||||
--getenv) var="$1"; echo "${!var}";;
|
||||
--getenv)
|
||||
var="$1"
|
||||
echo "${!var}"
|
||||
;;
|
||||
--help) help ;;
|
||||
--*)
|
||||
help
|
||||
|
|
|
@ -8,11 +8,11 @@ build.env.export() {
|
|||
GIT_BRANCH="$(git branch | grep '\*' | cut -d' ' -f2-)"
|
||||
GIT_REMOTE="$(git config "branch.${GIT_BRANCH}.remote")"
|
||||
GIT_URL="$(git config --get "remote.${GIT_REMOTE}.url")"
|
||||
if [[ "${GIT_URL}" == git@* ]]; then
|
||||
if [[ ${GIT_URL} == git@* ]]; then
|
||||
GIT_URL="${GIT_URL/://}"
|
||||
GIT_URL="${GIT_URL/git@/https://}"
|
||||
fi
|
||||
if [[ "${GIT_URL}" == *.git ]]; then
|
||||
if [[ ${GIT_URL} == *.git ]]; then
|
||||
GIT_URL="${GIT_URL%.git}"
|
||||
fi
|
||||
|
||||
|
|
121
utils/lib.sh
121
utils/lib.sh
|
@ -4,11 +4,20 @@
|
|||
# shellcheck disable=SC2059,SC1117
|
||||
|
||||
# ubuntu, debian, arch, fedora, centos ...
|
||||
DIST_ID=$(source /etc/os-release; echo "$ID");
|
||||
DIST_ID=$(
|
||||
source /etc/os-release
|
||||
echo "$ID"
|
||||
)
|
||||
# shellcheck disable=SC2034
|
||||
DIST_VERS=$(source /etc/os-release; echo "$VERSION_ID");
|
||||
DIST_VERS=$(
|
||||
source /etc/os-release
|
||||
echo "$VERSION_ID"
|
||||
)
|
||||
# shellcheck disable=SC2034
|
||||
DIST_VERSION_CODENAME=$(source /etc/os-release; echo "$VERSION_CODENAME");
|
||||
DIST_VERSION_CODENAME=$(
|
||||
source /etc/os-release
|
||||
echo "$VERSION_CODENAME"
|
||||
)
|
||||
|
||||
ADMIN_NAME="${ADMIN_NAME:-$(git config user.name)}"
|
||||
ADMIN_NAME="${ADMIN_NAME:-$USER}"
|
||||
|
@ -16,7 +25,7 @@ ADMIN_NAME="${ADMIN_NAME:-$USER}"
|
|||
ADMIN_EMAIL="${ADMIN_EMAIL:-$(git config user.email)}"
|
||||
ADMIN_EMAIL="${ADMIN_EMAIL:-$USER@$(hostname)}"
|
||||
|
||||
if [[ -z "${REPO_ROOT}" ]]; then
|
||||
if [[ -z ${REPO_ROOT} ]]; then
|
||||
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")
|
||||
while [ -h "${REPO_ROOT}" ]; do
|
||||
REPO_ROOT=$(readlink "${REPO_ROOT}")
|
||||
|
@ -28,7 +37,7 @@ if [[ -z ${TEMPLATES} ]]; then
|
|||
TEMPLATES="${REPO_ROOT}/utils/templates"
|
||||
fi
|
||||
|
||||
if [[ -z "$CACHE" ]]; then
|
||||
if [[ -z $CACHE ]]; then
|
||||
CACHE="${REPO_ROOT}/cache"
|
||||
fi
|
||||
|
||||
|
@ -42,7 +51,7 @@ fi
|
|||
DOT_CONFIG="${DOT_CONFIG:-${REPO_ROOT}/.config.sh}"
|
||||
|
||||
source_dot_config() {
|
||||
if [[ ! -e "${DOT_CONFIG}" ]]; then
|
||||
if [[ ! -e ${DOT_CONFIG} ]]; then
|
||||
err_msg "configuration does not exists at: ${DOT_CONFIG}"
|
||||
return 42
|
||||
fi
|
||||
|
@ -150,12 +159,12 @@ rst_para() {
|
|||
}
|
||||
|
||||
die() {
|
||||
echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: ${2-died ${1-1}}" >&2;
|
||||
echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: ${2-died ${1-1}}" >&2
|
||||
exit "${1-1}"
|
||||
}
|
||||
|
||||
die_caller() {
|
||||
echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[2]}: line ${BASH_LINENO[1]}: ${FUNCNAME[1]}(): ${2-died ${1-1}}" >&2;
|
||||
echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[2]}: line ${BASH_LINENO[1]}: ${FUNCNAME[1]}(): ${2-died ${1-1}}" >&2
|
||||
exit "${1-1}"
|
||||
}
|
||||
|
||||
|
@ -191,7 +200,7 @@ wait_key(){
|
|||
clean_stdin
|
||||
local _t=$1
|
||||
local msg="${MSG}"
|
||||
[[ -z "$msg" ]] && msg="${_Green}** press any [${_BCyan}KEY${_Green}] to continue **${_creset}"
|
||||
[[ -z $msg ]] && msg="${_Green}** press any [${_BCyan}KEY${_Green}] to continue **${_creset}"
|
||||
|
||||
[[ -n $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
|
||||
[[ -n $_t ]] && _t="-t $_t"
|
||||
|
@ -233,7 +242,8 @@ ask_yn() {
|
|||
# shellcheck disable=SC2086,SC2229
|
||||
read -r -n1 $_t
|
||||
if [[ -z $REPLY ]]; then
|
||||
printf "$default\n"; break
|
||||
printf "$default\n"
|
||||
break
|
||||
elif [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit_val=${EXIT_YES}
|
||||
printf "\n"
|
||||
|
@ -260,7 +270,7 @@ tee_stderr () {
|
|||
# >>> print("hello")
|
||||
# hello
|
||||
|
||||
local _t="0";
|
||||
local _t="0"
|
||||
if [[ -n $1 ]]; then _t="$1"; fi
|
||||
|
||||
(while read -r line; do
|
||||
|
@ -320,11 +330,13 @@ cache_download() {
|
|||
info_msg "caching: $1"
|
||||
info_msg " --> ${CACHE}/$2"
|
||||
if [[ -n ${SUDO_USER} ]]; then
|
||||
sudo -u "${SUDO_USER}" wget --progress=bar -O "${CACHE}/$2" "$1" ; exit_value=$?
|
||||
sudo -u "${SUDO_USER}" wget --progress=bar -O "${CACHE}/$2" "$1"
|
||||
exit_value=$?
|
||||
else
|
||||
wget --progress=bar -O "${CACHE}/$2" "$1" ; exit_value=$?
|
||||
wget --progress=bar -O "${CACHE}/$2" "$1"
|
||||
exit_value=$?
|
||||
fi
|
||||
if [[ ! $exit_value = 0 ]]; then
|
||||
if [[ $exit_value != 0 ]]; then
|
||||
err_msg "failed to download: $1"
|
||||
fi
|
||||
fi
|
||||
|
@ -350,7 +362,7 @@ choose_one() {
|
|||
local default=${DEFAULT_SELECT-1}
|
||||
local REPLY
|
||||
local env_name=$1 && shift
|
||||
local choice=$1;
|
||||
local choice=$1
|
||||
local max="${#@}"
|
||||
local _t
|
||||
[[ -n $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
|
||||
|
@ -359,7 +371,7 @@ choose_one() {
|
|||
list=("$@")
|
||||
echo -e "${_BGreen}Menu::${_creset}"
|
||||
for ((i = 1; i <= $((max - 1)); i++)); do
|
||||
if [[ "$i" == "$default" ]]; then
|
||||
if [[ $i == "$default" ]]; then
|
||||
echo -e " ${_BGreen}$i.${_creset}) ${list[$i]} [default]"
|
||||
else
|
||||
echo -e " $i.) ${list[$i]}"
|
||||
|
@ -414,8 +426,14 @@ install_template() {
|
|||
|
||||
for i in "$@"; do
|
||||
case $i in
|
||||
--no-eval) do_eval=0; shift ;;
|
||||
--variant=*) variant=":${i#*=}"; shift ;;
|
||||
--no-eval)
|
||||
do_eval=0
|
||||
shift
|
||||
;;
|
||||
--variant=*)
|
||||
variant=":${i#*=}"
|
||||
shift
|
||||
;;
|
||||
*) pos_args+=("$i") ;;
|
||||
esac
|
||||
done
|
||||
|
@ -431,14 +449,14 @@ install_template() {
|
|||
info_msg "install (eval=$do_eval): ${dst}"
|
||||
[[ -n $variant ]] && info_msg "variant --> ${variant}"
|
||||
|
||||
if [[ ! -f "${template_origin}" ]] ; then
|
||||
if [[ ! -f ${template_origin} ]]; then
|
||||
err_msg "${template_origin} does not exists"
|
||||
err_msg "... can't install $dst"
|
||||
wait_key 30
|
||||
return 42
|
||||
fi
|
||||
|
||||
if [[ "$do_eval" == "1" ]]; then
|
||||
if [[ $do_eval == "1" ]]; then
|
||||
template_file="${CACHE}${dst}${variant}"
|
||||
info_msg "BUILD ${template_file}"
|
||||
info_msg "BUILD using template ${template_origin}"
|
||||
|
@ -458,14 +476,14 @@ install_template() {
|
|||
|
||||
mkdir -p "$(dirname "${dst}")"
|
||||
|
||||
if [[ ! -f "${dst}" ]]; then
|
||||
if [[ ! -f ${dst} ]]; then
|
||||
info_msg "install: ${template_file}"
|
||||
sudo -H install -v -o "${owner}" -g "${group}" -m "${chmod}" \
|
||||
"${template_file}" "${dst}" | prefix_stdout
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [[ -f "${dst}" ]] && cmp --silent "${template_file}" "${dst}" ; then
|
||||
if [[ -f ${dst} ]] && cmp --silent "${template_file}" "${dst}"; then
|
||||
info_msg "file ${dst} already installed"
|
||||
return 0
|
||||
fi
|
||||
|
@ -503,6 +521,7 @@ install_template() {
|
|||
;;
|
||||
"diff files")
|
||||
$DIFF_CMD "${dst}" "${template_file}" | prefix_stdout
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
@ -517,7 +536,7 @@ service_is_available() {
|
|||
--silent -o /dev/null --head --write-out '%{http_code}' --insecure \
|
||||
"${URL}")
|
||||
exit_val=$?
|
||||
if [[ $exit_val = 0 ]]; then
|
||||
if [[ $exit_val == 0 ]]; then
|
||||
info_msg "got $http_code from ${URL}"
|
||||
fi
|
||||
case "$http_code" in
|
||||
|
@ -563,8 +582,8 @@ pyenv() {
|
|||
# files.
|
||||
|
||||
required_commands \
|
||||
sha256sum "${PYTHON}" \
|
||||
|| exit
|
||||
sha256sum "${PYTHON}" ||
|
||||
exit
|
||||
|
||||
local pip_req=()
|
||||
|
||||
|
@ -583,8 +602,8 @@ pyenv() {
|
|||
(
|
||||
[ "$VERBOSE" = "1" ] && set -x
|
||||
# shellcheck disable=SC2086
|
||||
"${PY_ENV_BIN}/python" -m pip install "${pip_req[@]}" \
|
||||
&& sha256sum ${PY_ENV_REQ} > "${PY_ENV}/requirements.sha256"
|
||||
"${PY_ENV_BIN}/python" -m pip install "${pip_req[@]}" &&
|
||||
sha256sum ${PY_ENV_REQ} >"${PY_ENV}/requirements.sha256"
|
||||
)
|
||||
fi
|
||||
pyenv.OK
|
||||
|
@ -602,17 +621,17 @@ pyenv.OK() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${PY_ENV}/requirements.sha256" ] \
|
||||
|| ! sha256sum -c "${PY_ENV}/requirements.sha256" > /dev/null 2>&1; then
|
||||
if [ ! -f "${PY_ENV}/requirements.sha256" ] ||
|
||||
! sha256sum -c "${PY_ENV}/requirements.sha256" >/dev/null 2>&1; then
|
||||
build_msg PYENV "[virtualenv] requirements.sha256 failed"
|
||||
sed 's/^/ [virtualenv] - /' <"${PY_ENV}/requirements.sha256"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "$VERBOSE" = "1" ]; then
|
||||
pyenv.check \
|
||||
| "${PY_ENV_BIN}/python" 2>&1 \
|
||||
| prefix_stdout "${_Blue}PYENV ${_creset}[check] "
|
||||
pyenv.check |
|
||||
"${PY_ENV_BIN}/python" 2>&1 |
|
||||
prefix_stdout "${_Blue}PYENV ${_creset}[check] "
|
||||
else
|
||||
pyenv.check | "${PY_ENV_BIN}/python" 1>/dev/null
|
||||
fi
|
||||
|
@ -708,19 +727,19 @@ pyenv.uninstall() {
|
|||
build_msg PYENV "[uninstall] ${PYOBJECTS}"
|
||||
|
||||
if [ "." = "${PYOBJECTS}" ]; then
|
||||
pyenv.cmd python setup.py develop --uninstall 2>&1 \
|
||||
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||
pyenv.cmd python setup.py develop --uninstall 2>&1 |
|
||||
prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||
else
|
||||
# shellcheck disable=SC2086
|
||||
pyenv.cmd python -m pip uninstall --yes ${PYOBJECTS} 2>&1 \
|
||||
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||
pyenv.cmd python -m pip uninstall --yes ${PYOBJECTS} 2>&1 |
|
||||
prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
pyenv.cmd() {
|
||||
pyenv.install
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
# shellcheck source=/dev/null
|
||||
source "${PY_ENV_BIN}/activate"
|
||||
[ "$VERBOSE" = "1" ] && set -x
|
||||
|
@ -728,14 +747,12 @@ pyenv.cmd() {
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
pyenv.activate() {
|
||||
pyenv.install
|
||||
# shellcheck source=/dev/null
|
||||
source "${PY_ENV_BIN}/activate"
|
||||
}
|
||||
|
||||
|
||||
# Sphinx doc
|
||||
# ----------
|
||||
|
||||
|
@ -858,7 +875,6 @@ interactive_shell(){
|
|||
sudo -H -u "${1}" -i
|
||||
}
|
||||
|
||||
|
||||
# systemd
|
||||
# -------
|
||||
|
||||
|
@ -927,7 +943,6 @@ systemctl status --no-pager ${1}.service
|
|||
EOF
|
||||
}
|
||||
|
||||
|
||||
# nginx
|
||||
# -----
|
||||
|
||||
|
@ -1042,16 +1057,15 @@ nginx_include_apps_enabled() {
|
|||
(
|
||||
local line
|
||||
local stage=0
|
||||
while IFS= read -r line
|
||||
do
|
||||
while IFS= read -r line; do
|
||||
echo "$line"
|
||||
if [[ $stage = 0 ]]; then
|
||||
if [[ $stage == 0 ]]; then
|
||||
if [[ $line =~ ^[[:space:]]*server*[[:space:]]*\{ ]]; then
|
||||
stage=1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $stage = 1 ]]; then
|
||||
if [[ $stage == 1 ]]; then
|
||||
echo " # Load configuration files for the default server block."
|
||||
echo " $include_directive"
|
||||
echo ""
|
||||
|
@ -1095,7 +1109,6 @@ nginx_disable_app() {
|
|||
nginx_reload
|
||||
}
|
||||
|
||||
|
||||
# Apache
|
||||
# ------
|
||||
|
||||
|
@ -1601,15 +1614,15 @@ git_clone() {
|
|||
local bash_cmd="bash"
|
||||
local remote="origin"
|
||||
|
||||
if [[ ! "${dest:0:1}" = "/" ]]; then
|
||||
if [[ ${dest:0:1} != "/" ]]; then
|
||||
dest="$CACHE/$dest"
|
||||
fi
|
||||
|
||||
[[ -z $branch ]] && branch=master
|
||||
[[ -z $user ]] && [[ -n "${SUDO_USER}" ]] && user="${SUDO_USER}"
|
||||
[[ -z $user ]] && [[ -n ${SUDO_USER} ]] && user="${SUDO_USER}"
|
||||
[[ -n $user ]] && bash_cmd="sudo -H -u $user -i"
|
||||
|
||||
if [[ -d "${dest}" ]] ; then
|
||||
if [[ -d ${dest} ]]; then
|
||||
info_msg "already cloned: $dest"
|
||||
tee_stderr 0.1 <<EOF | $bash_cmd 2>&1 | prefix_stdout " ${_Yellow}|$user|${_creset} "
|
||||
cd "${dest}"
|
||||
|
@ -1700,7 +1713,6 @@ lxc_install_base_packages() {
|
|||
pkg_install "${LXC_BASE_PACKAGES}"
|
||||
}
|
||||
|
||||
|
||||
lxc_image_copy() {
|
||||
|
||||
# usage: lxc_image_copy <remote image> <local image>
|
||||
|
@ -1766,7 +1778,6 @@ lxc_delete_local_image() {
|
|||
lxc image delete "local:$i"
|
||||
}
|
||||
|
||||
|
||||
# IP
|
||||
# --
|
||||
|
||||
|
@ -1787,9 +1798,9 @@ primary_ip() {
|
|||
|
||||
case $DIST_ID in
|
||||
arch)
|
||||
ip -o addr show \
|
||||
| sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\2/p' \
|
||||
| head -n 1
|
||||
ip -o addr show |
|
||||
sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\2/p' |
|
||||
head -n 1
|
||||
;;
|
||||
*) hostname -I | cut -d' ' -f1 ;;
|
||||
esac
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
# configure golang environment
|
||||
# ----------------------------
|
||||
|
||||
[[ -z "${GO_VERSION}" ]] && GO_VERSION="go1.17.3"
|
||||
[[ -z ${GO_VERSION} ]] && GO_VERSION="go1.17.3"
|
||||
|
||||
GO_DL_URL="https://golang.org/dl"
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ declare main_cmd
|
|||
|
||||
NVM_LOCAL_FOLDER=.nvm
|
||||
|
||||
[[ -z "${NVM_GIT_URL}" ]] && NVM_GIT_URL="https://github.com/nvm-sh/nvm.git"
|
||||
[[ -z "${NVM_MIN_NODE_VER}" ]] && NVM_MIN_NODE_VER="16.13.0"
|
||||
[[ -z ${NVM_GIT_URL} ]] && NVM_GIT_URL="https://github.com/nvm-sh/nvm.git"
|
||||
[[ -z ${NVM_MIN_NODE_VER} ]] && NVM_MIN_NODE_VER="16.13.0"
|
||||
|
||||
# initialize nvm environment
|
||||
# -------------------------
|
||||
|
@ -35,7 +35,7 @@ nvm.is_installed() {
|
|||
[[ -f "${NVM_DIR}/nvm.sh" ]]
|
||||
}
|
||||
|
||||
if [[ -z "${NVM_DIR}" ]]; then
|
||||
if [[ -z ${NVM_DIR} ]]; then
|
||||
# nvm is not pre-installed in $HOME. Prepare for using nvm from <repo-root>
|
||||
NVM_DIR="$(git rev-parse --show-toplevel)/${NVM_LOCAL_FOLDER}"
|
||||
fi
|
||||
|
|
|
@ -21,7 +21,6 @@ redis.:
|
|||
EOF
|
||||
}
|
||||
|
||||
|
||||
redis.remove() {
|
||||
sudo_or_exit
|
||||
(
|
||||
|
@ -36,7 +35,6 @@ redis.shell() {
|
|||
interactive_shell "${REDIS_USER}"
|
||||
}
|
||||
|
||||
|
||||
redis.userdel() {
|
||||
sudo_or_exit
|
||||
drop_service_account "${REDIS_USER}"
|
||||
|
|
|
@ -117,7 +117,7 @@ container.build() {
|
|||
--tag="localhost/$CONTAINER_IMAGE_ORGANIZATION/$CONTAINER_IMAGE_NAME:builder" \
|
||||
--file="./container/$dockerfile" \
|
||||
.
|
||||
build_msg CONTAINER "Image \"builder\" built"
|
||||
build_msg CONTAINER 'Image "builder" built'
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
"$container_engine" $params_build \
|
||||
|
|
|
@ -13,7 +13,8 @@ EOF
|
|||
}
|
||||
|
||||
data.all() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
|
||||
pyenv.activate
|
||||
data.traits
|
||||
|
@ -35,9 +36,9 @@ data.all() {
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
data.traits() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
build_msg DATA "update searx/data/engine_traits.json"
|
||||
python searxng_extra/update/update_engine_traits.py
|
||||
|
@ -53,7 +54,8 @@ data.useragents() {
|
|||
}
|
||||
|
||||
data.locales() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
build_msg DATA "update searx/data/locales.json"
|
||||
python searxng_extra/update/update_locales.py
|
||||
|
@ -62,7 +64,8 @@ data.locales() {
|
|||
}
|
||||
|
||||
data.currencies() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
build_msg DATA "update searx/data/currencies.json"
|
||||
python searxng_extra/update/update_currencies.py
|
||||
|
|
|
@ -24,7 +24,8 @@ nodejs.ensure() {
|
|||
|
||||
node.env() {
|
||||
nodejs.ensure
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
build_msg INSTALL "[npm] ./client/simple/package.json"
|
||||
npm --prefix client/simple install
|
||||
)
|
||||
|
@ -43,17 +44,19 @@ node.clean() {
|
|||
return 0
|
||||
fi
|
||||
build_msg CLEAN "themes -- locally installed npm dependencies"
|
||||
( set -e
|
||||
npm --prefix client/simple run clean \
|
||||
| prefix_stdout "${_Blue}CLEAN ${_creset} "
|
||||
(
|
||||
set -e
|
||||
npm --prefix client/simple run clean |
|
||||
prefix_stdout "${_Blue}CLEAN ${_creset} "
|
||||
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
|
||||
return 1
|
||||
fi
|
||||
)
|
||||
build_msg CLEAN "locally installed developer and CI tools"
|
||||
( set -e
|
||||
npm --prefix . run clean \
|
||||
| prefix_stdout "${_Blue}CLEAN ${_creset} "
|
||||
(
|
||||
set -e
|
||||
npm --prefix . run clean |
|
||||
prefix_stdout "${_Blue}CLEAN ${_creset} "
|
||||
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
|
||||
STATIC_BUILD_COMMIT="[build] /static"
|
||||
STATIC_BUILT_PATHS=(
|
||||
'searx/templates/simple/icons.html'
|
||||
|
@ -96,7 +95,8 @@ static.build.commit() {
|
|||
# drop existing commit from previous build
|
||||
static.build.drop &>/dev/null
|
||||
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
# fix & build the themes
|
||||
themes.fix
|
||||
themes.lint
|
||||
|
|
|
@ -22,13 +22,14 @@ if [ "$VERBOSE" = "1" ]; then
|
|||
fi
|
||||
|
||||
test.yamllint() {
|
||||
build_msg TEST "[yamllint] \$YAMLLINT_FILES"
|
||||
build_msg TEST "[yamllint] ${YAMLLINT_FILES[*]}"
|
||||
pyenv.cmd yamllint --strict --format parsable "${YAMLLINT_FILES[@]}"
|
||||
dump_return $?
|
||||
}
|
||||
|
||||
test.pylint() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
PYLINT_OPTIONS="--rcfile .pylintrc"
|
||||
|
||||
|
@ -63,13 +64,13 @@ test.types.dev() {
|
|||
build_msg TEST "[pyright/types] suppress warnings related to intentional monkey patching"
|
||||
# We run Pyright in the virtual environment because pyright executes
|
||||
# "python" to determine the Python version.
|
||||
pyenv.cmd npx --no-install pyright -p pyrightconfig.json \
|
||||
| grep -E '\.py:[0-9]+:[0-9]+'\
|
||||
| grep -v '/engines/.*.py.* - warning: "logger" is not defined'\
|
||||
| grep -v '/plugins/.*.py.* - error: "logger" is not defined'\
|
||||
| grep -v '/engines/.*.py.* - warning: "supported_languages" is not defined' \
|
||||
| grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' \
|
||||
| grep -v '/engines/.*.py.* - warning: "categories" is not defined'
|
||||
pyenv.cmd npx --no-install pyright -p pyrightconfig.json |
|
||||
grep -E '\.py:[0-9]+:[0-9]+' |
|
||||
grep -v '/engines/.*.py.* - warning: "logger" is not defined' |
|
||||
grep -v '/plugins/.*.py.* - error: "logger" is not defined' |
|
||||
grep -v '/engines/.*.py.* - warning: "supported_languages" is not defined' |
|
||||
grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' |
|
||||
grep -v '/engines/.*.py.* - warning: "categories" is not defined'
|
||||
# ignore exit value from pyright
|
||||
# dump_return ${PIPESTATUS[0]}
|
||||
return 0
|
||||
|
@ -88,13 +89,13 @@ test.types.ci() {
|
|||
build_msg TEST "[pyright] suppress warnings related to intentional monkey patching"
|
||||
# We run Pyright in the virtual environment because pyright executes
|
||||
# "python" to determine the Python version.
|
||||
pyenv.cmd npx --no-install pyright -p pyrightconfig-ci.json \
|
||||
| grep -E '\.py:[0-9]+:[0-9]+'\
|
||||
| grep -v '/engines/.*.py.* - warning: "logger" is not defined'\
|
||||
| grep -v '/plugins/.*.py.* - error: "logger" is not defined'\
|
||||
| grep -v '/engines/.*.py.* - warning: "supported_languages" is not defined' \
|
||||
| grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' \
|
||||
| grep -v '/engines/.*.py.* - warning: "categories" is not defined'
|
||||
pyenv.cmd npx --no-install pyright -p pyrightconfig-ci.json |
|
||||
grep -E '\.py:[0-9]+:[0-9]+' |
|
||||
grep -v '/engines/.*.py.* - warning: "logger" is not defined' |
|
||||
grep -v '/plugins/.*.py.* - error: "logger" is not defined' |
|
||||
grep -v '/engines/.*.py.* - warning: "supported_languages" is not defined' |
|
||||
grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' |
|
||||
grep -v '/engines/.*.py.* - warning: "categories" is not defined'
|
||||
# ignore exit value from pyright
|
||||
# dump_return ${PIPESTATUS[0]}
|
||||
return 0
|
||||
|
@ -121,7 +122,8 @@ test.unit() {
|
|||
|
||||
test.coverage() {
|
||||
build_msg TEST 'unit test coverage'
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
# shellcheck disable=SC2086
|
||||
python -m nose2 ${TEST_NOSE2_VERBOSE} -C --log-capture --with-coverage --coverage searx -s tests/unit
|
||||
|
|
|
@ -13,14 +13,16 @@ EOF
|
|||
}
|
||||
|
||||
themes.all() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
vite.simple.build
|
||||
)
|
||||
dump_return $?
|
||||
}
|
||||
|
||||
themes.simple() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
build_msg SIMPLE "theme: run build (simple)"
|
||||
vite.simple.build
|
||||
)
|
||||
|
@ -28,7 +30,8 @@ themes.simple() {
|
|||
}
|
||||
|
||||
themes.fix() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
build_msg SIMPLE "theme: fix (all themes)"
|
||||
vite.simple.fix
|
||||
)
|
||||
|
@ -36,7 +39,8 @@ themes.fix() {
|
|||
}
|
||||
|
||||
themes.lint() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
build_msg SIMPLE "theme: lint (all themes)"
|
||||
vite.simple.lint
|
||||
)
|
||||
|
@ -44,7 +48,8 @@ themes.lint() {
|
|||
}
|
||||
|
||||
themes.test() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
# we run a build to test (in CI)
|
||||
build_msg SIMPLE "theme: run build (to test)"
|
||||
vite.simple.build
|
||||
|
|
|
@ -30,7 +30,8 @@ VITE_SIMPLE_THEME="${REPO_ROOT}/client/simple"
|
|||
# }
|
||||
|
||||
vite.simple.build() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
templates.simple.pygments
|
||||
|
||||
node.env
|
||||
|
@ -44,14 +45,16 @@ vite.simple.build() {
|
|||
}
|
||||
|
||||
vite.simple.fix() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
node.env
|
||||
npm --prefix client/simple run fix
|
||||
)
|
||||
}
|
||||
|
||||
vite.simple.lint() {
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
node.env
|
||||
npm --prefix client/simple run lint
|
||||
)
|
||||
|
@ -59,8 +62,8 @@ vite.simple.lint() {
|
|||
|
||||
templates.simple.pygments() {
|
||||
build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
|
||||
pyenv.cmd python searxng_extra/update/update_pygments.py \
|
||||
| prefix_stdout "${_Blue}PYGMENTS ${_creset} "
|
||||
pyenv.cmd python searxng_extra/update/update_pygments.py |
|
||||
prefix_stdout "${_Blue}PYGMENTS ${_creset} "
|
||||
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
|
||||
build_msg PYGMENTS "building LESS files for pygments failed"
|
||||
return 1
|
||||
|
|
|
@ -19,7 +19,8 @@ weblate.translations.worktree() {
|
|||
#
|
||||
# remote weblate https://translate.codeberg.org/git/searxng/searxng/
|
||||
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
if ! git remote get-url weblate 2>/dev/null; then
|
||||
git remote add weblate https://translate.codeberg.org/git/searxng/searxng/
|
||||
fi
|
||||
|
@ -49,7 +50,8 @@ weblate.to.translations() {
|
|||
# 4. In translations worktree, merge changes of branch 'translations' from
|
||||
# remote 'weblate' and push it on branch 'translations' of 'origin'
|
||||
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
if [ "$(wlc lock-status)" != "locked: True" ]; then
|
||||
die 1 "weblate must be locked, currently: $(wlc lock-status)"
|
||||
|
@ -77,14 +79,18 @@ weblate.translations.commit() {
|
|||
# create a commit in the local branch (master)
|
||||
|
||||
local existing_commit_hash commit_body commit_message exitcode
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
# lock change on weblate
|
||||
wlc lock
|
||||
|
||||
# get translations branch in git worktree (TRANSLATIONS_WORKTREE)
|
||||
weblate.translations.worktree
|
||||
existing_commit_hash=$(cd "${TRANSLATIONS_WORKTREE}"; git log -n1 --pretty=format:'%h')
|
||||
existing_commit_hash=$(
|
||||
cd "${TRANSLATIONS_WORKTREE}"
|
||||
git log -n1 --pretty=format:'%h'
|
||||
)
|
||||
|
||||
# pull weblate commits
|
||||
weblate.to.translations
|
||||
|
@ -101,7 +107,10 @@ weblate.translations.commit() {
|
|||
data.locales
|
||||
|
||||
# git add/commit (no push)
|
||||
commit_body=$(cd "${TRANSLATIONS_WORKTREE}"; git log --pretty=format:'%h - %as - %aN <%ae>' "${existing_commit_hash}..HEAD")
|
||||
commit_body=$(
|
||||
cd "${TRANSLATIONS_WORKTREE}"
|
||||
git log --pretty=format:'%h - %as - %aN <%ae>' "${existing_commit_hash}..HEAD"
|
||||
)
|
||||
commit_message=$(echo -e "[l10n] update translations from Weblate\n\n${commit_body}")
|
||||
git add searx/translations
|
||||
git add searx/data/locales.json
|
||||
|
@ -135,7 +144,8 @@ weblate.push.translations() {
|
|||
local messages_pot diff_messages_pot last_commit_hash last_commit_detail \
|
||||
exitcode
|
||||
messages_pot="${TRANSLATIONS_WORKTREE}/searx/translations/messages.pot"
|
||||
( set -e
|
||||
(
|
||||
set -e
|
||||
pyenv.activate
|
||||
# get translations branch in git worktree (TRANSLATIONS_WORKTREE)
|
||||
weblate.translations.worktree
|
||||
|
@ -147,8 +157,10 @@ weblate.push.translations() {
|
|||
"searx/"
|
||||
|
||||
# stop if there is no meaningful change in the master branch
|
||||
diff_messages_pot=$(cd "${TRANSLATIONS_WORKTREE}";\
|
||||
git diff -- "searx/translations/messages.pot")
|
||||
diff_messages_pot=$(
|
||||
cd "${TRANSLATIONS_WORKTREE}"
|
||||
git diff -- "searx/translations/messages.pot"
|
||||
)
|
||||
if ! echo "$diff_messages_pot" | grep -qE "[\+\-](msgid|msgstr)"; then
|
||||
build_msg BABEL 'no changes detected, exiting'
|
||||
return 42
|
||||
|
|
96
utils/lxc.sh
96
utils/lxc.sh
|
@ -70,9 +70,7 @@ HOST_USER="${SUDO_USER:-$USER}"
|
|||
HOST_USER_ID=$(id -u "${HOST_USER}")
|
||||
HOST_GROUP_ID=$(id -g "${HOST_USER}")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
usage() {
|
||||
# ----------------------------------------------------------------------------
|
||||
_cmd="$(basename "$0")"
|
||||
cat <<EOF
|
||||
usage::
|
||||
|
@ -138,7 +136,7 @@ main() {
|
|||
lxc_distro_setup
|
||||
|
||||
# don't check prerequisite when in recursion
|
||||
if [[ ! $1 == __* ]] && [[ ! $1 == --help ]]; then
|
||||
if [[ $1 != __* ]] && [[ $1 != --help ]]; then
|
||||
if ! in_container; then
|
||||
! required_commands lxc && lxd_info && exit 42
|
||||
fi
|
||||
|
@ -146,21 +144,34 @@ main() {
|
|||
fi
|
||||
|
||||
case $1 in
|
||||
--getenv) var="$2"; echo "${!var}"; exit 0;;
|
||||
-h|--help) usage; exit 0;;
|
||||
--getenv)
|
||||
var="$2"
|
||||
echo "${!var}"
|
||||
exit 0
|
||||
;;
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
|
||||
build)
|
||||
sudo_or_exit
|
||||
case $2 in
|
||||
${LXC_HOST_PREFIX}-*) build_container "$2" ;;
|
||||
'' | -- | containers) build_all_containers ;;
|
||||
*) usage "$_usage"; exit 42;;
|
||||
*)
|
||||
usage "$_usage"
|
||||
exit 42
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
copy)
|
||||
case $2 in
|
||||
'' | images) lxc_copy_images_locally ;;
|
||||
*) usage "$_usage"; exit 42;;
|
||||
*)
|
||||
usage "$_usage"
|
||||
exit 42
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
remove)
|
||||
|
@ -174,7 +185,10 @@ main() {
|
|||
lxc_delete_container "$2"
|
||||
fi
|
||||
;;
|
||||
*) usage "unknown or missing container <name> $2"; exit 42;;
|
||||
*)
|
||||
usage "unknown or missing container <name> $2"
|
||||
exit 42
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
start | stop)
|
||||
|
@ -186,7 +200,10 @@ main() {
|
|||
info_msg "lxc $1 $2"
|
||||
lxc "$1" "$2" | prefix_stdout "[${_BBlue}${i}${_creset}] "
|
||||
;;
|
||||
*) usage "unknown or missing container <name> $2"; exit 42;;
|
||||
*)
|
||||
usage "unknown or missing container <name> $2"
|
||||
exit 42
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
show)
|
||||
|
@ -195,8 +212,8 @@ main() {
|
|||
suite)
|
||||
case $3 in
|
||||
${LXC_HOST_PREFIX}-*)
|
||||
lxc exec -t "$3" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite \
|
||||
| prefix_stdout "[${_BBlue}$3${_creset}] "
|
||||
lxc exec -t "$3" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite |
|
||||
prefix_stdout "[${_BBlue}$3${_creset}] "
|
||||
;;
|
||||
*) show_suite ;;
|
||||
esac
|
||||
|
@ -230,7 +247,10 @@ main() {
|
|||
;;
|
||||
esac
|
||||
;;
|
||||
*) usage "$_usage"; exit 42;;
|
||||
*)
|
||||
usage "$_usage"
|
||||
exit 42
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
__show)
|
||||
|
@ -243,14 +263,17 @@ main() {
|
|||
sudo_or_exit
|
||||
shift
|
||||
case $1 in
|
||||
--) shift; lxc_exec "$@" ;;
|
||||
--)
|
||||
shift
|
||||
lxc_exec "$@"
|
||||
;;
|
||||
${LXC_HOST_PREFIX}-*)
|
||||
! lxc_exists "$1" && usage_containers "unknown container: $1" && exit 42
|
||||
local name=$1
|
||||
shift
|
||||
lxc_exec_cmd "${name}" "$@"
|
||||
;;
|
||||
*) usage_containers "unknown container: $1" && exit 42
|
||||
*) usage_containers "unknown container: $1" && exit 42 ;;
|
||||
esac
|
||||
;;
|
||||
install)
|
||||
|
@ -263,10 +286,13 @@ main() {
|
|||
lxc_exec_cmd "$3" "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2"
|
||||
;;
|
||||
'' | --) lxc_exec "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2" ;;
|
||||
*) usage_containers "unknown container: $3" && exit 42
|
||||
*) usage_containers "unknown container: $3" && exit 42 ;;
|
||||
esac
|
||||
;;
|
||||
*) usage "$_usage"; exit 42 ;;
|
||||
*)
|
||||
usage "$_usage"
|
||||
exit 42
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
__install)
|
||||
|
@ -281,12 +307,17 @@ main() {
|
|||
echo
|
||||
echo ".. generic utils/lxc.sh documentation"
|
||||
;;
|
||||
-*) usage "unknown option $1"; exit 42;;
|
||||
*) usage "unknown or missing command $1"; exit 42;;
|
||||
-*)
|
||||
usage "unknown option $1"
|
||||
exit 42
|
||||
;;
|
||||
*)
|
||||
usage "unknown or missing command $1"
|
||||
exit 42
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
build_all_containers() {
|
||||
rst_title "Build all LXC containers of suite"
|
||||
echo
|
||||
|
@ -335,8 +366,8 @@ build_container() {
|
|||
lxc_install_boilerplate "${container}" "$boilerplate_script"
|
||||
echo
|
||||
rst_title "install LXC base packages" section
|
||||
lxc_exec_cmd "${container}" "${LXC_REPO_ROOT}/utils/lxc.sh" __install base \
|
||||
| prefix_stdout "[${_BBlue}${container}${_creset}] "
|
||||
lxc_exec_cmd "${container}" "${LXC_REPO_ROOT}/utils/lxc.sh" __install base |
|
||||
prefix_stdout "[${_BBlue}${container}${_creset}] "
|
||||
echo
|
||||
lxc list "$container"
|
||||
}
|
||||
|
@ -348,7 +379,7 @@ remove_containers() {
|
|||
lxc list "$LXC_HOST_PREFIX-"
|
||||
echo -en "\\n${_BRed}LXC containers to delete::${_creset}\\n\\n ${CONTAINERS[*]}\\n" | $FMT
|
||||
local default=Ny
|
||||
[[ $FORCE_TIMEOUT = 0 ]] && default=Yn
|
||||
[[ $FORCE_TIMEOUT == 0 ]] && default=Yn
|
||||
if ask_yn "Do you really want to delete these containers" $default; then
|
||||
for i in "${CONTAINERS[@]}"; do
|
||||
lxc_delete_container "$i"
|
||||
|
@ -408,7 +439,6 @@ show_images(){
|
|||
|
||||
}
|
||||
|
||||
|
||||
# container
|
||||
# ---------
|
||||
|
||||
|
@ -421,8 +451,8 @@ show_suite(){
|
|||
if ! lxc_exists "$i"; then
|
||||
warn_msg "container ${_BBlue}$i${_creset} does not yet exists"
|
||||
else
|
||||
lxc exec -t "${i}" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite \
|
||||
| prefix_stdout "[${_BBlue}${i}${_creset}] "
|
||||
lxc exec -t "${i}" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite |
|
||||
prefix_stdout "[${_BBlue}${i}${_creset}] "
|
||||
echo
|
||||
fi
|
||||
done
|
||||
|
@ -487,8 +517,8 @@ lxc_config_container() {
|
|||
|
||||
info_msg "[${_BBlue}$1${_creset}] map uid/gid from host to container"
|
||||
# https://lxd.readthedocs.io/en/latest/userns-idmap/#custom-idmaps
|
||||
echo -e -n "uid $HOST_USER_ID 0\\ngid $HOST_GROUP_ID 0"\
|
||||
| lxc config set "$1" raw.idmap -
|
||||
echo -e -n "uid $HOST_USER_ID 0\\ngid $HOST_GROUP_ID 0" |
|
||||
lxc config set "$1" raw.idmap -
|
||||
|
||||
info_msg "[${_BBlue}$1${_creset}] share ${REPO_ROOT} (repo_share) from HOST into container"
|
||||
# https://lxd.readthedocs.io/en/latest/instances/#type-disk
|
||||
|
@ -512,7 +542,7 @@ lxc_boilerplate_all_containers() {
|
|||
|
||||
lxc_install_boilerplate "${LXC_HOST_PREFIX}-${image_name}" "$boilerplate_script"
|
||||
|
||||
if [[ -z "${boilerplate_script}" ]]; then
|
||||
if [[ -z ${boilerplate_script} ]]; then
|
||||
err_msg "[${_BBlue}${container_name}${_creset}] no boilerplate for image '${image_name}'"
|
||||
fi
|
||||
done
|
||||
|
@ -546,10 +576,10 @@ EOF
|
|||
if lxc start -q "${container_name}" &>/dev/null; then
|
||||
sleep 5 # guest needs some time to come up and get an IP
|
||||
fi
|
||||
if [[ -n "${boilerplate_script}" ]]; then
|
||||
echo "${boilerplate_script}" \
|
||||
| lxc exec "${container_name}" -- bash \
|
||||
| prefix_stdout "[${_BBlue}${container_name}${_creset}] "
|
||||
if [[ -n ${boilerplate_script} ]]; then
|
||||
echo "${boilerplate_script}" |
|
||||
lxc exec "${container_name}" -- bash |
|
||||
prefix_stdout "[${_BBlue}${container_name}${_creset}] "
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -568,6 +598,4 @@ check_connectivity() {
|
|||
return $ret_val
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
main "$@"
|
||||
# ----------------------------------------------------------------------------
|
||||
|
|
|
@ -46,7 +46,7 @@ if in_container; then
|
|||
SEARXNG_URL="http://$(primary_ip)/searxng"
|
||||
fi
|
||||
SEARXNG_URL_PATH="$(echo "${SEARXNG_URL}" | sed -e 's,^.*://[^/]*\(/.*\),\1,g')"
|
||||
[[ "${SEARXNG_URL_PATH}" == "${SEARXNG_URL}" ]] && SEARXNG_URL_PATH=/
|
||||
[[ ${SEARXNG_URL_PATH} == "${SEARXNG_URL}" ]] && SEARXNG_URL_PATH=/
|
||||
|
||||
# Apache settings
|
||||
|
||||
|
@ -114,9 +114,7 @@ esac
|
|||
|
||||
_service_prefix=" ${_Yellow}|${SERVICE_USER}|${_creset} "
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
usage() {
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# shellcheck disable=SC1117
|
||||
cat <<EOF
|
||||
|
@ -175,17 +173,27 @@ main() {
|
|||
apache_distro_setup
|
||||
uWSGI_distro_setup
|
||||
required_commands \
|
||||
sudo systemctl install git wget curl \
|
||||
|| exit
|
||||
sudo systemctl install git wget curl ||
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
local _usage="unknown or missing $1 command $2"
|
||||
|
||||
case $1 in
|
||||
--getenv) var="$2"; echo "${!var}"; exit 0;;
|
||||
--cmd) shift; "$@";;
|
||||
-h|--help) usage; exit 0;;
|
||||
--getenv)
|
||||
var="$2"
|
||||
echo "${!var}"
|
||||
exit 0
|
||||
;;
|
||||
--cmd)
|
||||
shift
|
||||
"$@"
|
||||
;;
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
install)
|
||||
sudo_or_exit
|
||||
case $2 in
|
||||
|
@ -200,7 +208,10 @@ main() {
|
|||
nginx) searxng.nginx.install ;;
|
||||
apache) searxng.apache.install ;;
|
||||
valkey) searxng.install.valkey ;;
|
||||
*) usage "$_usage"; exit 42;;
|
||||
*)
|
||||
usage "$_usage"
|
||||
exit 42
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
remove)
|
||||
|
@ -215,7 +226,10 @@ main() {
|
|||
remove) searxng.nginx.remove ;;
|
||||
valkey) searxng.remove.valkey ;;
|
||||
redis) searxng.remove.redis ;;
|
||||
*) usage "$_usage"; exit 42;;
|
||||
*)
|
||||
usage "$_usage"
|
||||
exit 42
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
instance)
|
||||
|
@ -234,19 +248,30 @@ main() {
|
|||
;;
|
||||
cmd)
|
||||
sudo_or_exit
|
||||
shift; shift; searxng.instance.exec "$@"
|
||||
shift
|
||||
shift
|
||||
searxng.instance.exec "$@"
|
||||
;;
|
||||
get_setting)
|
||||
shift; shift; searxng.instance.get_setting "$@"
|
||||
shift
|
||||
shift
|
||||
searxng.instance.get_setting "$@"
|
||||
;;
|
||||
call)
|
||||
# call a function in instance's environment
|
||||
shift; shift; searxng.instance.self.call "$@"
|
||||
shift
|
||||
shift
|
||||
searxng.instance.self.call "$@"
|
||||
;;
|
||||
_call)
|
||||
shift; shift; "$@"
|
||||
shift
|
||||
shift
|
||||
"$@"
|
||||
;;
|
||||
*)
|
||||
usage "$_usage"
|
||||
exit 42
|
||||
;;
|
||||
*) usage "$_usage"; exit 42;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
|
@ -314,7 +339,7 @@ In your instance, valkey DB connector is configured at:
|
|||
fi
|
||||
fi
|
||||
|
||||
if ! [[ ${valkey_url} = valkey://localhost:6379/* ]]; then
|
||||
if ! [[ ${valkey_url} == valkey://localhost:6379/* ]]; then
|
||||
err_msg "SearXNG instance can't connect valkey DB / check valkey & your settings"
|
||||
return
|
||||
fi
|
||||
|
@ -352,7 +377,7 @@ searxng.remove.all() {
|
|||
fi
|
||||
|
||||
valkey_url=$(searxng.instance.get_setting valkey.url)
|
||||
if ! [[ ${valkey_url} = unix://${VALKEY_HOME}/run/valkey.sock* ]]; then
|
||||
if ! [[ ${valkey_url} == unix://${VALKEY_HOME}/run/valkey.sock* ]]; then
|
||||
searxng.remove.valkey
|
||||
fi
|
||||
|
||||
|
@ -403,7 +428,7 @@ searxng.install.clone() {
|
|||
die 42 "user '${SERVICE_USER}' missed read permission: $REPO_ROOT"
|
||||
fi
|
||||
# SERVICE_HOME="$(sudo -i -u "${SERVICE_USER}" echo \$HOME 2>/dev/null)"
|
||||
if [[ ! "${SERVICE_HOME}" ]]; then
|
||||
if [[ ! ${SERVICE_HOME} ]]; then
|
||||
err_msg "to clone SearXNG sources, user ${SERVICE_USER} hast to be created first"
|
||||
return 42
|
||||
fi
|
||||
|
@ -412,7 +437,7 @@ searxng.install.clone() {
|
|||
info_msg "create local branch ${GIT_BRANCH} from start point: origin/${GIT_BRANCH}"
|
||||
git branch "${GIT_BRANCH}" "origin/${GIT_BRANCH}"
|
||||
fi
|
||||
if [[ ! $(git rev-parse --abbrev-ref HEAD) == "${GIT_BRANCH}" ]]; then
|
||||
if [[ $(git rev-parse --abbrev-ref HEAD) != "${GIT_BRANCH}" ]]; then
|
||||
warn_msg "take into account, installing branch $GIT_BRANCH while current branch is $(git rev-parse --abbrev-ref HEAD)"
|
||||
fi
|
||||
# export SERVICE_HOME
|
||||
|
@ -588,9 +613,9 @@ searxng.install.uwsgi.socket() {
|
|||
|
||||
searxng.uwsgi.available() {
|
||||
if [[ ${SEARXNG_UWSGI_USE_SOCKET} == true ]]; then
|
||||
[[ -S "${SEARXNG_UWSGI_SOCKET}" ]]
|
||||
[[ -S ${SEARXNG_UWSGI_SOCKET} ]]
|
||||
exit_val=$?
|
||||
if [[ $exit_val = 0 ]]; then
|
||||
if [[ $exit_val == 0 ]]; then
|
||||
info_msg "uWSGI socket is located at: ${SEARXNG_UWSGI_SOCKET}"
|
||||
fi
|
||||
else
|
||||
|
@ -617,7 +642,6 @@ searxng.install.valkey() {
|
|||
valkey.install
|
||||
}
|
||||
|
||||
|
||||
searxng.instance.localtest() {
|
||||
rst_title "Test SearXNG instance locally" section
|
||||
rst_para "Activate debug mode, start a minimal SearXNG " \
|
||||
|
@ -897,7 +921,8 @@ searxng.doc.rst() {
|
|||
echo -e "\n.. START searxng uwsgi-description $DIST_NAME"
|
||||
|
||||
case $DIST_ID-$DIST_VERS in
|
||||
ubuntu-*|debian-*) cat <<EOF
|
||||
ubuntu-* | debian-*)
|
||||
cat <<EOF
|
||||
|
||||
.. code:: bash
|
||||
|
||||
|
@ -914,7 +939,8 @@ searxng.doc.rst() {
|
|||
|
||||
EOF
|
||||
;;
|
||||
arch-*) cat <<EOF
|
||||
arch-*)
|
||||
cat <<EOF
|
||||
|
||||
.. code:: bash
|
||||
|
||||
|
@ -932,7 +958,8 @@ EOF
|
|||
|
||||
EOF
|
||||
;;
|
||||
fedora-*|centos-7) cat <<EOF
|
||||
fedora-* | centos-7)
|
||||
cat <<EOF
|
||||
|
||||
.. code:: bash
|
||||
|
||||
|
@ -985,6 +1012,4 @@ EOF
|
|||
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
main "$@"
|
||||
# ----------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue