mirror of
https://github.com/searxng/searxng.git
synced 2025-08-05 03:16:46 +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
52
manage
52
manage
|
@ -65,7 +65,7 @@ while IFS= read -r line; do
|
||||||
if [ "$line" != "tests/unit/settings/syntaxerror_settings.yml" ]; then
|
if [ "$line" != "tests/unit/settings/syntaxerror_settings.yml" ]; then
|
||||||
YAMLLINT_FILES+=("$line")
|
YAMLLINT_FILES+=("$line")
|
||||||
fi
|
fi
|
||||||
done <<< "$(git ls-files './tests/*.yml' './searx/*.yml' './utils/templates/etc/searxng/*.yml' '.github/*.yml' '.github/*/*.yml')"
|
done <<<"$(git ls-files './tests/*.yml' './searx/*.yml' './utils/templates/etc/searxng/*.yml' '.github/*.yml' '.github/*/*.yml')"
|
||||||
|
|
||||||
RST_FILES=(
|
RST_FILES=(
|
||||||
'README.rst'
|
'README.rst'
|
||||||
|
@ -113,7 +113,6 @@ environment ...
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if [ "$VERBOSE" = "1" ]; then
|
if [ "$VERBOSE" = "1" ]; then
|
||||||
SPHINX_VERBOSE="-v"
|
SPHINX_VERBOSE="-v"
|
||||||
PYLINT_VERBOSE="-v"
|
PYLINT_VERBOSE="-v"
|
||||||
|
@ -126,14 +125,14 @@ webapp.run() {
|
||||||
local parent_proc="$$"
|
local parent_proc="$$"
|
||||||
(
|
(
|
||||||
if [ "${LIVE_THEME}" ]; then
|
if [ "${LIVE_THEME}" ]; then
|
||||||
( themes.live "${LIVE_THEME}" )
|
(themes.live "${LIVE_THEME}")
|
||||||
kill $parent_proc
|
kill $parent_proc
|
||||||
fi
|
fi
|
||||||
)&
|
) &
|
||||||
(
|
(
|
||||||
sleep 3
|
sleep 3
|
||||||
xdg-open http://127.0.0.1:8888/
|
xdg-open http://127.0.0.1:8888/
|
||||||
)&
|
) &
|
||||||
SEARXNG_DEBUG=1 pyenv.cmd python -m searx.webapp
|
SEARXNG_DEBUG=1 pyenv.cmd python -m searx.webapp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,10 +142,11 @@ gecko.driver() {
|
||||||
|
|
||||||
build_msg INSTALL "gecko.driver"
|
build_msg INSTALL "gecko.driver"
|
||||||
# run installation in a subprocess and activate pyenv
|
# run installation in a subprocess and activate pyenv
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
|
|
||||||
INSTALLED_VERSION=$(geckodriver -V 2> /dev/null | head -1 | awk '{ print "v" $2}') || INSTALLED_VERSION=""
|
INSTALLED_VERSION=$(geckodriver -V 2>/dev/null | head -1 | awk '{ print "v" $2}') || INSTALLED_VERSION=""
|
||||||
set +e
|
set +e
|
||||||
if [ "${INSTALLED_VERSION}" = "${GECKODRIVER_VERSION}" ]; then
|
if [ "${INSTALLED_VERSION}" = "${GECKODRIVER_VERSION}" ]; then
|
||||||
build_msg INSTALL "geckodriver already installed"
|
build_msg INSTALL "geckodriver already installed"
|
||||||
|
@ -154,13 +154,13 @@ gecko.driver() {
|
||||||
fi
|
fi
|
||||||
PLATFORM="$(python -c 'import platform; print(platform.system().lower(), platform.architecture()[0])')"
|
PLATFORM="$(python -c 'import platform; print(platform.system().lower(), platform.architecture()[0])')"
|
||||||
case "$PLATFORM" in
|
case "$PLATFORM" in
|
||||||
"linux 32bit" | "linux2 32bit") ARCH="linux32";;
|
"linux 32bit" | "linux2 32bit") ARCH="linux32" ;;
|
||||||
"linux 64bit" | "linux2 64bit") ARCH="linux64";;
|
"linux 64bit" | "linux2 64bit") ARCH="linux64" ;;
|
||||||
"windows 32 bit") ARCH="win32";;
|
"windows 32 bit") ARCH="win32" ;;
|
||||||
"windows 64 bit") ARCH="win64";;
|
"windows 64 bit") ARCH="win64" ;;
|
||||||
"mac 64bit") ARCH="macos";;
|
"mac 64bit") ARCH="macos" ;;
|
||||||
esac
|
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"
|
build_msg GECKO "Installing ${PY_ENV_BIN}/geckodriver from $GECKODRIVER_URL"
|
||||||
|
|
||||||
|
@ -181,7 +181,8 @@ py.build() {
|
||||||
|
|
||||||
py.clean() {
|
py.clean() {
|
||||||
build_msg CLEAN pyenv
|
build_msg CLEAN pyenv
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.drop
|
pyenv.drop
|
||||||
[ "$VERBOSE" = "1" ] && set -x
|
[ "$VERBOSE" = "1" ] && set -x
|
||||||
rm -rf "${PYDIST}" "${PYBUILD}" "${PY_ENV}" ./.tox ./*.egg-info
|
rm -rf "${PYDIST}" "${PYBUILD}" "${PY_ENV}" ./.tox ./*.egg-info
|
||||||
|
@ -201,13 +202,14 @@ EOF
|
||||||
pyenv.install() {
|
pyenv.install() {
|
||||||
|
|
||||||
if ! pyenv.OK; then
|
if ! pyenv.OK; then
|
||||||
py.clean > /dev/null
|
py.clean >/dev/null
|
||||||
fi
|
fi
|
||||||
if pyenv.install.OK > /dev/null; then
|
if pyenv.install.OK >/dev/null; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv
|
pyenv
|
||||||
build_msg PYENV "[install] pip install --use-pep517 --no-build-isolation -e 'searx${PY_SETUP_EXTRAS}'"
|
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}"
|
"${PY_ENV_BIN}/python" -m pip install --use-pep517 --no-build-isolation -e ".${PY_SETUP_EXTRAS}"
|
||||||
|
@ -220,8 +222,8 @@ pyenv.install() {
|
||||||
|
|
||||||
pyenv.uninstall() {
|
pyenv.uninstall() {
|
||||||
build_msg PYENV "[pyenv.uninstall] uninstall packages: ${PYOBJECTS}"
|
build_msg PYENV "[pyenv.uninstall] uninstall packages: ${PYOBJECTS}"
|
||||||
pyenv.cmd python setup.py develop --uninstall 2>&1 \
|
pyenv.cmd python setup.py develop --uninstall 2>&1 |
|
||||||
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +245,7 @@ docs.prebuild() {
|
||||||
set -e
|
set -e
|
||||||
[ "$VERBOSE" = "1" ] && set -x
|
[ "$VERBOSE" = "1" ] && set -x
|
||||||
mkdir -p "${DOCS_BUILD}/includes"
|
mkdir -p "${DOCS_BUILD}/includes"
|
||||||
./utils/searxng.sh searxng.doc.rst > "${DOCS_BUILD}/includes/searxng.rst"
|
./utils/searxng.sh searxng.doc.rst >"${DOCS_BUILD}/includes/searxng.rst"
|
||||||
pyenv.cmd searxng_extra/docs_prebuild
|
pyenv.cmd searxng_extra/docs_prebuild
|
||||||
)
|
)
|
||||||
dump_return $?
|
dump_return $?
|
||||||
|
@ -253,7 +255,8 @@ docs.prebuild() {
|
||||||
main() {
|
main() {
|
||||||
|
|
||||||
local _type
|
local _type
|
||||||
local cmd="$1"; shift
|
local cmd="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
if [ "$cmd" == "" ]; then
|
if [ "$cmd" == "" ]; then
|
||||||
help
|
help
|
||||||
|
@ -262,8 +265,11 @@ main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
--getenv) var="$1"; echo "${!var}";;
|
--getenv)
|
||||||
--help) help;;
|
var="$1"
|
||||||
|
echo "${!var}"
|
||||||
|
;;
|
||||||
|
--help) help ;;
|
||||||
--*)
|
--*)
|
||||||
help
|
help
|
||||||
err_msg "unknown option $cmd"
|
err_msg "unknown option $cmd"
|
||||||
|
|
|
@ -8,11 +8,11 @@ build.env.export() {
|
||||||
GIT_BRANCH="$(git branch | grep '\*' | cut -d' ' -f2-)"
|
GIT_BRANCH="$(git branch | grep '\*' | cut -d' ' -f2-)"
|
||||||
GIT_REMOTE="$(git config "branch.${GIT_BRANCH}.remote")"
|
GIT_REMOTE="$(git config "branch.${GIT_BRANCH}.remote")"
|
||||||
GIT_URL="$(git config --get "remote.${GIT_REMOTE}.url")"
|
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_URL="${GIT_URL/git@/https://}"
|
GIT_URL="${GIT_URL/git@/https://}"
|
||||||
fi
|
fi
|
||||||
if [[ "${GIT_URL}" == *.git ]]; then
|
if [[ ${GIT_URL} == *.git ]]; then
|
||||||
GIT_URL="${GIT_URL%.git}"
|
GIT_URL="${GIT_URL%.git}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -27,6 +27,6 @@ build.env.export() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pushd "${REPO_ROOT}" &> /dev/null
|
pushd "${REPO_ROOT}" &>/dev/null
|
||||||
build.env.export
|
build.env.export
|
||||||
popd &> /dev/null
|
popd &>/dev/null
|
||||||
|
|
293
utils/lib.sh
293
utils/lib.sh
|
@ -4,11 +4,20 @@
|
||||||
# shellcheck disable=SC2059,SC1117
|
# shellcheck disable=SC2059,SC1117
|
||||||
|
|
||||||
# ubuntu, debian, arch, fedora, centos ...
|
# ubuntu, debian, arch, fedora, centos ...
|
||||||
DIST_ID=$(source /etc/os-release; echo "$ID");
|
DIST_ID=$(
|
||||||
|
source /etc/os-release
|
||||||
|
echo "$ID"
|
||||||
|
)
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
DIST_VERS=$(source /etc/os-release; echo "$VERSION_ID");
|
DIST_VERS=$(
|
||||||
|
source /etc/os-release
|
||||||
|
echo "$VERSION_ID"
|
||||||
|
)
|
||||||
# shellcheck disable=SC2034
|
# 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:-$(git config user.name)}"
|
||||||
ADMIN_NAME="${ADMIN_NAME:-$USER}"
|
ADMIN_NAME="${ADMIN_NAME:-$USER}"
|
||||||
|
@ -16,19 +25,19 @@ ADMIN_NAME="${ADMIN_NAME:-$USER}"
|
||||||
ADMIN_EMAIL="${ADMIN_EMAIL:-$(git config user.email)}"
|
ADMIN_EMAIL="${ADMIN_EMAIL:-$(git config user.email)}"
|
||||||
ADMIN_EMAIL="${ADMIN_EMAIL:-$USER@$(hostname)}"
|
ADMIN_EMAIL="${ADMIN_EMAIL:-$USER@$(hostname)}"
|
||||||
|
|
||||||
if [[ -z "${REPO_ROOT}" ]]; then
|
if [[ -z ${REPO_ROOT} ]]; then
|
||||||
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")
|
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")
|
||||||
while [ -h "${REPO_ROOT}" ] ; do
|
while [ -h "${REPO_ROOT}" ]; do
|
||||||
REPO_ROOT=$(readlink "${REPO_ROOT}")
|
REPO_ROOT=$(readlink "${REPO_ROOT}")
|
||||||
done
|
done
|
||||||
REPO_ROOT=$(cd "${REPO_ROOT}/.." && pwd -P )
|
REPO_ROOT=$(cd "${REPO_ROOT}/.." && pwd -P)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z ${TEMPLATES} ]]; then
|
if [[ -z ${TEMPLATES} ]]; then
|
||||||
TEMPLATES="${REPO_ROOT}/utils/templates"
|
TEMPLATES="${REPO_ROOT}/utils/templates"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$CACHE" ]]; then
|
if [[ -z $CACHE ]]; then
|
||||||
CACHE="${REPO_ROOT}/cache"
|
CACHE="${REPO_ROOT}/cache"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -42,7 +51,7 @@ fi
|
||||||
DOT_CONFIG="${DOT_CONFIG:-${REPO_ROOT}/.config.sh}"
|
DOT_CONFIG="${DOT_CONFIG:-${REPO_ROOT}/.config.sh}"
|
||||||
|
|
||||||
source_dot_config() {
|
source_dot_config() {
|
||||||
if [[ ! -e "${DOT_CONFIG}" ]]; then
|
if [[ ! -e ${DOT_CONFIG} ]]; then
|
||||||
err_msg "configuration does not exists at: ${DOT_CONFIG}"
|
err_msg "configuration does not exists at: ${DOT_CONFIG}"
|
||||||
return 42
|
return 42
|
||||||
fi
|
fi
|
||||||
|
@ -128,9 +137,9 @@ rst_title() {
|
||||||
# usage: rst_title <header-text> [part|chapter|section]
|
# usage: rst_title <header-text> [part|chapter|section]
|
||||||
|
|
||||||
case ${2-chapter} in
|
case ${2-chapter} in
|
||||||
part) printf "\n${_BGreen}${1//?/=}${_creset}\n${_BCyan}${1}${_creset}\n${_BGreen}${1//?/=}${_creset}\n";;
|
part) printf "\n${_BGreen}${1//?/=}${_creset}\n${_BCyan}${1}${_creset}\n${_BGreen}${1//?/=}${_creset}\n" ;;
|
||||||
chapter) printf "\n${_BCyan}${1}${_creset}\n${_BGreen}${1//?/=}${_creset}\n";;
|
chapter) printf "\n${_BCyan}${1}${_creset}\n${_BGreen}${1//?/=}${_creset}\n" ;;
|
||||||
section) printf "\n${_BCyan}${1}${_creset}\n${_BGreen}${1//?/-}${_creset}\n";;
|
section) printf "\n${_BCyan}${1}${_creset}\n${_BGreen}${1//?/-}${_creset}\n" ;;
|
||||||
*)
|
*)
|
||||||
err_msg "invalid argument '${2}' in line $(caller)"
|
err_msg "invalid argument '${2}' in line $(caller)"
|
||||||
return 42
|
return 42
|
||||||
|
@ -150,12 +159,12 @@ rst_para() {
|
||||||
}
|
}
|
||||||
|
|
||||||
die() {
|
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}"
|
exit "${1-1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
die_caller() {
|
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}"
|
exit "${1-1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,17 +190,17 @@ dump_return() {
|
||||||
|
|
||||||
clean_stdin() {
|
clean_stdin() {
|
||||||
if [[ $(uname -s) != 'Darwin' ]]; then
|
if [[ $(uname -s) != 'Darwin' ]]; then
|
||||||
while read -r -n1 -t 0.1; do : ; done
|
while read -r -n1 -t 0.1; do :; done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_key(){
|
wait_key() {
|
||||||
# usage: wait_key [<timeout in sec>]
|
# usage: wait_key [<timeout in sec>]
|
||||||
|
|
||||||
clean_stdin
|
clean_stdin
|
||||||
local _t=$1
|
local _t=$1
|
||||||
local msg="${MSG}"
|
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 $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
|
||||||
[[ -n $_t ]] && _t="-t $_t"
|
[[ -n $_t ]] && _t="-t $_t"
|
||||||
|
@ -233,7 +242,8 @@ ask_yn() {
|
||||||
# shellcheck disable=SC2086,SC2229
|
# shellcheck disable=SC2086,SC2229
|
||||||
read -r -n1 $_t
|
read -r -n1 $_t
|
||||||
if [[ -z $REPLY ]]; then
|
if [[ -z $REPLY ]]; then
|
||||||
printf "$default\n"; break
|
printf "$default\n"
|
||||||
|
break
|
||||||
elif [[ $REPLY =~ ^[Yy]$ ]]; then
|
elif [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
exit_val=${EXIT_YES}
|
exit_val=${EXIT_YES}
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
@ -250,7 +260,7 @@ ask_yn() {
|
||||||
return $exit_val
|
return $exit_val
|
||||||
}
|
}
|
||||||
|
|
||||||
tee_stderr () {
|
tee_stderr() {
|
||||||
|
|
||||||
# usage::
|
# usage::
|
||||||
# tee_stderr 1 <<EOF | python -i
|
# tee_stderr 1 <<EOF | python -i
|
||||||
|
@ -260,8 +270,8 @@ tee_stderr () {
|
||||||
# >>> print("hello")
|
# >>> print("hello")
|
||||||
# hello
|
# hello
|
||||||
|
|
||||||
local _t="0";
|
local _t="0"
|
||||||
if [[ -n $1 ]] ; then _t="$1"; fi
|
if [[ -n $1 ]]; then _t="$1"; fi
|
||||||
|
|
||||||
(while read -r line; do
|
(while read -r line; do
|
||||||
# shellcheck disable=SC2086,SC2229
|
# shellcheck disable=SC2086,SC2229
|
||||||
|
@ -271,12 +281,12 @@ tee_stderr () {
|
||||||
done)
|
done)
|
||||||
}
|
}
|
||||||
|
|
||||||
prefix_stdout () {
|
prefix_stdout() {
|
||||||
# usage: <cmd> | prefix_stdout [prefix]
|
# usage: <cmd> | prefix_stdout [prefix]
|
||||||
|
|
||||||
local prefix="${_BYellow}-->|${_creset}"
|
local prefix="${_BYellow}-->|${_creset}"
|
||||||
|
|
||||||
if [[ -n $1 ]] ; then prefix="$1"; fi
|
if [[ -n $1 ]]; then prefix="$1"; fi
|
||||||
|
|
||||||
# shellcheck disable=SC2162
|
# shellcheck disable=SC2162
|
||||||
(while IFS= read line; do
|
(while IFS= read line; do
|
||||||
|
@ -296,7 +306,7 @@ append_line() {
|
||||||
|
|
||||||
local LINE=$1
|
local LINE=$1
|
||||||
local FILE=$2
|
local FILE=$2
|
||||||
grep -qFs -- "$LINE" "$FILE" || echo "$LINE" >> "$FILE"
|
grep -qFs -- "$LINE" "$FILE" || echo "$LINE" >>"$FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_download() {
|
cache_download() {
|
||||||
|
@ -311,7 +321,7 @@ cache_download() {
|
||||||
mkdir -p "${CACHE}"
|
mkdir -p "${CACHE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "${CACHE}/$2" ]] ; then
|
if [[ -f "${CACHE}/$2" ]]; then
|
||||||
info_msg "already cached: $1"
|
info_msg "already cached: $1"
|
||||||
info_msg " --> ${CACHE}/$2"
|
info_msg " --> ${CACHE}/$2"
|
||||||
fi
|
fi
|
||||||
|
@ -320,11 +330,13 @@ cache_download() {
|
||||||
info_msg "caching: $1"
|
info_msg "caching: $1"
|
||||||
info_msg " --> ${CACHE}/$2"
|
info_msg " --> ${CACHE}/$2"
|
||||||
if [[ -n ${SUDO_USER} ]]; then
|
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
|
else
|
||||||
wget --progress=bar -O "${CACHE}/$2" "$1" ; exit_value=$?
|
wget --progress=bar -O "${CACHE}/$2" "$1"
|
||||||
|
exit_value=$?
|
||||||
fi
|
fi
|
||||||
if [[ ! $exit_value = 0 ]]; then
|
if [[ $exit_value != 0 ]]; then
|
||||||
err_msg "failed to download: $1"
|
err_msg "failed to download: $1"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -350,7 +362,7 @@ choose_one() {
|
||||||
local default=${DEFAULT_SELECT-1}
|
local default=${DEFAULT_SELECT-1}
|
||||||
local REPLY
|
local REPLY
|
||||||
local env_name=$1 && shift
|
local env_name=$1 && shift
|
||||||
local choice=$1;
|
local choice=$1
|
||||||
local max="${#@}"
|
local max="${#@}"
|
||||||
local _t
|
local _t
|
||||||
[[ -n $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
|
[[ -n $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
|
||||||
|
@ -358,8 +370,8 @@ choose_one() {
|
||||||
|
|
||||||
list=("$@")
|
list=("$@")
|
||||||
echo -e "${_BGreen}Menu::${_creset}"
|
echo -e "${_BGreen}Menu::${_creset}"
|
||||||
for ((i=1; i<= $((max -1)); i++)); do
|
for ((i = 1; i <= $((max - 1)); i++)); do
|
||||||
if [[ "$i" == "$default" ]]; then
|
if [[ $i == "$default" ]]; then
|
||||||
echo -e " ${_BGreen}$i.${_creset}) ${list[$i]} [default]"
|
echo -e " ${_BGreen}$i.${_creset}) ${list[$i]} [default]"
|
||||||
else
|
else
|
||||||
echo -e " $i.) ${list[$i]}"
|
echo -e " $i.) ${list[$i]}"
|
||||||
|
@ -369,7 +381,7 @@ choose_one() {
|
||||||
clean_stdin
|
clean_stdin
|
||||||
printf "$1 [${_BGreen}$default${_creset}] "
|
printf "$1 [${_BGreen}$default${_creset}] "
|
||||||
|
|
||||||
if (( 10 > max )); then
|
if ((10 > max)); then
|
||||||
# shellcheck disable=SC2086,SC2229
|
# shellcheck disable=SC2086,SC2229
|
||||||
read -r -n1 $_t
|
read -r -n1 $_t
|
||||||
else
|
else
|
||||||
|
@ -377,7 +389,7 @@ choose_one() {
|
||||||
read -r $_t
|
read -r $_t
|
||||||
fi
|
fi
|
||||||
# selection fits
|
# selection fits
|
||||||
[[ $REPLY =~ ^-?[0-9]+$ ]] && (( REPLY > 0 )) && (( REPLY < max )) && break
|
[[ $REPLY =~ ^-?[0-9]+$ ]] && ((REPLY > 0)) && ((REPLY < max)) && break
|
||||||
|
|
||||||
# take default
|
# take default
|
||||||
[[ -z $REPLY ]] && REPLY=$default && break
|
[[ -z $REPLY ]] && REPLY=$default && break
|
||||||
|
@ -414,8 +426,14 @@ install_template() {
|
||||||
|
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
case $i in
|
case $i in
|
||||||
--no-eval) do_eval=0; shift ;;
|
--no-eval)
|
||||||
--variant=*) variant=":${i#*=}"; shift ;;
|
do_eval=0
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--variant=*)
|
||||||
|
variant=":${i#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*) pos_args+=("$i") ;;
|
*) pos_args+=("$i") ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -431,14 +449,14 @@ install_template() {
|
||||||
info_msg "install (eval=$do_eval): ${dst}"
|
info_msg "install (eval=$do_eval): ${dst}"
|
||||||
[[ -n $variant ]] && info_msg "variant --> ${variant}"
|
[[ -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 "${template_origin} does not exists"
|
||||||
err_msg "... can't install $dst"
|
err_msg "... can't install $dst"
|
||||||
wait_key 30
|
wait_key 30
|
||||||
return 42
|
return 42
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$do_eval" == "1" ]]; then
|
if [[ $do_eval == "1" ]]; then
|
||||||
template_file="${CACHE}${dst}${variant}"
|
template_file="${CACHE}${dst}${variant}"
|
||||||
info_msg "BUILD ${template_file}"
|
info_msg "BUILD ${template_file}"
|
||||||
info_msg "BUILD using template ${template_origin}"
|
info_msg "BUILD using template ${template_origin}"
|
||||||
|
@ -448,7 +466,7 @@ install_template() {
|
||||||
mkdir -p "$(dirname "${template_file}")"
|
mkdir -p "$(dirname "${template_file}")"
|
||||||
fi
|
fi
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
eval "echo \"$(cat ${template_origin})\"" > "${template_file}"
|
eval "echo \"$(cat ${template_origin})\"" >"${template_file}"
|
||||||
if [[ -n ${SUDO_USER} ]]; then
|
if [[ -n ${SUDO_USER} ]]; then
|
||||||
chown "${SUDO_USER}:${SUDO_USER}" "${template_file}"
|
chown "${SUDO_USER}:${SUDO_USER}" "${template_file}"
|
||||||
fi
|
fi
|
||||||
|
@ -458,14 +476,14 @@ install_template() {
|
||||||
|
|
||||||
mkdir -p "$(dirname "${dst}")"
|
mkdir -p "$(dirname "${dst}")"
|
||||||
|
|
||||||
if [[ ! -f "${dst}" ]]; then
|
if [[ ! -f ${dst} ]]; then
|
||||||
info_msg "install: ${template_file}"
|
info_msg "install: ${template_file}"
|
||||||
sudo -H install -v -o "${owner}" -g "${group}" -m "${chmod}" \
|
sudo -H install -v -o "${owner}" -g "${group}" -m "${chmod}" \
|
||||||
"${template_file}" "${dst}" | prefix_stdout
|
"${template_file}" "${dst}" | prefix_stdout
|
||||||
return $?
|
return $?
|
||||||
fi
|
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"
|
info_msg "file ${dst} already installed"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -503,6 +521,7 @@ install_template() {
|
||||||
;;
|
;;
|
||||||
"diff files")
|
"diff files")
|
||||||
$DIFF_CMD "${dst}" "${template_file}" | prefix_stdout
|
$DIFF_CMD "${dst}" "${template_file}" | prefix_stdout
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -517,11 +536,11 @@ service_is_available() {
|
||||||
--silent -o /dev/null --head --write-out '%{http_code}' --insecure \
|
--silent -o /dev/null --head --write-out '%{http_code}' --insecure \
|
||||||
"${URL}")
|
"${URL}")
|
||||||
exit_val=$?
|
exit_val=$?
|
||||||
if [[ $exit_val = 0 ]]; then
|
if [[ $exit_val == 0 ]]; then
|
||||||
info_msg "got $http_code from ${URL}"
|
info_msg "got $http_code from ${URL}"
|
||||||
fi
|
fi
|
||||||
case "$http_code" in
|
case "$http_code" in
|
||||||
404|410|423) exit_val=$http_code;;
|
404 | 410 | 423) exit_val=$http_code ;;
|
||||||
esac
|
esac
|
||||||
return "$exit_val"
|
return "$exit_val"
|
||||||
}
|
}
|
||||||
|
@ -549,7 +568,7 @@ PYBUILD="${PYBUILD:=build/py${PY}}"
|
||||||
#PY_SETUP_EXTRAS='[develop,test]'
|
#PY_SETUP_EXTRAS='[develop,test]'
|
||||||
PY_SETUP_EXTRAS="${PY_SETUP_EXTRAS:=[develop,test]}"
|
PY_SETUP_EXTRAS="${PY_SETUP_EXTRAS:=[develop,test]}"
|
||||||
|
|
||||||
PIP_BOILERPLATE=( pip wheel setuptools )
|
PIP_BOILERPLATE=(pip wheel setuptools)
|
||||||
|
|
||||||
# shellcheck disable=SC2120
|
# shellcheck disable=SC2120
|
||||||
pyenv() {
|
pyenv() {
|
||||||
|
@ -563,28 +582,28 @@ pyenv() {
|
||||||
# files.
|
# files.
|
||||||
|
|
||||||
required_commands \
|
required_commands \
|
||||||
sha256sum "${PYTHON}" \
|
sha256sum "${PYTHON}" ||
|
||||||
|| exit
|
exit
|
||||||
|
|
||||||
local pip_req=()
|
local pip_req=()
|
||||||
|
|
||||||
if ! pyenv.OK > /dev/null; then
|
if ! pyenv.OK >/dev/null; then
|
||||||
rm -f "${PY_ENV}/${PY_ENV_REQ}.sha256"
|
rm -f "${PY_ENV}/${PY_ENV_REQ}.sha256"
|
||||||
pyenv.drop > /dev/null
|
pyenv.drop >/dev/null
|
||||||
build_msg PYENV "[virtualenv] installing ${PY_ENV_REQ} into ${PY_ENV}"
|
build_msg PYENV "[virtualenv] installing ${PY_ENV_REQ} into ${PY_ENV}"
|
||||||
|
|
||||||
"${PYTHON}" -m venv "$@" "${PY_ENV}"
|
"${PYTHON}" -m venv "$@" "${PY_ENV}"
|
||||||
"${PY_ENV_BIN}/python" -m pip install -U "${PIP_BOILERPLATE[@]}"
|
"${PY_ENV_BIN}/python" -m pip install -U "${PIP_BOILERPLATE[@]}"
|
||||||
|
|
||||||
for i in ${PY_ENV_REQ}; do
|
for i in ${PY_ENV_REQ}; do
|
||||||
pip_req=( "${pip_req[@]}" "-r" "$i" )
|
pip_req=("${pip_req[@]}" "-r" "$i")
|
||||||
done
|
done
|
||||||
|
|
||||||
(
|
(
|
||||||
[ "$VERBOSE" = "1" ] && set -x
|
[ "$VERBOSE" = "1" ] && set -x
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
"${PY_ENV_BIN}/python" -m pip install "${pip_req[@]}" \
|
"${PY_ENV_BIN}/python" -m pip install "${pip_req[@]}" &&
|
||||||
&& sha256sum ${PY_ENV_REQ} > "${PY_ENV}/requirements.sha256"
|
sha256sum ${PY_ENV_REQ} >"${PY_ENV}/requirements.sha256"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
pyenv.OK
|
pyenv.OK
|
||||||
|
@ -602,17 +621,17 @@ pyenv.OK() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "${PY_ENV}/requirements.sha256" ] \
|
if [ ! -f "${PY_ENV}/requirements.sha256" ] ||
|
||||||
|| ! sha256sum -c "${PY_ENV}/requirements.sha256" > /dev/null 2>&1; then
|
! sha256sum -c "${PY_ENV}/requirements.sha256" >/dev/null 2>&1; then
|
||||||
build_msg PYENV "[virtualenv] requirements.sha256 failed"
|
build_msg PYENV "[virtualenv] requirements.sha256 failed"
|
||||||
sed 's/^/ [virtualenv] - /' <"${PY_ENV}/requirements.sha256"
|
sed 's/^/ [virtualenv] - /' <"${PY_ENV}/requirements.sha256"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$VERBOSE" = "1" ]; then
|
if [ "$VERBOSE" = "1" ]; then
|
||||||
pyenv.check \
|
pyenv.check |
|
||||||
| "${PY_ENV_BIN}/python" 2>&1 \
|
"${PY_ENV_BIN}/python" 2>&1 |
|
||||||
| prefix_stdout "${_Blue}PYENV ${_creset}[check] "
|
prefix_stdout "${_Blue}PYENV ${_creset}[check] "
|
||||||
else
|
else
|
||||||
pyenv.check | "${PY_ENV_BIN}/python" 1>/dev/null
|
pyenv.check | "${PY_ENV_BIN}/python" 1>/dev/null
|
||||||
fi
|
fi
|
||||||
|
@ -657,9 +676,9 @@ EOF
|
||||||
pyenv.install() {
|
pyenv.install() {
|
||||||
|
|
||||||
if ! pyenv.OK; then
|
if ! pyenv.OK; then
|
||||||
py.clean > /dev/null
|
py.clean >/dev/null
|
||||||
fi
|
fi
|
||||||
if ! pyenv.install.OK > /dev/null; then
|
if ! pyenv.install.OK >/dev/null; then
|
||||||
build_msg PYENV "[install] ${PYOBJECTS}"
|
build_msg PYENV "[install] ${PYOBJECTS}"
|
||||||
if ! pyenv.OK >/dev/null; then
|
if ! pyenv.OK >/dev/null; then
|
||||||
pyenv
|
pyenv
|
||||||
|
@ -708,19 +727,19 @@ pyenv.uninstall() {
|
||||||
build_msg PYENV "[uninstall] ${PYOBJECTS}"
|
build_msg PYENV "[uninstall] ${PYOBJECTS}"
|
||||||
|
|
||||||
if [ "." = "${PYOBJECTS}" ]; then
|
if [ "." = "${PYOBJECTS}" ]; then
|
||||||
pyenv.cmd python setup.py develop --uninstall 2>&1 \
|
pyenv.cmd python setup.py develop --uninstall 2>&1 |
|
||||||
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||||
else
|
else
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
pyenv.cmd python -m pip uninstall --yes ${PYOBJECTS} 2>&1 \
|
pyenv.cmd python -m pip uninstall --yes ${PYOBJECTS} 2>&1 |
|
||||||
| prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pyenv.cmd() {
|
pyenv.cmd() {
|
||||||
pyenv.install
|
pyenv.install
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "${PY_ENV_BIN}/activate"
|
source "${PY_ENV_BIN}/activate"
|
||||||
[ "$VERBOSE" = "1" ] && set -x
|
[ "$VERBOSE" = "1" ] && set -x
|
||||||
|
@ -728,14 +747,12 @@ pyenv.cmd() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pyenv.activate() {
|
pyenv.activate() {
|
||||||
pyenv.install
|
pyenv.install
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "${PY_ENV_BIN}/activate"
|
source "${PY_ENV_BIN}/activate"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Sphinx doc
|
# Sphinx doc
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
|
@ -804,25 +821,25 @@ docs.gh-pages() {
|
||||||
(
|
(
|
||||||
git worktree remove -f "${GH_PAGES}"
|
git worktree remove -f "${GH_PAGES}"
|
||||||
git branch -D gh-pages
|
git branch -D gh-pages
|
||||||
) &> /dev/null || true
|
) &>/dev/null || true
|
||||||
git worktree add --no-checkout "${GH_PAGES}" "${remote}/master"
|
git worktree add --no-checkout "${GH_PAGES}" "${remote}/master"
|
||||||
|
|
||||||
pushd "${GH_PAGES}" &> /dev/null
|
pushd "${GH_PAGES}" &>/dev/null
|
||||||
git checkout --orphan gh-pages
|
git checkout --orphan gh-pages
|
||||||
git rm -rfq .
|
git rm -rfq .
|
||||||
popd &> /dev/null
|
popd &>/dev/null
|
||||||
|
|
||||||
cp -r "${DOCS_DIST}"/* "${GH_PAGES}"/
|
cp -r "${DOCS_DIST}"/* "${GH_PAGES}"/
|
||||||
touch "${GH_PAGES}/.nojekyll"
|
touch "${GH_PAGES}/.nojekyll"
|
||||||
cat > "${GH_PAGES}/404.html" <<EOF
|
cat >"${GH_PAGES}/404.html" <<EOF
|
||||||
<html><head><META http-equiv='refresh' content='0;URL=index.html'></head></html>
|
<html><head><META http-equiv='refresh' content='0;URL=index.html'></head></html>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
pushd "${GH_PAGES}" &> /dev/null
|
pushd "${GH_PAGES}" &>/dev/null
|
||||||
git add --all .
|
git add --all .
|
||||||
git commit -q -m "gh-pages build from: ${branch}@${head} (${remote_url})"
|
git commit -q -m "gh-pages build from: ${branch}@${head} (${remote_url})"
|
||||||
git push -f "${remote}" gh-pages
|
git push -f "${remote}" gh-pages
|
||||||
popd &> /dev/null
|
popd &>/dev/null
|
||||||
|
|
||||||
set +x
|
set +x
|
||||||
build_msg GH-PAGES "deployed"
|
build_msg GH-PAGES "deployed"
|
||||||
|
@ -850,7 +867,7 @@ drop_service_account() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
interactive_shell(){
|
interactive_shell() {
|
||||||
|
|
||||||
# usage: interactive_shell "${SERVICE_USER}"
|
# usage: interactive_shell "${SERVICE_USER}"
|
||||||
|
|
||||||
|
@ -858,7 +875,6 @@ interactive_shell(){
|
||||||
sudo -H -u "${1}" -i
|
sudo -H -u "${1}" -i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# systemd
|
# systemd
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
|
@ -927,7 +943,6 @@ systemctl status --no-pager ${1}.service
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# nginx
|
# nginx
|
||||||
# -----
|
# -----
|
||||||
|
|
||||||
|
@ -945,14 +960,14 @@ nginx_distro_setup() {
|
||||||
NGINX_APPS_AVAILABLE="/etc/nginx/default.apps-available"
|
NGINX_APPS_AVAILABLE="/etc/nginx/default.apps-available"
|
||||||
|
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
NGINX_PACKAGES="nginx"
|
NGINX_PACKAGES="nginx"
|
||||||
NGINX_DEFAULT_SERVER=/etc/nginx/sites-available/default
|
NGINX_DEFAULT_SERVER=/etc/nginx/sites-available/default
|
||||||
;;
|
;;
|
||||||
arch-*)
|
arch-*)
|
||||||
NGINX_PACKAGES="nginx-mainline"
|
NGINX_PACKAGES="nginx-mainline"
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
NGINX_PACKAGES="nginx"
|
NGINX_PACKAGES="nginx"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -961,11 +976,11 @@ nginx_distro_setup() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
install_nginx(){
|
install_nginx() {
|
||||||
info_msg "installing nginx ..."
|
info_msg "installing nginx ..."
|
||||||
pkg_install "${NGINX_PACKAGES}"
|
pkg_install "${NGINX_PACKAGES}"
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
arch-*|fedora-*|centos-7)
|
arch-* | fedora-* | centos-7)
|
||||||
systemctl enable nginx
|
systemctl enable nginx
|
||||||
systemctl start nginx
|
systemctl start nginx
|
||||||
;;
|
;;
|
||||||
|
@ -998,8 +1013,8 @@ nginx_install_app() {
|
||||||
|
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
case $i in
|
case $i in
|
||||||
-*) template_opts+=("$i");;
|
-*) template_opts+=("$i") ;;
|
||||||
*) pos_args+=("$i");;
|
*) pos_args+=("$i") ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1042,23 +1057,22 @@ nginx_include_apps_enabled() {
|
||||||
(
|
(
|
||||||
local line
|
local line
|
||||||
local stage=0
|
local stage=0
|
||||||
while IFS= read -r line
|
while IFS= read -r line; do
|
||||||
do
|
|
||||||
echo "$line"
|
echo "$line"
|
||||||
if [[ $stage = 0 ]]; then
|
if [[ $stage == 0 ]]; then
|
||||||
if [[ $line =~ ^[[:space:]]*server*[[:space:]]*\{ ]]; then
|
if [[ $line =~ ^[[:space:]]*server*[[:space:]]*\{ ]]; then
|
||||||
stage=1
|
stage=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $stage = 1 ]]; then
|
if [[ $stage == 1 ]]; then
|
||||||
echo " # Load configuration files for the default server block."
|
echo " # Load configuration files for the default server block."
|
||||||
echo " $include_directive"
|
echo " $include_directive"
|
||||||
echo ""
|
echo ""
|
||||||
stage=2
|
stage=2
|
||||||
fi
|
fi
|
||||||
done < "${server_conf}.bak"
|
done <"${server_conf}.bak"
|
||||||
) > "${server_conf}"
|
) >"${server_conf}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,14 +1109,13 @@ nginx_disable_app() {
|
||||||
nginx_reload
|
nginx_reload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Apache
|
# Apache
|
||||||
# ------
|
# ------
|
||||||
|
|
||||||
apache_distro_setup() {
|
apache_distro_setup() {
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
# debian uses the /etc/apache2 path, while other distros use
|
# debian uses the /etc/apache2 path, while other distros use
|
||||||
# the apache default at /etc/httpd
|
# the apache default at /etc/httpd
|
||||||
APACHE_SITES_AVAILABLE="/etc/apache2/sites-available"
|
APACHE_SITES_AVAILABLE="/etc/apache2/sites-available"
|
||||||
|
@ -1116,7 +1129,7 @@ apache_distro_setup() {
|
||||||
APACHE_MODULES="modules"
|
APACHE_MODULES="modules"
|
||||||
APACHE_PACKAGES="apache"
|
APACHE_PACKAGES="apache"
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
APACHE_SITES_AVAILABLE="/etc/httpd/sites-available"
|
APACHE_SITES_AVAILABLE="/etc/httpd/sites-available"
|
||||||
APACHE_SITES_ENABLED="/etc/httpd/sites-enabled"
|
APACHE_SITES_ENABLED="/etc/httpd/sites-enabled"
|
||||||
APACHE_MODULES="modules"
|
APACHE_MODULES="modules"
|
||||||
|
@ -1128,13 +1141,13 @@ apache_distro_setup() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
install_apache(){
|
install_apache() {
|
||||||
info_msg "installing apache ..."
|
info_msg "installing apache ..."
|
||||||
pkg_install "$APACHE_PACKAGES"
|
pkg_install "$APACHE_PACKAGES"
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
arch-*|fedora-*|centos-7)
|
arch-* | fedora-* | centos-7)
|
||||||
if ! grep "IncludeOptional sites-enabled" "/etc/httpd/conf/httpd.conf"; then
|
if ! grep "IncludeOptional sites-enabled" "/etc/httpd/conf/httpd.conf"; then
|
||||||
echo "IncludeOptional sites-enabled/*.conf" >> "/etc/httpd/conf/httpd.conf"
|
echo "IncludeOptional sites-enabled/*.conf" >>"/etc/httpd/conf/httpd.conf"
|
||||||
fi
|
fi
|
||||||
systemctl enable httpd
|
systemctl enable httpd
|
||||||
systemctl start httpd
|
systemctl start httpd
|
||||||
|
@ -1144,9 +1157,9 @@ install_apache(){
|
||||||
|
|
||||||
apache_is_installed() {
|
apache_is_installed() {
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*) (command -v apachectl) &>/dev/null;;
|
ubuntu-* | debian-*) (command -v apachectl) &>/dev/null ;;
|
||||||
arch-*) (command -v httpd) &>/dev/null;;
|
arch-*) (command -v httpd) &>/dev/null ;;
|
||||||
fedora-*|centos-7) (command -v httpd) &>/dev/null;;
|
fedora-* | centos-7) (command -v httpd) &>/dev/null ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1155,11 +1168,11 @@ apache_reload() {
|
||||||
info_msg "reload apache .."
|
info_msg "reload apache .."
|
||||||
echo
|
echo
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
sudo -H apachectl configtest
|
sudo -H apachectl configtest
|
||||||
sudo -H systemctl force-reload apache2
|
sudo -H systemctl force-reload apache2
|
||||||
;;
|
;;
|
||||||
arch-*|fedora-*|centos-7)
|
arch-* | fedora-* | centos-7)
|
||||||
sudo -H httpd -t
|
sudo -H httpd -t
|
||||||
sudo -H systemctl force-reload httpd
|
sudo -H systemctl force-reload httpd
|
||||||
;;
|
;;
|
||||||
|
@ -1177,8 +1190,8 @@ apache_install_site() {
|
||||||
|
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
case $i in
|
case $i in
|
||||||
-*) template_opts+=("$i");;
|
-*) template_opts+=("$i") ;;
|
||||||
*) pos_args+=("$i");;
|
*) pos_args+=("$i") ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1207,7 +1220,7 @@ apache_enable_site() {
|
||||||
info_msg "enable apache site: ${CONF}"
|
info_msg "enable apache site: ${CONF}"
|
||||||
|
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
sudo -H a2ensite -q "${CONF}"
|
sudo -H a2ensite -q "${CONF}"
|
||||||
;;
|
;;
|
||||||
arch-*)
|
arch-*)
|
||||||
|
@ -1215,7 +1228,7 @@ apache_enable_site() {
|
||||||
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
|
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
|
||||||
ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
|
ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
mkdir -p "${APACHE_SITES_ENABLED}"
|
mkdir -p "${APACHE_SITES_ENABLED}"
|
||||||
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
|
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
|
||||||
ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
|
ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
|
||||||
|
@ -1233,13 +1246,13 @@ apache_disable_site() {
|
||||||
info_msg "disable apache site: ${CONF}"
|
info_msg "disable apache site: ${CONF}"
|
||||||
|
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
sudo -H a2dissite -q "${CONF}"
|
sudo -H a2dissite -q "${CONF}"
|
||||||
;;
|
;;
|
||||||
arch-*)
|
arch-*)
|
||||||
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
|
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
|
rm -f "${APACHE_SITES_ENABLED}/${CONF}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -1256,7 +1269,7 @@ uWSGI_SETUP="${uWSGI_SETUP:=/etc/uwsgi}"
|
||||||
|
|
||||||
uWSGI_distro_setup() {
|
uWSGI_distro_setup() {
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
# init.d --> /usr/share/doc/uwsgi/README.Debian.gz
|
# init.d --> /usr/share/doc/uwsgi/README.Debian.gz
|
||||||
# For uWSGI debian uses the LSB init process, this might be changed
|
# For uWSGI debian uses the LSB init process, this might be changed
|
||||||
# one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067
|
# one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067
|
||||||
|
@ -1273,7 +1286,7 @@ uWSGI_distro_setup() {
|
||||||
uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
|
uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
|
||||||
uWSGI_PACKAGES="uwsgi"
|
uWSGI_PACKAGES="uwsgi"
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
# systemd --> /usr/lib/systemd/system/uwsgi.service
|
# systemd --> /usr/lib/systemd/system/uwsgi.service
|
||||||
# Fedora runs uWSGI in emperor-tyrant mode: in Tyrant mode the
|
# Fedora runs uWSGI in emperor-tyrant mode: in Tyrant mode the
|
||||||
# Emperor will run the vassal using the UID/GID of the vassal
|
# Emperor will run the vassal using the UID/GID of the vassal
|
||||||
|
@ -1287,14 +1300,14 @@ uWSGI_distro_setup() {
|
||||||
*)
|
*)
|
||||||
err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
|
err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
install_uwsgi(){
|
install_uwsgi() {
|
||||||
info_msg "installing uwsgi ..."
|
info_msg "installing uwsgi ..."
|
||||||
pkg_install "$uWSGI_PACKAGES"
|
pkg_install "$uWSGI_PACKAGES"
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
# enable & start should be called once at uWSGI installation time
|
# enable & start should be called once at uWSGI installation time
|
||||||
systemctl enable uwsgi
|
systemctl enable uwsgi
|
||||||
systemctl restart uwsgi
|
systemctl restart uwsgi
|
||||||
|
@ -1311,7 +1324,7 @@ uWSGI_restart() {
|
||||||
[[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
|
[[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
|
||||||
info_msg "restart uWSGI service"
|
info_msg "restart uWSGI service"
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
# the 'service' method seems broken in that way, that it (re-)starts
|
# the 'service' method seems broken in that way, that it (re-)starts
|
||||||
# the whole uwsgi process.
|
# the whole uwsgi process.
|
||||||
service uwsgi restart "${CONF%.*}"
|
service uwsgi restart "${CONF%.*}"
|
||||||
|
@ -1324,7 +1337,7 @@ uWSGI_restart() {
|
||||||
info_msg "[uWSGI:systemd-template] ${CONF} not installed (no need to restart)"
|
info_msg "[uWSGI:systemd-template] ${CONF} not installed (no need to restart)"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
# in emperor mode, just touch the file to restart
|
# in emperor mode, just touch the file to restart
|
||||||
if uWSGI_app_enabled "${CONF}"; then
|
if uWSGI_app_enabled "${CONF}"; then
|
||||||
touch "${uWSGI_APPS_ENABLED}/${CONF}"
|
touch "${uWSGI_APPS_ENABLED}/${CONF}"
|
||||||
|
@ -1360,8 +1373,8 @@ uWSGI_install_app() {
|
||||||
|
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
case $i in
|
case $i in
|
||||||
-*) template_opts+=("$i");;
|
-*) template_opts+=("$i") ;;
|
||||||
*) pos_args+=("$i");;
|
*) pos_args+=("$i") ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
mkdir -p "${uWSGI_APPS_AVAILABLE}"
|
mkdir -p "${uWSGI_APPS_AVAILABLE}"
|
||||||
|
@ -1394,7 +1407,7 @@ uWSGI_app_enabled() {
|
||||||
|
|
||||||
[[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
|
[[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
[[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
|
[[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
|
||||||
exit_val=$?
|
exit_val=$?
|
||||||
;;
|
;;
|
||||||
|
@ -1402,7 +1415,7 @@ uWSGI_app_enabled() {
|
||||||
systemctl -q is-enabled "uwsgi@${CONF%.*}"
|
systemctl -q is-enabled "uwsgi@${CONF%.*}"
|
||||||
exit_val=$?
|
exit_val=$?
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
[[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
|
[[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
|
||||||
exit_val=$?
|
exit_val=$?
|
||||||
;;
|
;;
|
||||||
|
@ -1424,7 +1437,7 @@ uWSGI_enable_app() {
|
||||||
|
|
||||||
[[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
|
[[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
mkdir -p "${uWSGI_APPS_ENABLED}"
|
mkdir -p "${uWSGI_APPS_ENABLED}"
|
||||||
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
||||||
ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
|
ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
|
||||||
|
@ -1437,7 +1450,7 @@ uWSGI_enable_app() {
|
||||||
systemctl enable "uwsgi@${CONF%.*}"
|
systemctl enable "uwsgi@${CONF%.*}"
|
||||||
info_msg "enabled uWSGI app: ${CONF} (restart required)"
|
info_msg "enabled uWSGI app: ${CONF} (restart required)"
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
mkdir -p "${uWSGI_APPS_ENABLED}"
|
mkdir -p "${uWSGI_APPS_ENABLED}"
|
||||||
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
||||||
ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
|
ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
|
||||||
|
@ -1458,7 +1471,7 @@ uWSGI_disable_app() {
|
||||||
|
|
||||||
[[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
|
[[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
service uwsgi stop "${CONF%.*}"
|
service uwsgi stop "${CONF%.*}"
|
||||||
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
||||||
info_msg "disabled uWSGI app: ${CONF} (restart uWSGI required)"
|
info_msg "disabled uWSGI app: ${CONF} (restart uWSGI required)"
|
||||||
|
@ -1468,7 +1481,7 @@ uWSGI_disable_app() {
|
||||||
systemctl disable "uwsgi@${CONF%.*}"
|
systemctl disable "uwsgi@${CONF%.*}"
|
||||||
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7)
|
fedora-* | centos-7)
|
||||||
# in emperor mode, just remove the app.ini file
|
# in emperor mode, just remove the app.ini file
|
||||||
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
|
||||||
;;
|
;;
|
||||||
|
@ -1497,7 +1510,7 @@ pkg_install() {
|
||||||
return 42
|
return 42
|
||||||
fi
|
fi
|
||||||
case $DIST_ID in
|
case $DIST_ID in
|
||||||
ubuntu|debian)
|
ubuntu | debian)
|
||||||
if [[ $_apt_pkg_info_is_updated == 0 ]]; then
|
if [[ $_apt_pkg_info_is_updated == 0 ]]; then
|
||||||
export _apt_pkg_info_is_updated=1
|
export _apt_pkg_info_is_updated=1
|
||||||
apt update
|
apt update
|
||||||
|
@ -1533,7 +1546,7 @@ pkg_remove() {
|
||||||
return 42
|
return 42
|
||||||
fi
|
fi
|
||||||
case $DIST_ID in
|
case $DIST_ID in
|
||||||
ubuntu|debian)
|
ubuntu | debian)
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
apt-get purge --autoremove --ignore-missing -y $@
|
apt-get purge --autoremove --ignore-missing -y $@
|
||||||
;;
|
;;
|
||||||
|
@ -1557,20 +1570,20 @@ pkg_is_installed() {
|
||||||
# usage: pkg_is_install foopkg || pkg_install foopkg
|
# usage: pkg_is_install foopkg || pkg_install foopkg
|
||||||
|
|
||||||
case $DIST_ID in
|
case $DIST_ID in
|
||||||
ubuntu|debian)
|
ubuntu | debian)
|
||||||
dpkg -l "$1" &> /dev/null
|
dpkg -l "$1" &>/dev/null
|
||||||
return $?
|
return $?
|
||||||
;;
|
;;
|
||||||
arch)
|
arch)
|
||||||
pacman -Qsq "$1" &> /dev/null
|
pacman -Qsq "$1" &>/dev/null
|
||||||
return $?
|
return $?
|
||||||
;;
|
;;
|
||||||
fedora)
|
fedora)
|
||||||
dnf list -q --installed "$1" &> /dev/null
|
dnf list -q --installed "$1" &>/dev/null
|
||||||
return $?
|
return $?
|
||||||
;;
|
;;
|
||||||
centos)
|
centos)
|
||||||
yum list -q --installed "$1" &> /dev/null
|
yum list -q --installed "$1" &>/dev/null
|
||||||
return $?
|
return $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -1601,15 +1614,15 @@ git_clone() {
|
||||||
local bash_cmd="bash"
|
local bash_cmd="bash"
|
||||||
local remote="origin"
|
local remote="origin"
|
||||||
|
|
||||||
if [[ ! "${dest:0:1}" = "/" ]]; then
|
if [[ ${dest:0:1} != "/" ]]; then
|
||||||
dest="$CACHE/$dest"
|
dest="$CACHE/$dest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -z $branch ]] && branch=master
|
[[ -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"
|
[[ -n $user ]] && bash_cmd="sudo -H -u $user -i"
|
||||||
|
|
||||||
if [[ -d "${dest}" ]] ; then
|
if [[ -d ${dest} ]]; then
|
||||||
info_msg "already cloned: $dest"
|
info_msg "already cloned: $dest"
|
||||||
tee_stderr 0.1 <<EOF | $bash_cmd 2>&1 | prefix_stdout " ${_Yellow}|$user|${_creset} "
|
tee_stderr 0.1 <<EOF | $bash_cmd 2>&1 | prefix_stdout " ${_Yellow}|$user|${_creset} "
|
||||||
cd "${dest}"
|
cd "${dest}"
|
||||||
|
@ -1684,7 +1697,7 @@ LXC_BASE_PACKAGES_centos="bash git python3"
|
||||||
|
|
||||||
lxc_distro_setup() {
|
lxc_distro_setup() {
|
||||||
case $DIST_ID in
|
case $DIST_ID in
|
||||||
ubuntu|debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;;
|
ubuntu | debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;;
|
||||||
arch) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_arch}" ;;
|
arch) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_arch}" ;;
|
||||||
fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
|
fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
|
||||||
centos) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_centos}" ;;
|
centos) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_centos}" ;;
|
||||||
|
@ -1700,19 +1713,18 @@ lxc_install_base_packages() {
|
||||||
pkg_install "${LXC_BASE_PACKAGES}"
|
pkg_install "${LXC_BASE_PACKAGES}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lxc_image_copy() {
|
lxc_image_copy() {
|
||||||
|
|
||||||
# usage: lxc_image_copy <remote image> <local image>
|
# usage: lxc_image_copy <remote image> <local image>
|
||||||
#
|
#
|
||||||
# lxc_image_copy "images:ubuntu/20.04" "ubu2004"
|
# lxc_image_copy "images:ubuntu/20.04" "ubu2004"
|
||||||
|
|
||||||
if lxc_image_exists "local:${LXC_SUITE[i+1]}"; then
|
if lxc_image_exists "local:${LXC_SUITE[i + 1]}"; then
|
||||||
info_msg "image ${LXC_SUITE[i]} already copied --> ${LXC_SUITE[i+1]}"
|
info_msg "image ${LXC_SUITE[i]} already copied --> ${LXC_SUITE[i + 1]}"
|
||||||
else
|
else
|
||||||
info_msg "copy image locally ${LXC_SUITE[i]} --> ${LXC_SUITE[i+1]}"
|
info_msg "copy image locally ${LXC_SUITE[i]} --> ${LXC_SUITE[i + 1]}"
|
||||||
lxc image copy "${LXC_SUITE[i]}" local: \
|
lxc image copy "${LXC_SUITE[i]}" local: \
|
||||||
--alias "${LXC_SUITE[i+1]}" | prefix_stdout
|
--alias "${LXC_SUITE[i + 1]}" | prefix_stdout
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1731,14 +1743,14 @@ lxc_init_container() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
lxc_exists(){
|
lxc_exists() {
|
||||||
|
|
||||||
# usage: lxc_exists <name> || echo "container <name> does not exists"
|
# usage: lxc_exists <name> || echo "container <name> does not exists"
|
||||||
|
|
||||||
lxc info "$1" &>/dev/null
|
lxc info "$1" &>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
lxc_image_exists(){
|
lxc_image_exists() {
|
||||||
# usage: lxc_image_exists <alias> || echo "image <alias> does locally not exists"
|
# usage: lxc_image_exists <alias> || echo "image <alias> does locally not exists"
|
||||||
|
|
||||||
lxc image info "local:$1" &>/dev/null
|
lxc image info "local:$1" &>/dev/null
|
||||||
|
@ -1766,11 +1778,10 @@ lxc_delete_local_image() {
|
||||||
lxc image delete "local:$i"
|
lxc image delete "local:$i"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# IP
|
# IP
|
||||||
# --
|
# --
|
||||||
|
|
||||||
global_IPs(){
|
global_IPs() {
|
||||||
# usage: global_IPS
|
# usage: global_IPS
|
||||||
#
|
#
|
||||||
# print list of host's SCOPE global addresses and adapters e.g::
|
# print list of host's SCOPE global addresses and adapters e.g::
|
||||||
|
@ -1787,9 +1798,9 @@ primary_ip() {
|
||||||
|
|
||||||
case $DIST_ID in
|
case $DIST_ID in
|
||||||
arch)
|
arch)
|
||||||
ip -o addr show \
|
ip -o addr show |
|
||||||
| sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\2/p' \
|
sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\2/p' |
|
||||||
| head -n 1
|
head -n 1
|
||||||
;;
|
;;
|
||||||
*) hostname -I | cut -d' ' -f1 ;;
|
*) hostname -I | cut -d' ' -f1 ;;
|
||||||
esac
|
esac
|
||||||
|
@ -1798,7 +1809,7 @@ primary_ip() {
|
||||||
# URL
|
# URL
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
url_replace_hostname(){
|
url_replace_hostname() {
|
||||||
|
|
||||||
# usage: url_replace_hostname <url> <new hostname>
|
# usage: url_replace_hostname <url> <new hostname>
|
||||||
|
|
||||||
|
|
|
@ -23,14 +23,14 @@
|
||||||
# configure golang environment
|
# 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"
|
GO_DL_URL="https://golang.org/dl"
|
||||||
|
|
||||||
# implement go functions
|
# implement go functions
|
||||||
# -----------------------
|
# -----------------------
|
||||||
|
|
||||||
go.help(){
|
go.help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
go.:
|
go.:
|
||||||
ls : list golang binary archives (stable)
|
ls : list golang binary archives (stable)
|
||||||
|
@ -40,7 +40,7 @@ go.:
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
go.ls(){
|
go.ls() {
|
||||||
python <<EOF
|
python <<EOF
|
||||||
import sys, json, requests
|
import sys, json, requests
|
||||||
resp = requests.get("${GO_DL_URL}/?mode=json&include=all")
|
resp = requests.get("${GO_DL_URL}/?mode=json&include=all")
|
||||||
|
@ -54,7 +54,7 @@ for ver in json.loads(resp.text):
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
go.ver_info(){
|
go.ver_info() {
|
||||||
|
|
||||||
# print information about a golang distribution. To print filename
|
# print information about a golang distribution. To print filename
|
||||||
# sha256 and size of the archive that fits to your OS and host:
|
# sha256 and size of the archive that fits to your OS and host:
|
||||||
|
@ -140,14 +140,14 @@ go.golang() {
|
||||||
info_msg "Download go binary ${fname} (${size}B)"
|
info_msg "Download go binary ${fname} (${size}B)"
|
||||||
cache_download "${GO_DL_URL}/${fname}" "${fname}"
|
cache_download "${GO_DL_URL}/${fname}" "${fname}"
|
||||||
|
|
||||||
pushd "${CACHE}" &> /dev/null
|
pushd "${CACHE}" &>/dev/null
|
||||||
echo "${sha} ${fname}" > "${fname}.sha256"
|
echo "${sha} ${fname}" >"${fname}.sha256"
|
||||||
if ! sha256sum -c "${fname}.sha256" >/dev/null; then
|
if ! sha256sum -c "${fname}.sha256" >/dev/null; then
|
||||||
die 42 "downloaded file ${fname} checksum does not match"
|
die 42 "downloaded file ${fname} checksum does not match"
|
||||||
else
|
else
|
||||||
info_msg "${fname} checksum OK"
|
info_msg "${fname} checksum OK"
|
||||||
fi
|
fi
|
||||||
popd &> /dev/null
|
popd &>/dev/null
|
||||||
|
|
||||||
info_msg "install golang"
|
info_msg "install golang"
|
||||||
tee_stderr 0.1 <<EOF | sudo -i -u "${user}" | prefix_stdout "${userpr}"
|
tee_stderr 0.1 <<EOF | sudo -i -u "${user}" | prefix_stdout "${userpr}"
|
||||||
|
@ -201,7 +201,7 @@ go.bash() {
|
||||||
sudo -i -u "${user}" bash --init-file "~${user}/.go_env"
|
sudo -i -u "${user}" bash --init-file "~${user}/.go_env"
|
||||||
}
|
}
|
||||||
|
|
||||||
go.version(){
|
go.version() {
|
||||||
local user
|
local user
|
||||||
user="${1:-${USERNAME}}"
|
user="${1:-${USERNAME}}"
|
||||||
sudo -i -u "${user}" <<EOF
|
sudo -i -u "${user}" <<EOF
|
||||||
|
|
|
@ -17,8 +17,8 @@ declare main_cmd
|
||||||
|
|
||||||
NVM_LOCAL_FOLDER=.nvm
|
NVM_LOCAL_FOLDER=.nvm
|
||||||
|
|
||||||
[[ -z "${NVM_GIT_URL}" ]] && NVM_GIT_URL="https://github.com/nvm-sh/nvm.git"
|
[[ -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_MIN_NODE_VER} ]] && NVM_MIN_NODE_VER="16.13.0"
|
||||||
|
|
||||||
# initialize nvm environment
|
# initialize nvm environment
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
@ -35,7 +35,7 @@ nvm.is_installed() {
|
||||||
[[ -f "${NVM_DIR}/nvm.sh" ]]
|
[[ -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 is not pre-installed in $HOME. Prepare for using nvm from <repo-root>
|
||||||
NVM_DIR="$(git rev-parse --show-toplevel)/${NVM_LOCAL_FOLDER}"
|
NVM_DIR="$(git rev-parse --show-toplevel)/${NVM_LOCAL_FOLDER}"
|
||||||
fi
|
fi
|
||||||
|
@ -105,7 +105,7 @@ nvm.install() {
|
||||||
info_msg "install (update) NVM at ${NVM_DIR}"
|
info_msg "install (update) NVM at ${NVM_DIR}"
|
||||||
if nvm.is_installed; then
|
if nvm.is_installed; then
|
||||||
info_msg "already cloned at: ${NVM_DIR}"
|
info_msg "already cloned at: ${NVM_DIR}"
|
||||||
pushd "${NVM_DIR}" &> /dev/null
|
pushd "${NVM_DIR}" &>/dev/null
|
||||||
git fetch --all | prefix_stdout " ${_Yellow}||${_creset} "
|
git fetch --all | prefix_stdout " ${_Yellow}||${_creset} "
|
||||||
else
|
else
|
||||||
# delete any leftovers from previous installations
|
# delete any leftovers from previous installations
|
||||||
|
@ -114,14 +114,14 @@ nvm.install() {
|
||||||
fi
|
fi
|
||||||
info_msg "clone: ${NVM_GIT_URL}"
|
info_msg "clone: ${NVM_GIT_URL}"
|
||||||
git clone "${NVM_GIT_URL}" "${NVM_DIR}" 2>&1 | prefix_stdout " ${_Yellow}||${_creset} "
|
git clone "${NVM_GIT_URL}" "${NVM_DIR}" 2>&1 | prefix_stdout " ${_Yellow}||${_creset} "
|
||||||
pushd "${NVM_DIR}" &> /dev/null
|
pushd "${NVM_DIR}" &>/dev/null
|
||||||
git config --local advice.detachedHead false
|
git config --local advice.detachedHead false
|
||||||
fi
|
fi
|
||||||
NVM_VERSION_TAG="$(git rev-list --tags --max-count=1)"
|
NVM_VERSION_TAG="$(git rev-list --tags --max-count=1)"
|
||||||
NVM_VERSION_TAG="$(git describe --abbrev=0 --tags --match "v[0-9]*" "${NVM_VERSION_TAG}")"
|
NVM_VERSION_TAG="$(git describe --abbrev=0 --tags --match "v[0-9]*" "${NVM_VERSION_TAG}")"
|
||||||
info_msg "checkout ${NVM_VERSION_TAG}"
|
info_msg "checkout ${NVM_VERSION_TAG}"
|
||||||
git checkout "${NVM_VERSION_TAG}" 2>&1 | prefix_stdout " ${_Yellow}||${_creset} "
|
git checkout "${NVM_VERSION_TAG}" 2>&1 | prefix_stdout " ${_Yellow}||${_creset} "
|
||||||
popd &> /dev/null
|
popd &>/dev/null
|
||||||
if [ -f "${REPO_ROOT}/.nvm_packages" ]; then
|
if [ -f "${REPO_ROOT}/.nvm_packages" ]; then
|
||||||
cp "${REPO_ROOT}/.nvm_packages" "${NVM_DIR}/default-packages"
|
cp "${REPO_ROOT}/.nvm_packages" "${NVM_DIR}/default-packages"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -12,7 +12,7 @@ REDIS_GROUP="searxng-redis"
|
||||||
REDIS_SERVICE_NAME="searxng-redis"
|
REDIS_SERVICE_NAME="searxng-redis"
|
||||||
REDIS_SYSTEMD_UNIT="${SYSTEMD_UNITS}/${REDIS_SERVICE_NAME}.service"
|
REDIS_SYSTEMD_UNIT="${SYSTEMD_UNITS}/${REDIS_SERVICE_NAME}.service"
|
||||||
|
|
||||||
redis.help(){
|
redis.help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
redis.:
|
redis.:
|
||||||
remove : delete user (${REDIS_USER}) and remove service (${REDIS_SERVICE_NAME})
|
remove : delete user (${REDIS_USER}) and remove service (${REDIS_SERVICE_NAME})
|
||||||
|
@ -21,7 +21,6 @@ redis.:
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
redis.remove() {
|
redis.remove() {
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
(
|
(
|
||||||
|
@ -36,7 +35,6 @@ redis.shell() {
|
||||||
interactive_shell "${REDIS_USER}"
|
interactive_shell "${REDIS_USER}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
redis.userdel() {
|
redis.userdel() {
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
drop_service_account "${REDIS_USER}"
|
drop_service_account "${REDIS_USER}"
|
||||||
|
|
|
@ -117,7 +117,7 @@ container.build() {
|
||||||
--tag="localhost/$CONTAINER_IMAGE_ORGANIZATION/$CONTAINER_IMAGE_NAME:builder" \
|
--tag="localhost/$CONTAINER_IMAGE_ORGANIZATION/$CONTAINER_IMAGE_NAME:builder" \
|
||||||
--file="./container/$dockerfile" \
|
--file="./container/$dockerfile" \
|
||||||
.
|
.
|
||||||
build_msg CONTAINER "Image \"builder\" built"
|
build_msg CONTAINER 'Image "builder" built'
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
"$container_engine" $params_build \
|
"$container_engine" $params_build \
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
data.help(){
|
data.help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
data.:
|
data.:
|
||||||
all : update searx/sxng_locales.py and searx/data/*
|
all : update searx/sxng_locales.py and searx/data/*
|
||||||
|
@ -13,7 +13,8 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
data.all() {
|
data.all() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
|
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
data.traits
|
data.traits
|
||||||
|
@ -35,9 +36,9 @@ data.all() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data.traits() {
|
data.traits() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
build_msg DATA "update searx/data/engine_traits.json"
|
build_msg DATA "update searx/data/engine_traits.json"
|
||||||
python searxng_extra/update/update_engine_traits.py
|
python searxng_extra/update/update_engine_traits.py
|
||||||
|
@ -53,7 +54,8 @@ data.useragents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
data.locales() {
|
data.locales() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
build_msg DATA "update searx/data/locales.json"
|
build_msg DATA "update searx/data/locales.json"
|
||||||
python searxng_extra/update/update_locales.py
|
python searxng_extra/update/update_locales.py
|
||||||
|
@ -61,8 +63,9 @@ data.locales() {
|
||||||
dump_return $?
|
dump_return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
data.currencies(){
|
data.currencies() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
build_msg DATA "update searx/data/currencies.json"
|
build_msg DATA "update searx/data/currencies.json"
|
||||||
python searxng_extra/update/update_currencies.py
|
python searxng_extra/update/update_currencies.py
|
||||||
|
|
|
@ -6,7 +6,7 @@ declare _creset
|
||||||
|
|
||||||
export NODE_MINIMUM_VERSION="18.17.0"
|
export NODE_MINIMUM_VERSION="18.17.0"
|
||||||
|
|
||||||
node.help(){
|
node.help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
node.:
|
node.:
|
||||||
env : download & install SearXNG's npm dependencies locally
|
env : download & install SearXNG's npm dependencies locally
|
||||||
|
@ -24,7 +24,8 @@ nodejs.ensure() {
|
||||||
|
|
||||||
node.env() {
|
node.env() {
|
||||||
nodejs.ensure
|
nodejs.ensure
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
build_msg INSTALL "[npm] ./client/simple/package.json"
|
build_msg INSTALL "[npm] ./client/simple/package.json"
|
||||||
npm --prefix client/simple install
|
npm --prefix client/simple install
|
||||||
)
|
)
|
||||||
|
@ -43,17 +44,19 @@ node.clean() {
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
build_msg CLEAN "themes -- locally installed npm dependencies"
|
build_msg CLEAN "themes -- locally installed npm dependencies"
|
||||||
( set -e
|
(
|
||||||
npm --prefix client/simple run clean \
|
set -e
|
||||||
| prefix_stdout "${_Blue}CLEAN ${_creset} "
|
npm --prefix client/simple run clean |
|
||||||
|
prefix_stdout "${_Blue}CLEAN ${_creset} "
|
||||||
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
|
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
build_msg CLEAN "locally installed developer and CI tools"
|
build_msg CLEAN "locally installed developer and CI tools"
|
||||||
( set -e
|
(
|
||||||
npm --prefix . run clean \
|
set -e
|
||||||
| prefix_stdout "${_Blue}CLEAN ${_creset} "
|
npm --prefix . run clean |
|
||||||
|
prefix_stdout "${_Blue}CLEAN ${_creset} "
|
||||||
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
|
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
|
||||||
STATIC_BUILD_COMMIT="[build] /static"
|
STATIC_BUILD_COMMIT="[build] /static"
|
||||||
STATIC_BUILT_PATHS=(
|
STATIC_BUILT_PATHS=(
|
||||||
'searx/templates/simple/icons.html'
|
'searx/templates/simple/icons.html'
|
||||||
|
@ -9,7 +8,7 @@ STATIC_BUILT_PATHS=(
|
||||||
'client/simple/package-lock.json'
|
'client/simple/package-lock.json'
|
||||||
)
|
)
|
||||||
|
|
||||||
static.help(){
|
static.help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
static.build.: ${STATIC_BUILD_COMMIT}
|
static.build.: ${STATIC_BUILD_COMMIT}
|
||||||
commit : build & commit /static folder
|
commit : build & commit /static folder
|
||||||
|
@ -57,7 +56,7 @@ static.build.drop() {
|
||||||
|
|
||||||
# get only last (option -n1) local commit not in remotes
|
# get only last (option -n1) local commit not in remotes
|
||||||
branch="$(git branch --show-current)"
|
branch="$(git branch --show-current)"
|
||||||
last_commit_id="$(git log -n1 "${branch}" --pretty=format:'%h'\
|
last_commit_id="$(git log -n1 "${branch}" --pretty=format:'%h' \
|
||||||
--not --exclude="${branch}" --branches --remotes)"
|
--not --exclude="${branch}" --branches --remotes)"
|
||||||
|
|
||||||
if [ -z "${last_commit_id}" ]; then
|
if [ -z "${last_commit_id}" ]; then
|
||||||
|
@ -96,7 +95,8 @@ static.build.commit() {
|
||||||
# drop existing commit from previous build
|
# drop existing commit from previous build
|
||||||
static.build.drop &>/dev/null
|
static.build.drop &>/dev/null
|
||||||
|
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
# fix & build the themes
|
# fix & build the themes
|
||||||
themes.fix
|
themes.fix
|
||||||
themes.lint
|
themes.lint
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
test.help(){
|
test.help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
test.:
|
test.:
|
||||||
yamllint : lint YAML files (YAMLLINT_FILES)
|
yamllint : lint YAML files (YAMLLINT_FILES)
|
||||||
|
@ -22,13 +22,14 @@ if [ "$VERBOSE" = "1" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test.yamllint() {
|
test.yamllint() {
|
||||||
build_msg TEST "[yamllint] \$YAMLLINT_FILES"
|
build_msg TEST "[yamllint] ${YAMLLINT_FILES[*]}"
|
||||||
pyenv.cmd yamllint --strict --format parsable "${YAMLLINT_FILES[@]}"
|
pyenv.cmd yamllint --strict --format parsable "${YAMLLINT_FILES[@]}"
|
||||||
dump_return $?
|
dump_return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
test.pylint() {
|
test.pylint() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
PYLINT_OPTIONS="--rcfile .pylintrc"
|
PYLINT_OPTIONS="--rcfile .pylintrc"
|
||||||
|
|
||||||
|
@ -63,13 +64,13 @@ test.types.dev() {
|
||||||
build_msg TEST "[pyright/types] suppress warnings related to intentional monkey patching"
|
build_msg TEST "[pyright/types] suppress warnings related to intentional monkey patching"
|
||||||
# We run Pyright in the virtual environment because pyright executes
|
# We run Pyright in the virtual environment because pyright executes
|
||||||
# "python" to determine the Python version.
|
# "python" to determine the Python version.
|
||||||
pyenv.cmd npx --no-install pyright -p pyrightconfig.json \
|
pyenv.cmd npx --no-install pyright -p pyrightconfig.json |
|
||||||
| grep -E '\.py:[0-9]+:[0-9]+'\
|
grep -E '\.py:[0-9]+:[0-9]+' |
|
||||||
| grep -v '/engines/.*.py.* - warning: "logger" is not defined'\
|
grep -v '/engines/.*.py.* - warning: "logger" is not defined' |
|
||||||
| grep -v '/plugins/.*.py.* - error: "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: "supported_languages" is not defined' |
|
||||||
| grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' \
|
grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' |
|
||||||
| grep -v '/engines/.*.py.* - warning: "categories" is not defined'
|
grep -v '/engines/.*.py.* - warning: "categories" is not defined'
|
||||||
# ignore exit value from pyright
|
# ignore exit value from pyright
|
||||||
# dump_return ${PIPESTATUS[0]}
|
# dump_return ${PIPESTATUS[0]}
|
||||||
return 0
|
return 0
|
||||||
|
@ -88,13 +89,13 @@ test.types.ci() {
|
||||||
build_msg TEST "[pyright] suppress warnings related to intentional monkey patching"
|
build_msg TEST "[pyright] suppress warnings related to intentional monkey patching"
|
||||||
# We run Pyright in the virtual environment because pyright executes
|
# We run Pyright in the virtual environment because pyright executes
|
||||||
# "python" to determine the Python version.
|
# "python" to determine the Python version.
|
||||||
pyenv.cmd npx --no-install pyright -p pyrightconfig-ci.json \
|
pyenv.cmd npx --no-install pyright -p pyrightconfig-ci.json |
|
||||||
| grep -E '\.py:[0-9]+:[0-9]+'\
|
grep -E '\.py:[0-9]+:[0-9]+' |
|
||||||
| grep -v '/engines/.*.py.* - warning: "logger" is not defined'\
|
grep -v '/engines/.*.py.* - warning: "logger" is not defined' |
|
||||||
| grep -v '/plugins/.*.py.* - error: "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: "supported_languages" is not defined' |
|
||||||
| grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' \
|
grep -v '/engines/.*.py.* - warning: "language_aliases" is not defined' |
|
||||||
| grep -v '/engines/.*.py.* - warning: "categories" is not defined'
|
grep -v '/engines/.*.py.* - warning: "categories" is not defined'
|
||||||
# ignore exit value from pyright
|
# ignore exit value from pyright
|
||||||
# dump_return ${PIPESTATUS[0]}
|
# dump_return ${PIPESTATUS[0]}
|
||||||
return 0
|
return 0
|
||||||
|
@ -121,7 +122,8 @@ test.unit() {
|
||||||
|
|
||||||
test.coverage() {
|
test.coverage() {
|
||||||
build_msg TEST 'unit test coverage'
|
build_msg TEST 'unit test coverage'
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
python -m nose2 ${TEST_NOSE2_VERBOSE} -C --log-capture --with-coverage --coverage searx -s tests/unit
|
python -m nose2 ${TEST_NOSE2_VERBOSE} -C --log-capture --with-coverage --coverage searx -s tests/unit
|
||||||
|
@ -142,7 +144,7 @@ test.rst() {
|
||||||
build_msg TEST "[reST markup] ${RST_FILES[*]}"
|
build_msg TEST "[reST markup] ${RST_FILES[*]}"
|
||||||
|
|
||||||
for rst in "${RST_FILES[@]}"; do
|
for rst in "${RST_FILES[@]}"; do
|
||||||
pyenv.cmd rst2html --halt error "$rst" > /dev/null || die 42 "fix issue in $rst"
|
pyenv.cmd rst2html --halt error "$rst" >/dev/null || die 42 "fix issue in $rst"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
themes.help(){
|
themes.help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
themes.:
|
themes.:
|
||||||
all : test & build all themes
|
all : test & build all themes
|
||||||
|
@ -13,14 +13,16 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
themes.all() {
|
themes.all() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
vite.simple.build
|
vite.simple.build
|
||||||
)
|
)
|
||||||
dump_return $?
|
dump_return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
themes.simple() {
|
themes.simple() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
build_msg SIMPLE "theme: run build (simple)"
|
build_msg SIMPLE "theme: run build (simple)"
|
||||||
vite.simple.build
|
vite.simple.build
|
||||||
)
|
)
|
||||||
|
@ -28,7 +30,8 @@ themes.simple() {
|
||||||
}
|
}
|
||||||
|
|
||||||
themes.fix() {
|
themes.fix() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
build_msg SIMPLE "theme: fix (all themes)"
|
build_msg SIMPLE "theme: fix (all themes)"
|
||||||
vite.simple.fix
|
vite.simple.fix
|
||||||
)
|
)
|
||||||
|
@ -36,7 +39,8 @@ themes.fix() {
|
||||||
}
|
}
|
||||||
|
|
||||||
themes.lint() {
|
themes.lint() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
build_msg SIMPLE "theme: lint (all themes)"
|
build_msg SIMPLE "theme: lint (all themes)"
|
||||||
vite.simple.lint
|
vite.simple.lint
|
||||||
)
|
)
|
||||||
|
@ -44,7 +48,8 @@ themes.lint() {
|
||||||
}
|
}
|
||||||
|
|
||||||
themes.test() {
|
themes.test() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
# we run a build to test (in CI)
|
# we run a build to test (in CI)
|
||||||
build_msg SIMPLE "theme: run build (to test)"
|
build_msg SIMPLE "theme: run build (to test)"
|
||||||
vite.simple.build
|
vite.simple.build
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
declare _Blue
|
declare _Blue
|
||||||
declare _creset
|
declare _creset
|
||||||
|
|
||||||
vite.help(){
|
vite.help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
vite.: .. to be done ..
|
vite.: .. to be done ..
|
||||||
simple.:
|
simple.:
|
||||||
|
@ -30,7 +30,8 @@ VITE_SIMPLE_THEME="${REPO_ROOT}/client/simple"
|
||||||
# }
|
# }
|
||||||
|
|
||||||
vite.simple.build() {
|
vite.simple.build() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
templates.simple.pygments
|
templates.simple.pygments
|
||||||
|
|
||||||
node.env
|
node.env
|
||||||
|
@ -39,19 +40,21 @@ vite.simple.build() {
|
||||||
pushd "${VITE_SIMPLE_THEME}"
|
pushd "${VITE_SIMPLE_THEME}"
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
popd &> /dev/null
|
popd &>/dev/null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
vite.simple.fix() {
|
vite.simple.fix() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
node.env
|
node.env
|
||||||
npm --prefix client/simple run fix
|
npm --prefix client/simple run fix
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
vite.simple.lint() {
|
vite.simple.lint() {
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
node.env
|
node.env
|
||||||
npm --prefix client/simple run lint
|
npm --prefix client/simple run lint
|
||||||
)
|
)
|
||||||
|
@ -59,8 +62,8 @@ vite.simple.lint() {
|
||||||
|
|
||||||
templates.simple.pygments() {
|
templates.simple.pygments() {
|
||||||
build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
|
build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
|
||||||
pyenv.cmd python searxng_extra/update/update_pygments.py \
|
pyenv.cmd python searxng_extra/update/update_pygments.py |
|
||||||
| prefix_stdout "${_Blue}PYGMENTS ${_creset} "
|
prefix_stdout "${_Blue}PYGMENTS ${_creset} "
|
||||||
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
|
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
|
||||||
build_msg PYGMENTS "building LESS files for pygments failed"
|
build_msg PYGMENTS "building LESS files for pygments failed"
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
weblate.help(){
|
weblate.help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
weblate.:
|
weblate.:
|
||||||
push.translations: push translation changes from SearXNG to Weblate's counterpart
|
push.translations: push translation changes from SearXNG to Weblate's counterpart
|
||||||
|
@ -19,8 +19,9 @@ weblate.translations.worktree() {
|
||||||
#
|
#
|
||||||
# remote weblate https://translate.codeberg.org/git/searxng/searxng/
|
# remote weblate https://translate.codeberg.org/git/searxng/searxng/
|
||||||
|
|
||||||
( set -e
|
(
|
||||||
if ! git remote get-url weblate 2> /dev/null; then
|
set -e
|
||||||
|
if ! git remote get-url weblate 2>/dev/null; then
|
||||||
git remote add weblate https://translate.codeberg.org/git/searxng/searxng/
|
git remote add weblate https://translate.codeberg.org/git/searxng/searxng/
|
||||||
fi
|
fi
|
||||||
if [ -d "${TRANSLATIONS_WORKTREE}" ]; then
|
if [ -d "${TRANSLATIONS_WORKTREE}" ]; then
|
||||||
|
@ -49,7 +50,8 @@ weblate.to.translations() {
|
||||||
# 4. In translations worktree, merge changes of branch 'translations' from
|
# 4. In translations worktree, merge changes of branch 'translations' from
|
||||||
# remote 'weblate' and push it on branch 'translations' of 'origin'
|
# remote 'weblate' and push it on branch 'translations' of 'origin'
|
||||||
|
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
if [ "$(wlc lock-status)" != "locked: True" ]; then
|
if [ "$(wlc lock-status)" != "locked: True" ]; then
|
||||||
die 1 "weblate must be locked, currently: $(wlc lock-status)"
|
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)
|
# create a commit in the local branch (master)
|
||||||
|
|
||||||
local existing_commit_hash commit_body commit_message exitcode
|
local existing_commit_hash commit_body commit_message exitcode
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
# lock change on weblate
|
# lock change on weblate
|
||||||
wlc lock
|
wlc lock
|
||||||
|
|
||||||
# get translations branch in git worktree (TRANSLATIONS_WORKTREE)
|
# get translations branch in git worktree (TRANSLATIONS_WORKTREE)
|
||||||
weblate.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
|
# pull weblate commits
|
||||||
weblate.to.translations
|
weblate.to.translations
|
||||||
|
@ -101,7 +107,10 @@ weblate.translations.commit() {
|
||||||
data.locales
|
data.locales
|
||||||
|
|
||||||
# git add/commit (no push)
|
# 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}")
|
commit_message=$(echo -e "[l10n] update translations from Weblate\n\n${commit_body}")
|
||||||
git add searx/translations
|
git add searx/translations
|
||||||
git add searx/data/locales.json
|
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 \
|
local messages_pot diff_messages_pot last_commit_hash last_commit_detail \
|
||||||
exitcode
|
exitcode
|
||||||
messages_pot="${TRANSLATIONS_WORKTREE}/searx/translations/messages.pot"
|
messages_pot="${TRANSLATIONS_WORKTREE}/searx/translations/messages.pot"
|
||||||
( set -e
|
(
|
||||||
|
set -e
|
||||||
pyenv.activate
|
pyenv.activate
|
||||||
# get translations branch in git worktree (TRANSLATIONS_WORKTREE)
|
# get translations branch in git worktree (TRANSLATIONS_WORKTREE)
|
||||||
weblate.translations.worktree
|
weblate.translations.worktree
|
||||||
|
@ -147,8 +157,10 @@ weblate.push.translations() {
|
||||||
"searx/"
|
"searx/"
|
||||||
|
|
||||||
# stop if there is no meaningful change in the master branch
|
# stop if there is no meaningful change in the master branch
|
||||||
diff_messages_pot=$(cd "${TRANSLATIONS_WORKTREE}";\
|
diff_messages_pot=$(
|
||||||
git diff -- "searx/translations/messages.pot")
|
cd "${TRANSLATIONS_WORKTREE}"
|
||||||
|
git diff -- "searx/translations/messages.pot"
|
||||||
|
)
|
||||||
if ! echo "$diff_messages_pot" | grep -qE "[\+\-](msgid|msgstr)"; then
|
if ! echo "$diff_messages_pot" | grep -qE "[\+\-](msgid|msgstr)"; then
|
||||||
build_msg BABEL 'no changes detected, exiting'
|
build_msg BABEL 'no changes detected, exiting'
|
||||||
return 42
|
return 42
|
||||||
|
|
|
@ -5,10 +5,10 @@ valkey.distro.setup() {
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
case $DIST_ID in
|
case $DIST_ID in
|
||||||
ubuntu|debian)
|
ubuntu | debian)
|
||||||
VALKEY_PACKAGES="valkey-server"
|
VALKEY_PACKAGES="valkey-server"
|
||||||
;;
|
;;
|
||||||
arch|fedora|centos)
|
arch | fedora | centos)
|
||||||
VALKEY_PACKAGES="valkey"
|
VALKEY_PACKAGES="valkey"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -36,13 +36,13 @@ valkey.backports() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
valkey.install(){
|
valkey.install() {
|
||||||
info_msg "installing valkey ..."
|
info_msg "installing valkey ..."
|
||||||
valkey.distro.setup
|
valkey.distro.setup
|
||||||
|
|
||||||
case $DIST_ID in
|
case $DIST_ID in
|
||||||
debian|ubuntu)
|
debian | ubuntu)
|
||||||
apt-cache show "${VALKEY_PACKAGES}" &> /dev/null || valkey.backports
|
apt-cache show "${VALKEY_PACKAGES}" &>/dev/null || valkey.backports
|
||||||
pkg_install "${VALKEY_PACKAGES}"
|
pkg_install "${VALKEY_PACKAGES}"
|
||||||
|
|
||||||
# do some fix ...
|
# do some fix ...
|
||||||
|
@ -54,7 +54,7 @@ valkey.install(){
|
||||||
|
|
||||||
systemd_activate_service valkey-server
|
systemd_activate_service valkey-server
|
||||||
;;
|
;;
|
||||||
arch|fedora|centos)
|
arch | fedora | centos)
|
||||||
pkg_install "${VALKEY_PACKAGES}"
|
pkg_install "${VALKEY_PACKAGES}"
|
||||||
systemd_activate_service valkey
|
systemd_activate_service valkey
|
||||||
;;
|
;;
|
||||||
|
|
142
utils/lxc.sh
142
utils/lxc.sh
|
@ -60,19 +60,17 @@ REMOTE_IMAGES=()
|
||||||
CONTAINERS=()
|
CONTAINERS=()
|
||||||
LOCAL_IMAGES=()
|
LOCAL_IMAGES=()
|
||||||
|
|
||||||
for ((i=0; i<${#LXC_SUITE[@]}; i+=2)); do
|
for ((i = 0; i < ${#LXC_SUITE[@]}; i += 2)); do
|
||||||
REMOTE_IMAGES=("${REMOTE_IMAGES[@]}" "${LXC_SUITE[i]}")
|
REMOTE_IMAGES=("${REMOTE_IMAGES[@]}" "${LXC_SUITE[i]}")
|
||||||
CONTAINERS=("${CONTAINERS[@]}" "${LXC_HOST_PREFIX}-${LXC_SUITE[i+1]}")
|
CONTAINERS=("${CONTAINERS[@]}" "${LXC_HOST_PREFIX}-${LXC_SUITE[i + 1]}")
|
||||||
LOCAL_IMAGES=("${LOCAL_IMAGES[@]}" "${LXC_SUITE[i+1]}")
|
LOCAL_IMAGES=("${LOCAL_IMAGES[@]}" "${LXC_SUITE[i + 1]}")
|
||||||
done
|
done
|
||||||
|
|
||||||
HOST_USER="${SUDO_USER:-$USER}"
|
HOST_USER="${SUDO_USER:-$USER}"
|
||||||
HOST_USER_ID=$(id -u "${HOST_USER}")
|
HOST_USER_ID=$(id -u "${HOST_USER}")
|
||||||
HOST_GROUP_ID=$(id -g "${HOST_USER}")
|
HOST_GROUP_ID=$(id -g "${HOST_USER}")
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
usage() {
|
usage() {
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
_cmd="$(basename "$0")"
|
_cmd="$(basename "$0")"
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
usage::
|
usage::
|
||||||
|
@ -138,7 +136,7 @@ main() {
|
||||||
lxc_distro_setup
|
lxc_distro_setup
|
||||||
|
|
||||||
# don't check prerequisite when in recursion
|
# don't check prerequisite when in recursion
|
||||||
if [[ ! $1 == __* ]] && [[ ! $1 == --help ]]; then
|
if [[ $1 != __* ]] && [[ $1 != --help ]]; then
|
||||||
if ! in_container; then
|
if ! in_container; then
|
||||||
! required_commands lxc && lxd_info && exit 42
|
! required_commands lxc && lxd_info && exit 42
|
||||||
fi
|
fi
|
||||||
|
@ -146,27 +144,40 @@ main() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
--getenv) var="$2"; echo "${!var}"; exit 0;;
|
--getenv)
|
||||||
-h|--help) usage; exit 0;;
|
var="$2"
|
||||||
|
echo "${!var}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-h | --help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
build)
|
build)
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
case $2 in
|
case $2 in
|
||||||
${LXC_HOST_PREFIX}-*) build_container "$2" ;;
|
${LXC_HOST_PREFIX}-*) build_container "$2" ;;
|
||||||
''|--|containers) build_all_containers ;;
|
'' | -- | containers) build_all_containers ;;
|
||||||
*) usage "$_usage"; exit 42;;
|
*)
|
||||||
|
usage "$_usage"
|
||||||
|
exit 42
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
copy)
|
copy)
|
||||||
case $2 in
|
case $2 in
|
||||||
''|images) lxc_copy_images_locally;;
|
'' | images) lxc_copy_images_locally ;;
|
||||||
*) usage "$_usage"; exit 42;;
|
*)
|
||||||
|
usage "$_usage"
|
||||||
|
exit 42
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
remove)
|
remove)
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
case $2 in
|
case $2 in
|
||||||
''|--|containers) remove_containers ;;
|
'' | -- | containers) remove_containers ;;
|
||||||
images) lxc_delete_images_locally ;;
|
images) lxc_delete_images_locally ;;
|
||||||
${LXC_HOST_PREFIX}-*)
|
${LXC_HOST_PREFIX}-*)
|
||||||
! lxc_exists "$2" && warn_msg "container not yet exists: $2" && exit 0
|
! lxc_exists "$2" && warn_msg "container not yet exists: $2" && exit 0
|
||||||
|
@ -174,19 +185,25 @@ main() {
|
||||||
lxc_delete_container "$2"
|
lxc_delete_container "$2"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) usage "unknown or missing container <name> $2"; exit 42;;
|
*)
|
||||||
|
usage "unknown or missing container <name> $2"
|
||||||
|
exit 42
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
start|stop)
|
start | stop)
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
case $2 in
|
case $2 in
|
||||||
''|--|containers) lxc_cmd "$1" ;;
|
'' | -- | containers) lxc_cmd "$1" ;;
|
||||||
${LXC_HOST_PREFIX}-*)
|
${LXC_HOST_PREFIX}-*)
|
||||||
! lxc_exists "$2" && usage_containers "unknown container: $2" && exit 42
|
! lxc_exists "$2" && usage_containers "unknown container: $2" && exit 42
|
||||||
info_msg "lxc $1 $2"
|
info_msg "lxc $1 $2"
|
||||||
lxc "$1" "$2" | prefix_stdout "[${_BBlue}${i}${_creset}] "
|
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
|
esac
|
||||||
;;
|
;;
|
||||||
show)
|
show)
|
||||||
|
@ -195,10 +212,10 @@ main() {
|
||||||
suite)
|
suite)
|
||||||
case $3 in
|
case $3 in
|
||||||
${LXC_HOST_PREFIX}-*)
|
${LXC_HOST_PREFIX}-*)
|
||||||
lxc exec -t "$3" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite \
|
lxc exec -t "$3" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite |
|
||||||
| prefix_stdout "[${_BBlue}$3${_creset}] "
|
prefix_stdout "[${_BBlue}$3${_creset}] "
|
||||||
;;
|
;;
|
||||||
*) show_suite;;
|
*) show_suite ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
images) show_images ;;
|
images) show_images ;;
|
||||||
|
@ -230,7 +247,10 @@ main() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*) usage "$_usage"; exit 42;;
|
*)
|
||||||
|
usage "$_usage"
|
||||||
|
exit 42
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
__show)
|
__show)
|
||||||
|
@ -243,30 +263,36 @@ main() {
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
shift
|
shift
|
||||||
case $1 in
|
case $1 in
|
||||||
--) shift; lxc_exec "$@" ;;
|
--)
|
||||||
|
shift
|
||||||
|
lxc_exec "$@"
|
||||||
|
;;
|
||||||
${LXC_HOST_PREFIX}-*)
|
${LXC_HOST_PREFIX}-*)
|
||||||
! lxc_exists "$1" && usage_containers "unknown container: $1" && exit 42
|
! lxc_exists "$1" && usage_containers "unknown container: $1" && exit 42
|
||||||
local name=$1
|
local name=$1
|
||||||
shift
|
shift
|
||||||
lxc_exec_cmd "${name}" "$@"
|
lxc_exec_cmd "${name}" "$@"
|
||||||
;;
|
;;
|
||||||
*) usage_containers "unknown container: $1" && exit 42
|
*) usage_containers "unknown container: $1" && exit 42 ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
case $2 in
|
case $2 in
|
||||||
suite|base)
|
suite | base)
|
||||||
case $3 in
|
case $3 in
|
||||||
${LXC_HOST_PREFIX}-*)
|
${LXC_HOST_PREFIX}-*)
|
||||||
! lxc_exists "$3" && usage_containers "unknown container: $3" && exit 42
|
! lxc_exists "$3" && usage_containers "unknown container: $3" && exit 42
|
||||||
lxc_exec_cmd "$3" "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2"
|
lxc_exec_cmd "$3" "${LXC_REPO_ROOT}/utils/lxc.sh" __install "$2"
|
||||||
;;
|
;;
|
||||||
''|--) lxc_exec "${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
|
esac
|
||||||
;;
|
;;
|
||||||
*) usage "$_usage"; exit 42 ;;
|
*)
|
||||||
|
usage "$_usage"
|
||||||
|
exit 42
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
__install)
|
__install)
|
||||||
|
@ -281,12 +307,17 @@ main() {
|
||||||
echo
|
echo
|
||||||
echo ".. generic utils/lxc.sh documentation"
|
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
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
build_all_containers() {
|
build_all_containers() {
|
||||||
rst_title "Build all LXC containers of suite"
|
rst_title "Build all LXC containers of suite"
|
||||||
echo
|
echo
|
||||||
|
@ -310,11 +341,11 @@ build_container() {
|
||||||
local image
|
local image
|
||||||
local boilerplate_script
|
local boilerplate_script
|
||||||
|
|
||||||
for ((i=0; i<${#LXC_SUITE[@]}; i+=2)); do
|
for ((i = 0; i < ${#LXC_SUITE[@]}; i += 2)); do
|
||||||
if [ "${LXC_HOST_PREFIX}-${LXC_SUITE[i+1]}" = "$1" ]; then
|
if [ "${LXC_HOST_PREFIX}-${LXC_SUITE[i + 1]}" = "$1" ]; then
|
||||||
remote_image="${LXC_SUITE[i]}"
|
remote_image="${LXC_SUITE[i]}"
|
||||||
container="${LXC_HOST_PREFIX}-${LXC_SUITE[i+1]}"
|
container="${LXC_HOST_PREFIX}-${LXC_SUITE[i + 1]}"
|
||||||
image="${LXC_SUITE[i+1]}"
|
image="${LXC_SUITE[i + 1]}"
|
||||||
boilerplate_script="${image}_boilerplate"
|
boilerplate_script="${image}_boilerplate"
|
||||||
boilerplate_script="${!boilerplate_script}"
|
boilerplate_script="${!boilerplate_script}"
|
||||||
break
|
break
|
||||||
|
@ -335,8 +366,8 @@ build_container() {
|
||||||
lxc_install_boilerplate "${container}" "$boilerplate_script"
|
lxc_install_boilerplate "${container}" "$boilerplate_script"
|
||||||
echo
|
echo
|
||||||
rst_title "install LXC base packages" section
|
rst_title "install LXC base packages" section
|
||||||
lxc_exec_cmd "${container}" "${LXC_REPO_ROOT}/utils/lxc.sh" __install base \
|
lxc_exec_cmd "${container}" "${LXC_REPO_ROOT}/utils/lxc.sh" __install base |
|
||||||
| prefix_stdout "[${_BBlue}${container}${_creset}] "
|
prefix_stdout "[${_BBlue}${container}${_creset}] "
|
||||||
echo
|
echo
|
||||||
lxc list "$container"
|
lxc list "$container"
|
||||||
}
|
}
|
||||||
|
@ -348,7 +379,7 @@ remove_containers() {
|
||||||
lxc list "$LXC_HOST_PREFIX-"
|
lxc list "$LXC_HOST_PREFIX-"
|
||||||
echo -en "\\n${_BRed}LXC containers to delete::${_creset}\\n\\n ${CONTAINERS[*]}\\n" | $FMT
|
echo -en "\\n${_BRed}LXC containers to delete::${_creset}\\n\\n ${CONTAINERS[*]}\\n" | $FMT
|
||||||
local default=Ny
|
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
|
if ask_yn "Do you really want to delete these containers" $default; then
|
||||||
for i in "${CONTAINERS[@]}"; do
|
for i in "${CONTAINERS[@]}"; do
|
||||||
lxc_delete_container "$i"
|
lxc_delete_container "$i"
|
||||||
|
@ -363,8 +394,8 @@ remove_containers() {
|
||||||
|
|
||||||
lxc_copy_images_locally() {
|
lxc_copy_images_locally() {
|
||||||
rst_title "copy images" section
|
rst_title "copy images" section
|
||||||
for ((i=0; i<${#LXC_SUITE[@]}; i+=2)); do
|
for ((i = 0; i < ${#LXC_SUITE[@]}; i += 2)); do
|
||||||
lxc_image_copy "${LXC_SUITE[i]}" "${LXC_SUITE[i+1]}"
|
lxc_image_copy "${LXC_SUITE[i]}" "${LXC_SUITE[i + 1]}"
|
||||||
done
|
done
|
||||||
# lxc image list local: && wait_key
|
# lxc image list local: && wait_key
|
||||||
}
|
}
|
||||||
|
@ -391,7 +422,7 @@ lxc_delete_images_locally() {
|
||||||
lxc image list local:
|
lxc image list local:
|
||||||
}
|
}
|
||||||
|
|
||||||
show_images(){
|
show_images() {
|
||||||
rst_title "local images"
|
rst_title "local images"
|
||||||
echo
|
echo
|
||||||
lxc image list local:
|
lxc image list local:
|
||||||
|
@ -408,11 +439,10 @@ show_images(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# container
|
# container
|
||||||
# ---------
|
# ---------
|
||||||
|
|
||||||
show_suite(){
|
show_suite() {
|
||||||
rst_title "LXC suite ($LXC_HOST_PREFIX-*)"
|
rst_title "LXC suite ($LXC_HOST_PREFIX-*)"
|
||||||
echo
|
echo
|
||||||
lxc list "$LXC_HOST_PREFIX-"
|
lxc list "$LXC_HOST_PREFIX-"
|
||||||
|
@ -421,8 +451,8 @@ show_suite(){
|
||||||
if ! lxc_exists "$i"; then
|
if ! lxc_exists "$i"; then
|
||||||
warn_msg "container ${_BBlue}$i${_creset} does not yet exists"
|
warn_msg "container ${_BBlue}$i${_creset} does not yet exists"
|
||||||
else
|
else
|
||||||
lxc exec -t "${i}" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite \
|
lxc exec -t "${i}" -- "${LXC_REPO_ROOT}/utils/lxc.sh" __show suite |
|
||||||
| prefix_stdout "[${_BBlue}${i}${_creset}] "
|
prefix_stdout "[${_BBlue}${i}${_creset}] "
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -469,8 +499,8 @@ lxc_init_all_containers() {
|
||||||
local image_name
|
local image_name
|
||||||
local container_name
|
local container_name
|
||||||
|
|
||||||
for ((i=0; i<${#LXC_SUITE[@]}; i+=2)); do
|
for ((i = 0; i < ${#LXC_SUITE[@]}; i += 2)); do
|
||||||
lxc_init_container "${LXC_SUITE[i+1]}" "${LXC_HOST_PREFIX}-${LXC_SUITE[i+1]}"
|
lxc_init_container "${LXC_SUITE[i + 1]}" "${LXC_HOST_PREFIX}-${LXC_SUITE[i + 1]}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,8 +517,8 @@ lxc_config_container() {
|
||||||
|
|
||||||
info_msg "[${_BBlue}$1${_creset}] map uid/gid from host to container"
|
info_msg "[${_BBlue}$1${_creset}] map uid/gid from host to container"
|
||||||
# https://lxd.readthedocs.io/en/latest/userns-idmap/#custom-idmaps
|
# https://lxd.readthedocs.io/en/latest/userns-idmap/#custom-idmaps
|
||||||
echo -e -n "uid $HOST_USER_ID 0\\ngid $HOST_GROUP_ID 0"\
|
echo -e -n "uid $HOST_USER_ID 0\\ngid $HOST_GROUP_ID 0" |
|
||||||
| lxc config set "$1" raw.idmap -
|
lxc config set "$1" raw.idmap -
|
||||||
|
|
||||||
info_msg "[${_BBlue}$1${_creset}] share ${REPO_ROOT} (repo_share) from HOST into container"
|
info_msg "[${_BBlue}$1${_creset}] share ${REPO_ROOT} (repo_share) from HOST into container"
|
||||||
# https://lxd.readthedocs.io/en/latest/instances/#type-disk
|
# https://lxd.readthedocs.io/en/latest/instances/#type-disk
|
||||||
|
@ -504,15 +534,15 @@ lxc_boilerplate_all_containers() {
|
||||||
local boilerplate_script
|
local boilerplate_script
|
||||||
local image_name
|
local image_name
|
||||||
|
|
||||||
for ((i=0; i<${#LXC_SUITE[@]}; i+=2)); do
|
for ((i = 0; i < ${#LXC_SUITE[@]}; i += 2)); do
|
||||||
|
|
||||||
image_name="${LXC_SUITE[i+1]}"
|
image_name="${LXC_SUITE[i + 1]}"
|
||||||
boilerplate_script="${image_name}_boilerplate"
|
boilerplate_script="${image_name}_boilerplate"
|
||||||
boilerplate_script="${!boilerplate_script}"
|
boilerplate_script="${!boilerplate_script}"
|
||||||
|
|
||||||
lxc_install_boilerplate "${LXC_HOST_PREFIX}-${image_name}" "$boilerplate_script"
|
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}'"
|
err_msg "[${_BBlue}${container_name}${_creset}] no boilerplate for image '${image_name}'"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -546,10 +576,10 @@ EOF
|
||||||
if lxc start -q "${container_name}" &>/dev/null; then
|
if lxc start -q "${container_name}" &>/dev/null; then
|
||||||
sleep 5 # guest needs some time to come up and get an IP
|
sleep 5 # guest needs some time to come up and get an IP
|
||||||
fi
|
fi
|
||||||
if [[ -n "${boilerplate_script}" ]]; then
|
if [[ -n ${boilerplate_script} ]]; then
|
||||||
echo "${boilerplate_script}" \
|
echo "${boilerplate_script}" |
|
||||||
| lxc exec "${container_name}" -- bash \
|
lxc exec "${container_name}" -- bash |
|
||||||
| prefix_stdout "[${_BBlue}${container_name}${_creset}] "
|
prefix_stdout "[${_BBlue}${container_name}${_creset}] "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,6 +598,4 @@ check_connectivity() {
|
||||||
return $ret_val
|
return $ret_val
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
main "$@"
|
main "$@"
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
|
|
151
utils/searxng.sh
151
utils/searxng.sh
|
@ -46,7 +46,7 @@ if in_container; then
|
||||||
SEARXNG_URL="http://$(primary_ip)/searxng"
|
SEARXNG_URL="http://$(primary_ip)/searxng"
|
||||||
fi
|
fi
|
||||||
SEARXNG_URL_PATH="$(echo "${SEARXNG_URL}" | sed -e 's,^.*://[^/]*\(/.*\),\1,g')"
|
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
|
# Apache settings
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ case $DIST_ID-$DIST_VERS in
|
||||||
SEARXNG_BUILD_PACKAGES="${SEARXNG_BUILD_PACKAGES_debian}"
|
SEARXNG_BUILD_PACKAGES="${SEARXNG_BUILD_PACKAGES_debian}"
|
||||||
APACHE_PACKAGES="$APACHE_PACKAGES libapache2-mod-proxy-uwsgi"
|
APACHE_PACKAGES="$APACHE_PACKAGES libapache2-mod-proxy-uwsgi"
|
||||||
;;
|
;;
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
SEARXNG_PACKAGES="${SEARXNG_PACKAGES_debian} python-is-python3"
|
SEARXNG_PACKAGES="${SEARXNG_PACKAGES_debian} python-is-python3"
|
||||||
SEARXNG_BUILD_PACKAGES="${SEARXNG_BUILD_PACKAGES_debian}"
|
SEARXNG_BUILD_PACKAGES="${SEARXNG_BUILD_PACKAGES_debian}"
|
||||||
;;
|
;;
|
||||||
|
@ -114,9 +114,7 @@ esac
|
||||||
|
|
||||||
_service_prefix=" ${_Yellow}|${SERVICE_USER}|${_creset} "
|
_service_prefix=" ${_Yellow}|${SERVICE_USER}|${_creset} "
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
usage() {
|
usage() {
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
@ -170,52 +168,68 @@ EOF
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
case $1 in
|
case $1 in
|
||||||
install|remove|instance)
|
install | remove | instance)
|
||||||
nginx_distro_setup
|
nginx_distro_setup
|
||||||
apache_distro_setup
|
apache_distro_setup
|
||||||
uWSGI_distro_setup
|
uWSGI_distro_setup
|
||||||
required_commands \
|
required_commands \
|
||||||
sudo systemctl install git wget curl \
|
sudo systemctl install git wget curl ||
|
||||||
|| exit
|
exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
local _usage="unknown or missing $1 command $2"
|
local _usage="unknown or missing $1 command $2"
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
--getenv) var="$2"; echo "${!var}"; exit 0;;
|
--getenv)
|
||||||
--cmd) shift; "$@";;
|
var="$2"
|
||||||
-h|--help) usage; exit 0;;
|
echo "${!var}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--cmd)
|
||||||
|
shift
|
||||||
|
"$@"
|
||||||
|
;;
|
||||||
|
-h | --help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
install)
|
install)
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
case $2 in
|
case $2 in
|
||||||
all) searxng.install.all;;
|
all) searxng.install.all ;;
|
||||||
user) searxng.install.user;;
|
user) searxng.install.user ;;
|
||||||
pyenv) searxng.install.pyenv;;
|
pyenv) searxng.install.pyenv ;;
|
||||||
searxng-src) searxng.install.clone;;
|
searxng-src) searxng.install.clone ;;
|
||||||
settings) searxng.install.settings;;
|
settings) searxng.install.settings ;;
|
||||||
uwsgi) searxng.install.uwsgi;;
|
uwsgi) searxng.install.uwsgi ;;
|
||||||
packages) searxng.install.packages;;
|
packages) searxng.install.packages ;;
|
||||||
buildhost) searxng.install.buildhost;;
|
buildhost) searxng.install.buildhost ;;
|
||||||
nginx) searxng.nginx.install;;
|
nginx) searxng.nginx.install ;;
|
||||||
apache) searxng.apache.install;;
|
apache) searxng.apache.install ;;
|
||||||
valkey) searxng.install.valkey;;
|
valkey) searxng.install.valkey ;;
|
||||||
*) usage "$_usage"; exit 42;;
|
*)
|
||||||
|
usage "$_usage"
|
||||||
|
exit 42
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
remove)
|
remove)
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
case $2 in
|
case $2 in
|
||||||
all) searxng.remove.all;;
|
all) searxng.remove.all ;;
|
||||||
user) drop_service_account "${SERVICE_USER}";;
|
user) drop_service_account "${SERVICE_USER}" ;;
|
||||||
pyenv) searxng.remove.pyenv;;
|
pyenv) searxng.remove.pyenv ;;
|
||||||
settings) searxng.remove.settings;;
|
settings) searxng.remove.settings ;;
|
||||||
uwsgi) searxng.remove.uwsgi;;
|
uwsgi) searxng.remove.uwsgi ;;
|
||||||
apache) searxng.apache.remove;;
|
apache) searxng.apache.remove ;;
|
||||||
remove) searxng.nginx.remove;;
|
remove) searxng.nginx.remove ;;
|
||||||
valkey) searxng.remove.valkey;;
|
valkey) searxng.remove.valkey ;;
|
||||||
redis) searxng.remove.redis;;
|
redis) searxng.remove.redis ;;
|
||||||
*) usage "$_usage"; exit 42;;
|
*)
|
||||||
|
usage "$_usage"
|
||||||
|
exit 42
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
instance)
|
instance)
|
||||||
|
@ -234,19 +248,30 @@ main() {
|
||||||
;;
|
;;
|
||||||
cmd)
|
cmd)
|
||||||
sudo_or_exit
|
sudo_or_exit
|
||||||
shift; shift; searxng.instance.exec "$@"
|
shift
|
||||||
|
shift
|
||||||
|
searxng.instance.exec "$@"
|
||||||
;;
|
;;
|
||||||
get_setting)
|
get_setting)
|
||||||
shift; shift; searxng.instance.get_setting "$@"
|
shift
|
||||||
|
shift
|
||||||
|
searxng.instance.get_setting "$@"
|
||||||
;;
|
;;
|
||||||
call)
|
call)
|
||||||
# call a function in instance's environment
|
# call a function in instance's environment
|
||||||
shift; shift; searxng.instance.self.call "$@"
|
shift
|
||||||
|
shift
|
||||||
|
searxng.instance.self.call "$@"
|
||||||
;;
|
;;
|
||||||
_call)
|
_call)
|
||||||
shift; shift; "$@"
|
shift
|
||||||
|
shift
|
||||||
|
"$@"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage "$_usage"
|
||||||
|
exit 42
|
||||||
;;
|
;;
|
||||||
*) usage "$_usage"; exit 42;;
|
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -314,7 +339,7 @@ In your instance, valkey DB connector is configured at:
|
||||||
fi
|
fi
|
||||||
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"
|
err_msg "SearXNG instance can't connect valkey DB / check valkey & your settings"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -352,7 +377,7 @@ searxng.remove.all() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
valkey_url=$(searxng.instance.get_setting valkey.url)
|
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
|
searxng.remove.valkey
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -369,7 +394,7 @@ searxng.remove.all() {
|
||||||
searxng.install.user() {
|
searxng.install.user() {
|
||||||
rst_title "SearXNG -- install user" section
|
rst_title "SearXNG -- install user" section
|
||||||
echo
|
echo
|
||||||
if getent passwd "${SERVICE_USER}" > /dev/null; then
|
if getent passwd "${SERVICE_USER}" >/dev/null; then
|
||||||
echo "user already exists"
|
echo "user already exists"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -399,11 +424,11 @@ searxng.install.clone() {
|
||||||
die 42 "To clone SearXNG, first install user ${SERVICE_USER}."
|
die 42 "To clone SearXNG, first install user ${SERVICE_USER}."
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
if ! sudo -i -u "${SERVICE_USER}" ls -d "$REPO_ROOT" > /dev/null; then
|
if ! sudo -i -u "${SERVICE_USER}" ls -d "$REPO_ROOT" >/dev/null; then
|
||||||
die 42 "user '${SERVICE_USER}' missed read permission: $REPO_ROOT"
|
die 42 "user '${SERVICE_USER}' missed read permission: $REPO_ROOT"
|
||||||
fi
|
fi
|
||||||
# SERVICE_HOME="$(sudo -i -u "${SERVICE_USER}" echo \$HOME 2>/dev/null)"
|
# 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"
|
err_msg "to clone SearXNG sources, user ${SERVICE_USER} hast to be created first"
|
||||||
return 42
|
return 42
|
||||||
fi
|
fi
|
||||||
|
@ -412,7 +437,7 @@ searxng.install.clone() {
|
||||||
info_msg "create local branch ${GIT_BRANCH} from start point: origin/${GIT_BRANCH}"
|
info_msg "create local branch ${GIT_BRANCH} from start point: origin/${GIT_BRANCH}"
|
||||||
git branch "${GIT_BRANCH}" "origin/${GIT_BRANCH}"
|
git branch "${GIT_BRANCH}" "origin/${GIT_BRANCH}"
|
||||||
fi
|
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)"
|
warn_msg "take into account, installing branch $GIT_BRANCH while current branch is $(git rev-parse --abbrev-ref HEAD)"
|
||||||
fi
|
fi
|
||||||
# export SERVICE_HOME
|
# export SERVICE_HOME
|
||||||
|
@ -424,7 +449,7 @@ searxng.install.clone() {
|
||||||
"$GIT_BRANCH" "${SERVICE_USER}"
|
"$GIT_BRANCH" "${SERVICE_USER}"
|
||||||
git config --system --add safe.directory "${SEARXNG_SRC}"
|
git config --system --add safe.directory "${SEARXNG_SRC}"
|
||||||
|
|
||||||
pushd "${SEARXNG_SRC}" > /dev/null
|
pushd "${SEARXNG_SRC}" >/dev/null
|
||||||
tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
|
tee_stderr 0.1 <<EOF | sudo -H -u "${SERVICE_USER}" -i 2>&1 | prefix_stdout "$_service_prefix"
|
||||||
cd "${SEARXNG_SRC}"
|
cd "${SEARXNG_SRC}"
|
||||||
git remote set-url origin ${GIT_URL}
|
git remote set-url origin ${GIT_URL}
|
||||||
|
@ -432,7 +457,7 @@ git config user.email "${ADMIN_EMAIL}"
|
||||||
git config user.name "${ADMIN_NAME}"
|
git config user.name "${ADMIN_NAME}"
|
||||||
git config --list
|
git config --list
|
||||||
EOF
|
EOF
|
||||||
popd > /dev/null
|
popd >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
searxng.install.link_src() {
|
searxng.install.link_src() {
|
||||||
|
@ -588,9 +613,9 @@ searxng.install.uwsgi.socket() {
|
||||||
|
|
||||||
searxng.uwsgi.available() {
|
searxng.uwsgi.available() {
|
||||||
if [[ ${SEARXNG_UWSGI_USE_SOCKET} == true ]]; then
|
if [[ ${SEARXNG_UWSGI_USE_SOCKET} == true ]]; then
|
||||||
[[ -S "${SEARXNG_UWSGI_SOCKET}" ]]
|
[[ -S ${SEARXNG_UWSGI_SOCKET} ]]
|
||||||
exit_val=$?
|
exit_val=$?
|
||||||
if [[ $exit_val = 0 ]]; then
|
if [[ $exit_val == 0 ]]; then
|
||||||
info_msg "uWSGI socket is located at: ${SEARXNG_UWSGI_SOCKET}"
|
info_msg "uWSGI socket is located at: ${SEARXNG_UWSGI_SOCKET}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -617,10 +642,9 @@ searxng.install.valkey() {
|
||||||
valkey.install
|
valkey.install
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
searxng.instance.localtest() {
|
searxng.instance.localtest() {
|
||||||
rst_title "Test SearXNG instance locally" section
|
rst_title "Test SearXNG instance locally" section
|
||||||
rst_para "Activate debug mode, start a minimal SearXNG "\
|
rst_para "Activate debug mode, start a minimal SearXNG " \
|
||||||
"service and debug a HTTP request/response cycle."
|
"service and debug a HTTP request/response cycle."
|
||||||
|
|
||||||
if service_is_available "http://${SEARXNG_INTERNAL_HTTP}" &>/dev/null; then
|
if service_is_available "http://${SEARXNG_INTERNAL_HTTP}" &>/dev/null; then
|
||||||
|
@ -714,7 +738,7 @@ This installs SearXNG's uWSGI app as Nginx site. The Nginx site is located at:
|
||||||
${NGINX_APPS_AVAILABLE}/${NGINX_SEARXNG_SITE} and requires a uWSGI."
|
${NGINX_APPS_AVAILABLE}/${NGINX_SEARXNG_SITE} and requires a uWSGI."
|
||||||
searxng.install.http.pre
|
searxng.install.http.pre
|
||||||
|
|
||||||
if ! nginx_is_installed ; then
|
if ! nginx_is_installed; then
|
||||||
err_msg "Nginx packages are not installed"
|
err_msg "Nginx packages are not installed"
|
||||||
if ! ask_yn "Do you really want to continue and install Nginx packages?" Yn; then
|
if ! ask_yn "Do you really want to continue and install Nginx packages?" Yn; then
|
||||||
return
|
return
|
||||||
|
@ -805,7 +829,7 @@ searxng.instance.inspect() {
|
||||||
echo
|
echo
|
||||||
|
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*)
|
ubuntu-* | debian-*)
|
||||||
# For uWSGI debian uses the LSB init process; for each configuration
|
# For uWSGI debian uses the LSB init process; for each configuration
|
||||||
# file new uWSGI daemon instance is started with additional option.
|
# file new uWSGI daemon instance is started with additional option.
|
||||||
service uwsgi status "${SERVICE_NAME}"
|
service uwsgi status "${SERVICE_NAME}"
|
||||||
|
@ -825,7 +849,7 @@ searxng.instance.inspect() {
|
||||||
while true; do
|
while true; do
|
||||||
trap break 2
|
trap break 2
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*) tail -f "/var/log/uwsgi/app/${SERVICE_NAME%.*}.log" ;;
|
ubuntu-* | debian-*) tail -f "/var/log/uwsgi/app/${SERVICE_NAME%.*}.log" ;;
|
||||||
arch-*) journalctl -f -u "uwsgi@${SERVICE_NAME%.*}" ;;
|
arch-*) journalctl -f -u "uwsgi@${SERVICE_NAME%.*}" ;;
|
||||||
fedora-*) journalctl -f -u uwsgi ;;
|
fedora-*) journalctl -f -u uwsgi ;;
|
||||||
esac
|
esac
|
||||||
|
@ -882,7 +906,7 @@ searxng.doc.rst() {
|
||||||
uwsgi_variant=':socket'
|
uwsgi_variant=':socket'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval "echo \"$(< "${REPO_ROOT}/docs/build-templates/searxng.rst")\""
|
eval "echo \"$(<"${REPO_ROOT}/docs/build-templates/searxng.rst")\""
|
||||||
|
|
||||||
# I use ubuntu-20.04 here to demonstrate that versions are also supported,
|
# I use ubuntu-20.04 here to demonstrate that versions are also supported,
|
||||||
# normally debian-* and ubuntu-* are most the same.
|
# normally debian-* and ubuntu-* are most the same.
|
||||||
|
@ -897,7 +921,8 @@ searxng.doc.rst() {
|
||||||
echo -e "\n.. START searxng uwsgi-description $DIST_NAME"
|
echo -e "\n.. START searxng uwsgi-description $DIST_NAME"
|
||||||
|
|
||||||
case $DIST_ID-$DIST_VERS in
|
case $DIST_ID-$DIST_VERS in
|
||||||
ubuntu-*|debian-*) cat <<EOF
|
ubuntu-* | debian-*)
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
|
@ -914,7 +939,8 @@ searxng.doc.rst() {
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
arch-*) cat <<EOF
|
arch-*)
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
|
@ -932,7 +958,8 @@ EOF
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
fedora-*|centos-7) cat <<EOF
|
fedora-* | centos-7)
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
|
@ -954,37 +981,35 @@ EOF
|
||||||
echo -e "\n.. START searxng uwsgi-appini $DIST_NAME"
|
echo -e "\n.. START searxng uwsgi-appini $DIST_NAME"
|
||||||
echo ".. code:: bash"
|
echo ".. code:: bash"
|
||||||
echo
|
echo
|
||||||
eval "echo \"$(< "${TEMPLATES}/${uWSGI_APPS_AVAILABLE}/${SEARXNG_UWSGI_APP}${uwsgi_variant}")\"" | prefix_stdout " "
|
eval "echo \"$(<"${TEMPLATES}/${uWSGI_APPS_AVAILABLE}/${SEARXNG_UWSGI_APP}${uwsgi_variant}")\"" | prefix_stdout " "
|
||||||
echo -e "\n.. END searxng uwsgi-appini $DIST_NAME"
|
echo -e "\n.. END searxng uwsgi-appini $DIST_NAME"
|
||||||
|
|
||||||
echo -e "\n.. START nginx socket"
|
echo -e "\n.. START nginx socket"
|
||||||
echo ".. code:: nginx"
|
echo ".. code:: nginx"
|
||||||
echo
|
echo
|
||||||
eval "echo \"$(< "${TEMPLATES}/${NGINX_APPS_AVAILABLE}/${NGINX_SEARXNG_SITE}:socket")\"" | prefix_stdout " "
|
eval "echo \"$(<"${TEMPLATES}/${NGINX_APPS_AVAILABLE}/${NGINX_SEARXNG_SITE}:socket")\"" | prefix_stdout " "
|
||||||
echo -e "\n.. END nginx socket"
|
echo -e "\n.. END nginx socket"
|
||||||
|
|
||||||
echo -e "\n.. START nginx http"
|
echo -e "\n.. START nginx http"
|
||||||
echo ".. code:: nginx"
|
echo ".. code:: nginx"
|
||||||
echo
|
echo
|
||||||
eval "echo \"$(< "${TEMPLATES}/${NGINX_APPS_AVAILABLE}/${NGINX_SEARXNG_SITE}")\"" | prefix_stdout " "
|
eval "echo \"$(<"${TEMPLATES}/${NGINX_APPS_AVAILABLE}/${NGINX_SEARXNG_SITE}")\"" | prefix_stdout " "
|
||||||
echo -e "\n.. END nginx http"
|
echo -e "\n.. END nginx http"
|
||||||
|
|
||||||
echo -e "\n.. START apache socket"
|
echo -e "\n.. START apache socket"
|
||||||
echo ".. code:: apache"
|
echo ".. code:: apache"
|
||||||
echo
|
echo
|
||||||
eval "echo \"$(< "${TEMPLATES}/${APACHE_SITES_AVAILABLE}/${APACHE_SEARXNG_SITE}:socket")\"" | prefix_stdout " "
|
eval "echo \"$(<"${TEMPLATES}/${APACHE_SITES_AVAILABLE}/${APACHE_SEARXNG_SITE}:socket")\"" | prefix_stdout " "
|
||||||
echo -e "\n.. END apache socket"
|
echo -e "\n.. END apache socket"
|
||||||
|
|
||||||
echo -e "\n.. START apache http"
|
echo -e "\n.. START apache http"
|
||||||
echo ".. code:: apache"
|
echo ".. code:: apache"
|
||||||
echo
|
echo
|
||||||
eval "echo \"$(< "${TEMPLATES}/${APACHE_SITES_AVAILABLE}/${APACHE_SEARXNG_SITE}")\"" | prefix_stdout " "
|
eval "echo \"$(<"${TEMPLATES}/${APACHE_SITES_AVAILABLE}/${APACHE_SEARXNG_SITE}")\"" | prefix_stdout " "
|
||||||
echo -e "\n.. END apache http"
|
echo -e "\n.. END apache http"
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
main "$@"
|
main "$@"
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue