forked from Ponysearch/Ponysearch
LXC: from searx.sh, morty.sh and filtron.sh tests
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
b1e90cff23
commit
e7f69b63f1
4 changed files with 101 additions and 43 deletions
|
@ -7,6 +7,7 @@
|
||||||
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
||||||
source_dot_config
|
source_dot_config
|
||||||
source "${REPO_ROOT}/utils/lxc-searx.env"
|
source "${REPO_ROOT}/utils/lxc-searx.env"
|
||||||
|
in_container && lxc_set_suite_env
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# config
|
# config
|
||||||
|
@ -329,16 +330,25 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! service_is_available "${PUBLIC_URL}"; then
|
if ! service_is_available "${PUBLIC_URL}"; then
|
||||||
err_msg "Public service at ${PUBLIC_URL} is not available!"
|
warn_msg "Public service at ${PUBLIC_URL} is not available!"
|
||||||
wait_key
|
if ! in_container; then
|
||||||
|
warn_msg "Check if public name is correct and routed or use the public IP from above."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if in_container; then
|
||||||
|
lxc_suite_info
|
||||||
|
else
|
||||||
|
info_msg "public URL --> ${PUBLIC_URL}"
|
||||||
|
info_msg "internal URL --> http://${FILTRON_LISTEN}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
local _debug_on
|
local _debug_on
|
||||||
if ask_yn "Enable filtron debug mode?"; then
|
if ask_yn "Enable filtron debug mode?"; then
|
||||||
enable_debug
|
enable_debug
|
||||||
_debug_on=1
|
_debug_on=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
systemctl --no-pager -l status "${SERVICE_NAME}"
|
systemctl --no-pager -l status "${SERVICE_NAME}"
|
||||||
echo
|
echo
|
||||||
|
@ -346,7 +356,7 @@ EOF
|
||||||
info_msg "public URL --> ${PUBLIC_URL}"
|
info_msg "public URL --> ${PUBLIC_URL}"
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"
|
printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"
|
||||||
read -r -s -n1 -t 2
|
read -r -s -n1 -t 5
|
||||||
echo
|
echo
|
||||||
while true; do
|
while true; do
|
||||||
trap break 2
|
trap break 2
|
||||||
|
|
38
utils/lxc.sh
38
utils/lxc.sh
|
@ -108,15 +108,29 @@ cmd
|
||||||
install
|
install
|
||||||
:suite: install LXC suite, includes morty & filtron
|
:suite: install LXC suite, includes morty & filtron
|
||||||
|
|
||||||
Images of the LXC suite:
|
EOF
|
||||||
$(echo " ${LOCAL_IMAGES[*]}" | $FMT)
|
usage_images
|
||||||
|
echo
|
||||||
|
usage_containers
|
||||||
|
echo
|
||||||
|
[ -n "${1+x}" ] && err_msg "$1"
|
||||||
|
}
|
||||||
|
|
||||||
Containers of the LXC suite:
|
usage_containers() {
|
||||||
|
cat <<EOF
|
||||||
|
LXC suite containers:
|
||||||
$(echo " ${CONTAINERS[*]}" | $FMT)
|
$(echo " ${CONTAINERS[*]}" | $FMT)
|
||||||
EOF
|
EOF
|
||||||
[ -n "${1+x}" ] && err_msg "$1"
|
[ -n "${1+x}" ] && err_msg "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usage_images() {
|
||||||
|
cat <<EOF
|
||||||
|
LXC suite images:
|
||||||
|
$(echo " ${LOCAL_IMAGES[*]}" | $FMT)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
lxd_info() {
|
lxd_info() {
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
@ -164,11 +178,12 @@ main() {
|
||||||
images) lxc_delete_images_localy ;;
|
images) lxc_delete_images_localy ;;
|
||||||
subordinate) echo; del_subordinate_ids ;;
|
subordinate) echo; del_subordinate_ids ;;
|
||||||
${LXC_HOST_PREFIX}-*)
|
${LXC_HOST_PREFIX}-*)
|
||||||
|
! lxc_exists "$2" && usage_containers "unknown container: $2" && exit 42
|
||||||
if ask_yn "Do you really want to delete conatiner $2"; then
|
if ask_yn "Do you really want to delete conatiner $2"; then
|
||||||
lxc_delete_container "$2"
|
lxc_delete_container "$2"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) usage "unknown (or mising) container <name> $2"; exit 42;;
|
*) usage "uknown or missing container <name> $2"; exit 42;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
add)
|
add)
|
||||||
|
@ -183,10 +198,11 @@ main() {
|
||||||
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
|
||||||
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 "ukknown or missing container <name> $2"; exit 42;;
|
*) usage "uknown or missing container <name> $2"; exit 42;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
show)
|
show)
|
||||||
|
@ -225,13 +241,12 @@ main() {
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
${LXC_HOST_PREFIX}-*)
|
${LXC_HOST_PREFIX}-*)
|
||||||
|
! 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 "uknown or missing container <name> $2"; exit 42;;
|
||||||
*) usage "unknown <name>: $1"; exit 42
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
|
@ -351,6 +366,7 @@ show_suite(){
|
||||||
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
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -384,12 +400,12 @@ lxc_exec_cmd() {
|
||||||
shift
|
shift
|
||||||
exit_val=
|
exit_val=
|
||||||
info_msg "[${_BBlue}${name}${_creset}] ${_BGreen}${*}${_creset}"
|
info_msg "[${_BBlue}${name}${_creset}] ${_BGreen}${*}${_creset}"
|
||||||
lxc exec "${name}" -- "$@"
|
lxc exec --cwd "${LXC_REPO_ROOT}" "${name}" -- "$@"
|
||||||
exit_val=$?
|
exit_val=$?
|
||||||
if [[ $exit_val -ne 0 ]]; then
|
if [[ $exit_val -ne 0 ]]; then
|
||||||
warn_msg "[${_BBlue}${i}${_creset}] exit code (${_BRed}${exit_val}${_creset}) from ${_BGreen}${*}${_creset}"
|
warn_msg "[${_BBlue}${name}${_creset}] exit code (${_BRed}${exit_val}${_creset}) from ${_BGreen}${*}${_creset}"
|
||||||
else
|
else
|
||||||
info_msg "[${_BBlue}${i}${_creset}] exit code (${exit_val}) from ${_BGreen}${*}${_creset}"
|
info_msg "[${_BBlue}${name}${_creset}] exit code (${exit_val}) from ${_BGreen}${*}${_creset}"
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
||||||
source_dot_config
|
source_dot_config
|
||||||
source "${REPO_ROOT}/utils/lxc-searx.env"
|
source "${REPO_ROOT}/utils/lxc-searx.env"
|
||||||
|
in_container && lxc_set_suite_env
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# config
|
# config
|
||||||
|
@ -83,7 +84,14 @@ ${DOT_CONFIG#"$REPO_ROOT/"} file::
|
||||||
|
|
||||||
MORTY_LISTEN : ${MORTY_LISTEN}
|
MORTY_LISTEN : ${MORTY_LISTEN}
|
||||||
SERVICE_USER : ${SERVICE_USER}
|
SERVICE_USER : ${SERVICE_USER}
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
if in_container; then
|
||||||
|
lxc_suite_info
|
||||||
|
else
|
||||||
|
info_msg "public URL --> ${PUBLIC_URL}"
|
||||||
|
info_msg "internal URL --> http://${SEARX_INTERNAL_URL}"
|
||||||
|
fi
|
||||||
info_searx
|
info_searx
|
||||||
[[ -n ${1} ]] && err_msg "$1"
|
[[ -n ${1} ]] && err_msg "$1"
|
||||||
}
|
}
|
||||||
|
@ -333,21 +341,32 @@ EOF
|
||||||
wait_key
|
wait_key
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local _debug_on
|
if ! service_is_available "${PUBLIC_URL}"; then
|
||||||
if ask_yn "Enable filtron debug mode?"; then
|
warn_msg "Public service at ${PUBLIC_URL} is not available!"
|
||||||
enable_debug
|
if ! in_container; then
|
||||||
_debug_on=1
|
warn_msg "Check if public name is correct and routed or use the public IP from above."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
if in_container; then
|
||||||
systemctl --no-pager -l status "${SERVICE_NAME}"
|
lxc_suite_info
|
||||||
|
else
|
||||||
|
info_msg "public URL --> ${PUBLIC_URL_MORTY}"
|
||||||
|
info_msg "morty URL --> http://${MORTY_LISTEN}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local _debug_on
|
||||||
|
if ask_yn "Enable filtron debug mode (needs reinstall of systemd service)?"; then
|
||||||
|
enable_debug
|
||||||
|
_debug_on=1
|
||||||
|
else
|
||||||
|
systemctl --no-pager -l status "${SERVICE_NAME}"
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
|
|
||||||
info_msg "morty URL --> http://${MORTY_LISTEN}"
|
|
||||||
info_msg "public URL --> ${PUBLIC_URL_MORTY}"
|
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"
|
printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"
|
||||||
read -r -s -n1 -t 2
|
read -r -s -n1 -t 5
|
||||||
echo
|
echo
|
||||||
while true; do
|
while true; do
|
||||||
trap break 2
|
trap break 2
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
||||||
source_dot_config
|
source_dot_config
|
||||||
source "${REPO_ROOT}/utils/lxc-searx.env"
|
source "${REPO_ROOT}/utils/lxc-searx.env"
|
||||||
|
in_container && lxc_set_suite_env
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# config
|
# config
|
||||||
|
@ -223,6 +224,11 @@ install_all() {
|
||||||
rst_title "Install $SEARX_INSTANCE_NAME (service)"
|
rst_title "Install $SEARX_INSTANCE_NAME (service)"
|
||||||
pkg_install "$SEARX_PACKAGES"
|
pkg_install "$SEARX_PACKAGES"
|
||||||
wait_key
|
wait_key
|
||||||
|
case $DIST_ID-$DIST_VERS in
|
||||||
|
fedora-*)
|
||||||
|
systemctl enable uwsgi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
assert_user
|
assert_user
|
||||||
wait_key
|
wait_key
|
||||||
clone_searx
|
clone_searx
|
||||||
|
@ -545,26 +551,21 @@ EOF
|
||||||
|| err_msg "uWSGI app $SEARX_UWSGI_APP not available!"
|
|| err_msg "uWSGI app $SEARX_UWSGI_APP not available!"
|
||||||
|
|
||||||
if in_container; then
|
if in_container; then
|
||||||
warn_msg "runnning inside container ..."
|
lxc_suite_info
|
||||||
for ip in $(global_IPs); do
|
else
|
||||||
if [[ $ip =~ .*:.* ]]; then
|
info_msg "public URL --> ${PUBLIC_URL}"
|
||||||
info_msg " public HTTP service (IPv6) --> http://${ip#*|}"
|
info_msg "internal URL --> http://${SEARX_INTERNAL_URL}"
|
||||||
else
|
|
||||||
info_msg " public HTTP service (IPv4) --> http://${ip#*|}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
warn_msg "SEARX_INTERNAL_URL not available from outside"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! service_is_available "http://${SEARX_INTERNAL_URL}"; then
|
if ! service_is_available "http://${SEARX_INTERNAL_URL}"; then
|
||||||
err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_URL} is not available!"
|
err_msg "uWSGI app (service) at http://${SEARX_INTERNAL_URL} is not available!"
|
||||||
echo -e "${_Green}stop with [${_BCyan}CTRL-C${_Green}] or .."
|
MSG="${_Green}[${_BCyan}CTRL-C${_Green}] to stop or [${_BCyan}KEY${_Green}] to continue"\
|
||||||
wait_key
|
wait_key
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! service_is_available "${PUBLIC_URL}"; then
|
if ! service_is_available "${PUBLIC_URL}"; then
|
||||||
warn_msg "Public service at ${PUBLIC_URL} is not available!"
|
warn_msg "Public service at ${PUBLIC_URL} is not available!"
|
||||||
if in_container; then
|
if ! in_container; then
|
||||||
warn_msg "Check if public name is correct and routed or use the public IP from above."
|
warn_msg "Check if public name is correct and routed or use the public IP from above."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -575,19 +576,31 @@ EOF
|
||||||
_debug_on=1
|
_debug_on=1
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
systemctl --no-pager -l status "${SERVICE_NAME}"
|
|
||||||
echo
|
|
||||||
|
|
||||||
info_msg "public URL --> ${PUBLIC_URL}"
|
case $DIST_ID-$DIST_VERS in
|
||||||
info_msg "internal URL --> http://${SEARX_INTERNAL_URL}"
|
ubuntu-*|debian-*)
|
||||||
|
systemctl --no-pager -l status "${SERVICE_NAME}"
|
||||||
|
;;
|
||||||
|
arch-*)
|
||||||
|
systemctl --no-pager -l status "uwsgi@${SERVICE_NAME%.*}"
|
||||||
|
;;
|
||||||
|
fedora-*)
|
||||||
|
systemctl --no-pager -l status uwsgi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"
|
printf "// use ${_BCyan}CTRL-C${_creset} to stop monitoring the log"
|
||||||
read -r -s -n1 -t 2
|
read -r -s -n1 -t 5
|
||||||
echo
|
echo
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
trap break 2
|
trap break 2
|
||||||
#journalctl -f -u "${SERVICE_NAME}"
|
case $DIST_ID-$DIST_VERS in
|
||||||
tail -f /var/log/uwsgi/app/searx.log
|
ubuntu-*|debian-*) tail -f /var/log/uwsgi/app/searx.log ;;
|
||||||
|
arch-*) journalctl -f -u "uwsgi@${SERVICE_NAME%.*}" ;;
|
||||||
|
fedora-*) journalctl -f -u uwsgi ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $_debug_on == 1 ]]; then
|
if [[ $_debug_on == 1 ]]; then
|
||||||
|
|
Loading…
Reference in a new issue