2# -*- coding: utf-8; mode: sh indent-tabs-mode: nil -*-
3# SPDX-License-Identifier: AGPL-3.0-or-later
4# shellcheck disable=SC2059,SC1117
6# ubuntu, debian, arch, fedora, centos ...
7DIST_ID=$(source /etc/os-release; echo "$ID");
8# shellcheck disable=SC2034
9DIST_VERS=$(source /etc/os-release; echo "$VERSION_ID");
11ADMIN_NAME="${ADMIN_NAME:-$(git config user.name)}"
12ADMIN_NAME="${ADMIN_NAME:-$USER}"
14ADMIN_EMAIL="${ADMIN_EMAIL:-$(git config user.email)}"
15ADMIN_EMAIL="${ADMIN_EMAIL:-$USER@$(hostname)}"
17if [[ -z "${REPO_ROOT}" ]]; then
18 REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")
19 while [ -h "${REPO_ROOT}" ] ; do
20 REPO_ROOT=$(readlink "${REPO_ROOT}")
22 REPO_ROOT=$(cd "${REPO_ROOT}/.." && pwd -P )
25if [[ -z ${TEMPLATES} ]]; then
26 TEMPLATES="${REPO_ROOT}/utils/templates"
29if [[ -z "$CACHE" ]]; then
30 CACHE="${REPO_ROOT}/cache"
33if [[ -z ${DIFF_CMD} ]]; then
35 if command -v colordiff >/dev/null; then
36 DIFF_CMD="colordiff -u"
40DOT_CONFIG="${DOT_CONFIG:-${REPO_ROOT}/.config.sh}"
43 if [[ ! -e "${DOT_CONFIG}" ]]; then
44 err_msg "configuration does not exists at: ${DOT_CONFIG}"
47 # shellcheck disable=SC1090
48 source "${DOT_CONFIG}"
54 if [ ! "$(id -u)" -eq 0 ]; then
55 err_msg "this command requires root (sudo) privilege!" >&2
62 # usage: required_commands [cmd1 ...]
67 if ! command -v "$1" &>/dev/null; then
68 err_msg "missing command $1"
79# shellcheck disable=SC2034
80set_terminal_colors() {
82 _creset='\e[0m' # reset all attributes
103if [ ! -p /dev/stdout ] && [ ! "$TERM" = 'dumb' ] && [ ! "$TERM" = 'unknown' ]; then
110if command -v fmt >/dev/null; then
117 # usage: rst_title <header-text> [part|chapter|section]
120 part) printf "\n${_BGreen}${1//?/=}${_creset}\n${_BCyan}${1}${_creset}\n${_BGreen}${1//?/=}${_creset}\n";;
121 chapter) printf "\n${_BCyan}${1}${_creset}\n${_BGreen}${1//?/=}${_creset}\n";;
122 section) printf "\n${_BCyan}${1}${_creset}\n${_BGreen}${1//?/-}${_creset}\n";;
124 err_msg "invalid argument '${2}' in line $(caller)"
131 # usage: RST_INDENT=1 rst_para "lorem ipsum ..."
133 if [[ -n $RST_INDENT ]] && [[ $RST_INDENT -gt 0 ]]; then
134 prefix="$(for i in $(seq 1 "$RST_INDENT"); do printf " "; done)"
135 echo -en "\n$*\n" | $FMT | prefix_stdout "$prefix"
137 echo -en "\n$*\n" | $FMT
142 echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[1]}: line ${BASH_LINENO[0]}: ${2-died ${1-1}}" >&2;
147 echo -e "${_BRed}ERROR:${_creset} ${BASH_SOURCE[2]}: line ${BASH_LINENO[1]}: ${FUNCNAME[1]}(): ${2-died ${1-1}}" >&2;
151err_msg() { echo -e "${_BRed}ERROR:${_creset} $*" >&2; }
152warn_msg() { echo -e "${_BBlue}WARN:${_creset} $*" >&2; }
153info_msg() { echo -e "${_BYellow}INFO:${_creset} $*" >&2; }
158 echo -e "${_Blue}${tag:0:10}${_creset}$*"
163 # Use this as last command in your function to prompt an ERROR message if
164 # the exit code is not zero.
167 [ "$err" -ne "0" ] && err_msg "${FUNCNAME[1]} exit with error ($err)"
172 if [[ $(uname -s) != 'Darwin' ]]; then
173 while read -r -n1 -t 0.1; do : ; done
178 # usage: wait_key [<timeout in sec>]
183 [[ -z "$msg" ]] && msg="${_Green}** press any [${_BCyan}KEY${_Green}] to continue **${_creset}"
185 [[ -n $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
186 [[ -n $_t ]] && _t="-t $_t"
188 # shellcheck disable=SC2086
195 # usage: ask_yn <prompt-text> [Ny|Yn] [<timeout in sec>]
197 local EXIT_YES=0 # exit status 0 --> successful
198 local EXIT_NO=1 # exit status 1 --> error code
201 [[ -n $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
202 [[ -n $_t ]] && _t="-t $_t"
203 case "${FORCE_SELECTION:-${2}}" in
204 Y) return ${EXIT_YES} ;;
205 N) return ${EXIT_NO} ;;
207 local exit_val=${EXIT_YES}
208 local choice="[${_BGreen}YES${_creset}/no]"
212 local exit_val=${EXIT_NO}
213 local choice="[${_BGreen}NO${_creset}/yes]"
220 printf "$1 ${choice} "
221 # shellcheck disable=SC2086
223 if [[ -z $REPLY ]]; then
224 printf "$default\n"; break
225 elif [[ $REPLY =~ ^[Yy]$ ]]; then
229 elif [[ $REPLY =~ ^[Nn]$ ]]; then
235 err_msg "invalid choice"
244 # tee_stderr 1 <<EOF | python -i
252 if [[ -n $1 ]] ; then _t="$1"; fi
254 (while read -r line; do
255 # shellcheck disable=SC2086
263 # usage: <cmd> | prefix_stdout [prefix]
265 local prefix="${_BYellow}-->|${_creset}"
267 if [[ -n $1 ]] ; then prefix="$1"; fi
269 # shellcheck disable=SC2162
270 (while IFS= read line; do
271 echo -e "${prefix}$line"
277 # usage: append_line <line> <file>
279 # Append line if not exists, create file if not exists. E.g::
281 # append_line 'source ~/.foo' ~/bashrc
285 grep -qFs -- "$LINE" "$FILE" || echo "$LINE" >> "$FILE"
290 # usage: cache_download <url> <local-filename>
294 if [[ -n ${SUDO_USER} ]]; then
295 sudo -u "${SUDO_USER}" mkdir -p "${CACHE}"
300 if [[ -f "${CACHE}/$2" ]] ; then
301 info_msg "already cached: $1"
302 info_msg " --> ${CACHE}/$2"
305 if [[ ! -f "${CACHE}/$2" ]]; then
306 info_msg "caching: $1"
307 info_msg " --> ${CACHE}/$2"
308 if [[ -n ${SUDO_USER} ]]; then
309 sudo -u "${SUDO_USER}" wget --progress=bar -O "${CACHE}/$2" "$1" ; exit_value=$?
311 wget --progress=bar -O "${CACHE}/$2" "$1" ; exit_value=$?
313 if [[ ! $exit_value = 0 ]]; then
314 err_msg "failed to download: $1"
321 # usage: backup_file /path/to/file.foo
324 stamp=$(date +"_%Y%m%d_%H%M%S")
325 info_msg "create backup: ${1}${stamp}"
326 cp -a "${1}" "${1}${stamp}"
333 # DEFAULT_SELECT= 2 \
334 # choose_one <name> "your selection?" "Coffee" "Coffee with milk"
336 local default=${DEFAULT_SELECT-1}
338 local env_name=$1 && shift
342 [[ -n $FORCE_TIMEOUT ]] && _t=$FORCE_TIMEOUT
343 [[ -n $_t ]] && _t="-t $_t"
346 echo -e "${_BGreen}Menu::${_creset}"
347 for ((i=1; i<= $((max -1)); i++)); do
348 if [[ "$i" == "$default" ]]; then
349 echo -e " ${_BGreen}$i.${_creset}) ${list[$i]} [default]"
351 echo -e " $i.) ${list[$i]}"
356 printf "$1 [${_BGreen}$default${_creset}] "
358 if (( 10 > max )); then
359 # shellcheck disable=SC2086
362 # shellcheck disable=SC2086,SC2229
366 [[ $REPLY =~ ^-?[0-9]+$ ]] && (( REPLY > 0 )) && (( REPLY < max )) && break
369 [[ -z $REPLY ]] && REPLY=$default && break
372 err_msg "invalid choice"
374 eval "$env_name"='${list[${REPLY}]}'
383 # install_template [--no-eval] [--variant=<name>] \
384 # {file} [{owner} [{group} [{chmod}]]]
386 # E.g. the origin of variant 'raw' of /etc/updatedb.conf is::
388 # ${TEMPLATES}/etc/updatedb.conf:raw
390 # To install variant 'raw' of /etc/updatedb.conf without evaluated
391 # replacements you can use::
393 # install_template --variant=raw --no-eval \
394 # /etc/updatedb.conf root root 644
399 local pos_args=("$0")
403 --no-eval) do_eval=0; shift ;;
404 --variant=*) variant=":${i#*=}"; shift ;;
405 *) pos_args+=("$i") ;;
409 local dst="${pos_args[1]}"
410 local template_origin="${TEMPLATES}${dst}${variant}"
411 local template_file="${TEMPLATES}${dst}"
413 local owner="${pos_args[2]-$(id -un)}"
414 local group="${pos_args[3]-$(id -gn)}"
415 local chmod="${pos_args[4]-644}"
417 info_msg "install (eval=$do_eval): ${dst}"
418 [[ -n $variant ]] && info_msg "variant --> ${variant}"
420 if [[ ! -f "${template_origin}" ]] ; then
421 err_msg "${template_origin} does not exists"
422 err_msg "... can't install $dst"
427 if [[ "$do_eval" == "1" ]]; then
428 template_file="${CACHE}${dst}${variant}"
429 info_msg "BUILD template ${template_file}"
430 if [[ -n ${SUDO_USER} ]]; then
431 sudo -u "${SUDO_USER}" mkdir -p "$(dirname "${template_file}")"
433 mkdir -p "$(dirname "${template_file}")"
435 # shellcheck disable=SC2086
436 eval "echo \"$(cat ${template_origin})\"" > "${template_file}"
437 if [[ -n ${SUDO_USER} ]]; then
438 chown "${SUDO_USER}:${SUDO_USER}" "${template_file}"
441 template_file=$template_origin
444 mkdir -p "$(dirname "${dst}")"
446 if [[ ! -f "${dst}" ]]; then
447 info_msg "install: ${template_file}"
448 sudo -H install -v -o "${owner}" -g "${group}" -m "${chmod}" \
449 "${template_file}" "${dst}" | prefix_stdout
453 if [[ -f "${dst}" ]] && cmp --silent "${template_file}" "${dst}" ; then
454 info_msg "file ${dst} allready installed"
458 info_msg "diffrent file ${dst} allready exists on this host"
461 choose_one _reply "choose next step with file $dst" \
463 "leave file unchanged" \
469 info_msg "install: ${template_file}"
470 sudo -H install -v -o "${owner}" -g "${group}" -m "${chmod}" \
471 "${template_file}" "${dst}" | prefix_stdout
474 "leave file unchanged")
478 echo -e "// edit ${_Red}${dst}${_creset} to your needs"
479 echo -e "// exit with [${_BCyan}CTRL-D${_creset}]"
480 sudo -H -u "${owner}" -i
481 $DIFF_CMD "${dst}" "${template_file}"
483 echo -e "// ${_BBlack}did you edit file ...${_creset}"
484 echo -en "// ${_Red}${dst}${_creset}"
485 if ask_yn "//${_BBlack}... to your needs?${_creset}"; then
490 $DIFF_CMD "${dst}" "${template_file}" | prefix_stdout
496service_is_available() {
498 # usage: service_is_available <URL>
500 [[ -z $1 ]] && die_caller 42 "missing argument <URL>"
502 http_code=$(curl -H 'Cache-Control: no-cache' \
503 --silent -o /dev/null --head --write-out '%{http_code}' --insecure \
506 if [[ $exit_val = 0 ]]; then
507 info_msg "got $http_code from ${URL}"
510 404|410|423) exit_val=$http_code;;
519PYTHON="${PYTHON:=python$PY}"
520PY_ENV="${PY_ENV:=local/py${PY}}"
521PY_ENV_BIN="${PY_ENV}/bin"
522PY_ENV_REQ="${PY_ENV_REQ:=${REPO_ROOT}/requirements*.txt}"
524# List of python packages (folders) or modules (files) installed by command:
526PYOBJECTS="${PYOBJECTS:=.}"
528# folder where the python distribution takes place
529PYDIST="${PYDIST:=dist}"
531# folder where the intermediate build files take place
532PYBUILD="${PYBUILD:=build/py${PY}}"
534# https://www.python.org/dev/peps/pep-0508/#extras
535#PY_SETUP_EXTRAS='[develop,test]'
536PY_SETUP_EXTRAS="${PY_SETUP_EXTRAS:=[develop,test]}"
538PIP_BOILERPLATE=( pip wheel setuptools )
540# shellcheck disable=SC2120
543 # usage: pyenv [vtenv_opts ...]
545 # vtenv_opts: see 'pip install --help'
547 # Builds virtualenv with 'requirements*.txt' (PY_ENV_REQ) installed. The
548 # virtualenv will be reused by validating sha256sum of the requirement
552 sha256sum "${PYTHON}" \
557 if ! pyenv.OK > /dev/null; then
558 rm -f "${PY_ENV}/${PY_ENV_REQ}.sha256"
559 pyenv.drop > /dev/null
560 build_msg PYENV "[virtualenv] installing ${PY_ENV_REQ} into ${PY_ENV}"
562 "${PYTHON}" -m venv "$@" "${PY_ENV}" || exit
563 "${PY_ENV_BIN}/python" -m pip install -U "${PIP_BOILERPLATE[@]}" || exit
565 for i in ${PY_ENV_REQ}; do
566 pip_req=( "${pip_req[@]}" "-r" "$i" )
570 [ "$VERBOSE" = "1" ] && set -x
571 # shellcheck disable=SC2086
572 "${PY_ENV_BIN}/python" -m pip install "${pip_req[@]}" \
573 && sha256sum ${PY_ENV_REQ} > "${PY_ENV}/requirements.sha256"
582 # probes if pyenv exists and runs the script from pyenv.check
584 [ "$_pyenv_OK" == "OK" ] && return 0
586 if [ ! -f "${PY_ENV_BIN}/python" ]; then
587 build_msg PYENV "[virtualenv] missing ${PY_ENV_BIN}/python"
591 if [ ! -f "${PY_ENV}/requirements.sha256" ] \
592 || ! sha256sum --check --status <"${PY_ENV}/requirements.sha256" 2>/dev/null; then
593 build_msg PYENV "[virtualenv] requirements.sha256 failed"
594 sed 's/^/ [virtualenv] - /' <"${PY_ENV}/requirements.sha256"
599 | "${PY_ENV_BIN}/python" 2>&1 \
600 | prefix_stdout "${_Blue}PYENV ${_creset}[check] "
602 local err=${PIPESTATUS[1]}
603 if [ "$err" -ne "0" ]; then
604 build_msg PYENV "[check] python test failed"
615 build_msg PYENV "[virtualenv] drop ${PY_ENV}"
623 # Prompts a python script with additional checks. Used by pyenv.OK to check
624 # if virtualenv is ready to install python objects. This function should be
625 # overwritten by the application script.
629 for i in "${PIP_BOILERPLATE[@]}"; do
644 if ! pyenv.install.OK > /dev/null; then
645 build_msg PYENV "[install] ${PYOBJECTS}"
646 if ! pyenv.OK >/dev/null; then
649 for i in ${PYOBJECTS}; do
650 build_msg PYENV "[install] pip install -e '$i${PY_SETUP_EXTRAS}'"
651 "${PY_ENV_BIN}/python" -m pip install -e "$i${PY_SETUP_EXTRAS}"
660 [ "$_pyenv_install_OK" == "OK" ] && return 0
665 if [ "." = "${PYOBJECTS}" ]; then
666 imp="import $(basename "$(pwd)")"
668 # shellcheck disable=SC2086
669 for i in ${PYOBJECTS}; do imp="$imp, $i"; done
670 imp="import ${imp#,*} "
673 [ "$VERBOSE" = "1" ] && set -x
674 "${PY_ENV_BIN}/python" -c "import sys; sys.path.pop(0); $imp;" 2>/dev/null
678 if [ "$err" -ne "0" ]; then
679 build_msg PYENV "[install] python installation test failed"
683 build_msg PYENV "[install] OK"
684 _pyenv_install_OK="OK"
690 build_msg PYENV "[uninstall] ${PYOBJECTS}"
692 if [ "." = "${PYOBJECTS}" ]; then
693 pyenv.cmd python setup.py develop --uninstall 2>&1 \
694 | prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
696 pyenv.cmd python -m pip uninstall --yes ${PYOBJECTS} 2>&1 \
697 | prefix_stdout "${_Blue}PYENV ${_creset}[pyenv.uninstall] "
705 # shellcheck source=/dev/null
706 source "${PY_ENV_BIN}/activate"
707 [ "$VERBOSE" = "1" ] && set -x
715GH_PAGES="build/gh-pages"
716DOCS_DIST="${DOCS_DIST:=dist/docs}"
717DOCS_BUILD="${DOCS_BUILD:=build/docs}"
720 build_msg SPHINX "HTML ./docs --> file://$(readlink -e "$(pwd)/$DOCS_DIST")"
723 # shellcheck disable=SC2086
724 PATH="${PY_ENV_BIN}:${PATH}" pyenv.cmd sphinx-build \
725 ${SPHINX_VERBOSE} ${SPHINXOPTS} \
726 -b html -c ./docs -d "${DOCS_BUILD}/.doctrees" ./docs "${DOCS_DIST}"
731 build_msg SPHINX "autobuild ./docs --> file://$(readlink -e "$(pwd)/$DOCS_DIST")"
734 # shellcheck disable=SC2086
735 PATH="${PY_ENV_BIN}:${PATH}" pyenv.cmd sphinx-autobuild \
736 ${SPHINX_VERBOSE} ${SPHINXOPTS} --open-browser --host 0.0.0.0 \
737 -b html -c ./docs -d "${DOCS_BUILD}/.doctrees" ./docs "${DOCS_DIST}"
742 build_msg CLEAN "docs -- ${DOCS_BUILD} ${DOCS_DIST}"
743 # shellcheck disable=SC2115
744 rm -rf "${GH_PAGES}" "${DOCS_BUILD}" "${DOCS_DIST}"
749 # Dummy function to run some actions before sphinx-doc build gets started.
750 # This finction needs to be overwritten by the application script.
755# shellcheck disable=SC2155
758 # The commit history in the gh-pages branch makes no sense, the history only
759 # inflates the repository unnecessarily. Therefore a *new orphan* branch
760 # is created each time we deploy on the gh-pages branch.
766 [ "$VERBOSE" = "1" ] && set -x
767 local head="$(git rev-parse HEAD)"
768 local branch="$(git name-rev --name-only HEAD)"
769 local remote="$(git config branch."${branch}".remote)"
770 local remote_url="$(git config remote."${remote}".url)"
772 # prepare the *orphan* gh-pages working tree
774 git worktree remove -f "${GH_PAGES}"
775 git branch -D gh-pages
776 ) &> /dev/null || true
777 git worktree add --no-checkout "${GH_PAGES}" origin/master
779 pushd "${GH_PAGES}" &> /dev/null
780 git checkout --orphan gh-pages
784 cp -r "${DOCS_DIST}"/* "${GH_PAGES}"/
785 touch "${GH_PAGES}/.nojekyll"
786 cat > "${GH_PAGES}/404.html" <<EOF
787<html><head><META http-equiv='refresh' content='0;URL=index.html'></head></html>
790 pushd "${GH_PAGES}" &> /dev/null
792 git commit -q -m "gh-pages build from: ${branch}@${head} (${remote_url})"
793 git push -f "${remote}" gh-pages
797 build_msg GH-PAGES "deployed"
805 # usage: go_is_available $SERVICE_USER && echo "go is installed!"
807 sudo -i -u "${1}" which go &>/dev/null
812 # usage: install_go "${GO_PKG_URL}" "${GO_TAR}" "${SERVICE_USER}"
814 local _svcpr=" ${_Yellow}|${3}|${_creset} "
816 rst_title "Install Go in user's HOME" section
818 rst_para "download and install go binary .."
819 cache_download "${1}" "${2}"
821 tee_stderr 0.1 <<EOF | sudo -i -u "${3}" | prefix_stdout "$_svcpr"
825rm -rf \$HOME/local/go
826tar -C \$HOME/local -xzf ${CACHE}/${2}
828 sudo -i -u "${3}" <<EOF | prefix_stdout
829! which go >/dev/null && echo "ERROR - Go Installation not found in PATH!?!"
830which go >/dev/null && go version && echo "congratulations -- Go installation OK :)"
837service_account_is_available() {
839 # usage: service_account_is_available "$SERVICE_USER" && echo "OK"
841 sudo -i -u "$1" echo \$HOME &>/dev/null
844drop_service_account() {
846 # usage: drop_service_account "${SERVICE_USER}"
848 rst_title "Drop ${1} HOME" section
849 if ask_yn "Do you really want to drop ${1} home folder?"; then
850 userdel -r -f "${1}" 2>&1 | prefix_stdout
852 rst_para "Leave HOME folder $(du -sh "${1}") unchanged."
858 # usage: interactive_shell "${SERVICE_USER}"
860 echo -e "// exit with [${_BCyan}CTRL-D${_creset}]"
868SYSTEMD_UNITS="${SYSTEMD_UNITS:-/lib/systemd/system}"
870systemd_install_service() {
872 # usage: systemd_install_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}"
874 rst_title "Install System-D Unit ${1}" section
876 install_template "${2}" root root 644
878 systemd_activate_service "${1}"
881systemd_remove_service() {
883 # usage: systemd_remove_service "${SERVICE_NAME}" "${SERVICE_SYSTEMD_UNIT}"
885 if ! ask_yn "Do you really want to deinstall systemd unit ${1}?"; then
888 systemd_deactivate_service "${1}"
889 rm "${2}" 2>&1 | prefix_stdout
892systemd_activate_service() {
894 # usage: systemd_activate_service "${SERVICE_NAME}"
896 rst_title "Activate ${1} (service)" section
898 tee_stderr <<EOF | bash 2>&1
899systemctl enable ${1}.service
900systemctl restart ${1}.service
902 tee_stderr <<EOF | bash 2>&1
903systemctl status --no-pager ${1}.service
907systemd_deactivate_service() {
909 # usage: systemd_deactivate_service "${SERVICE_NAME}"
911 rst_title "De-Activate ${1} (service)" section
913 tee_stderr <<EOF | bash 2>&1 | prefix_stdout
914systemctl stop ${1}.service
915systemctl disable ${1}.service
919systemd_restart_service() {
921 # usage: systemd_restart_service "${SERVICE_NAME}"
923 rst_title "Restart ${1} (service)" section
925 tee_stderr <<EOF | bash 2>&1
926systemctl restart ${1}.service
928 tee_stderr <<EOF | bash 2>&1
929systemctl status --no-pager ${1}.service
937nginx_distro_setup() {
938 # shellcheck disable=SC2034
940 NGINX_DEFAULT_SERVER=/etc/nginx/nginx.conf
942 # Including *location* directives from a dedicated config-folder into the
943 # server directive is, what fedora and centos (already) does.
944 NGINX_APPS_ENABLED="/etc/nginx/default.d"
946 # We add a apps-available folder and linking configurations into the
947 # NGINX_APPS_ENABLED folder. See also nginx_include_apps_enabled().
948 NGINX_APPS_AVAILABLE="/etc/nginx/default.apps-available"
950 case $DIST_ID-$DIST_VERS in
952 NGINX_PACKAGES="nginx"
953 NGINX_DEFAULT_SERVER=/etc/nginx/sites-available/default
956 NGINX_PACKAGES="nginx-mainline"
959 NGINX_PACKAGES="nginx"
962 err_msg "$DIST_ID-$DIST_VERS: nginx not yet implemented"
969 info_msg "installing nginx ..."
970 pkg_install "${NGINX_PACKAGES}"
971 case $DIST_ID-$DIST_VERS in
972 arch-*|fedora-*|centos-7)
973 systemctl enable nginx
974 systemctl start nginx
979nginx_is_installed() {
980 command -v nginx &>/dev/null
985 info_msg "reload nginx .."
988 err_msg "testing nginx configuration failed"
991 systemctl restart nginx
996 # usage: nginx_install_app [<template option> ...] <myapp.conf>
998 # <template option>: see install_template
1000 local template_opts=()
1001 local pos_args=("$0")
1005 -*) template_opts+=("$i");;
1006 *) pos_args+=("$i");;
1010 nginx_include_apps_enabled "${NGINX_DEFAULT_SERVER}"
1012 install_template "${template_opts[@]}" \
1013 "${NGINX_APPS_AVAILABLE}/${pos_args[1]}" \
1015 nginx_enable_app "${pos_args[1]}"
1016 info_msg "installed nginx app: ${pos_args[1]}"
1019nginx_include_apps_enabled() {
1021 # Add the *NGINX_APPS_ENABLED* infrastruture to a nginx server block. Such
1022 # infrastruture is already known from fedora and centos, including apps (location
1023 # directives) from the /etc/nginx/default.d folder into the *default* nginx
1026 # usage: nginx_include_apps_enabled <config-file>
1028 # config-file: Config file with server directive in.
1030 [[ -z $1 ]] && die_caller 42 "missing argument <config-file>"
1031 local server_conf="$1"
1033 # include /etc/nginx/default.d/*.conf;
1034 local include_directive="include ${NGINX_APPS_ENABLED}/*.conf;"
1035 local include_directive_re="^\s*include ${NGINX_APPS_ENABLED}/\*\.conf;"
1037 info_msg "checking existence: '${include_directive}' in file ${server_conf}"
1038 if grep "${include_directive_re}" "${server_conf}"; then
1039 info_msg "OK, already exists."
1043 info_msg "add missing directive: '${include_directive}'"
1044 cp "${server_conf}" "${server_conf}.bak"
1049 while IFS= read -r line
1052 if [[ $stage = 0 ]]; then
1053 if [[ $line =~ ^[[:space:]]*server*[[:space:]]*\{ ]]; then
1058 if [[ $stage = 1 ]]; then
1059 echo " # Load configuration files for the default server block."
1060 echo " $include_directive"
1064 done < "${server_conf}.bak"
1065 ) > "${server_conf}"
1071 # usage: nginx_remove_app <myapp.conf>
1073 info_msg "remove nginx app: $1"
1074 nginx_dissable_app "$1"
1075 rm -f "${NGINX_APPS_AVAILABLE}/$1"
1080 # usage: nginx_enable_app <myapp.conf>
1084 info_msg "enable nginx app: ${CONF}"
1085 mkdir -p "${NGINX_APPS_ENABLED}"
1086 rm -f "${NGINX_APPS_ENABLED}/${CONF}"
1087 ln -s "${NGINX_APPS_AVAILABLE}/${CONF}" "${NGINX_APPS_ENABLED}/${CONF}"
1091nginx_dissable_app() {
1093 # usage: nginx_disable_app <myapp.conf>
1097 info_msg "disable nginx app: ${CONF}"
1098 rm -f "${NGINX_APPS_ENABLED}/${CONF}"
1106apache_distro_setup() {
1107 # shellcheck disable=SC2034
1108 case $DIST_ID-$DIST_VERS in
1110 # debian uses the /etc/apache2 path, while other distros use
1111 # the apache default at /etc/httpd
1112 APACHE_SITES_AVAILABLE="/etc/apache2/sites-available"
1113 APACHE_SITES_ENABLED="/etc/apache2/sites-enabled"
1114 APACHE_MODULES="/usr/lib/apache2/modules"
1115 APACHE_PACKAGES="apache2"
1118 APACHE_SITES_AVAILABLE="/etc/httpd/sites-available"
1119 APACHE_SITES_ENABLED="/etc/httpd/sites-enabled"
1120 APACHE_MODULES="modules"
1121 APACHE_PACKAGES="apache"
1124 APACHE_SITES_AVAILABLE="/etc/httpd/sites-available"
1125 APACHE_SITES_ENABLED="/etc/httpd/sites-enabled"
1126 APACHE_MODULES="modules"
1127 APACHE_PACKAGES="httpd"
1130 err_msg "$DIST_ID-$DIST_VERS: apache not yet implemented"
1138 info_msg "installing apache ..."
1139 pkg_install "$APACHE_PACKAGES"
1140 case $DIST_ID-$DIST_VERS in
1141 arch-*|fedora-*|centos-7)
1142 if ! grep "IncludeOptional sites-enabled" "/etc/httpd/conf/httpd.conf"; then
1143 echo "IncludeOptional sites-enabled/*.conf" >> "/etc/httpd/conf/httpd.conf"
1145 systemctl enable httpd
1146 systemctl start httpd
1151apache_is_installed() {
1152 case $DIST_ID-$DIST_VERS in
1153 ubuntu-*|debian-*) (command -v apachectl) &>/dev/null;;
1154 arch-*) (command -v httpd) &>/dev/null;;
1155 fedora-*|centos-7) (command -v httpd) &>/dev/null;;
1161 info_msg "reload apache .."
1163 case $DIST_ID-$DIST_VERS in
1165 sudo -H apachectl configtest
1166 sudo -H systemctl force-reload apache2
1168 arch-*|fedora-*|centos-7)
1170 sudo -H systemctl force-reload httpd
1175apache_install_site() {
1177 # usage: apache_install_site [<template option> ...] <mysite.conf>
1179 # <template option>: see install_template
1181 local template_opts=()
1182 local pos_args=("$0")
1186 -*) template_opts+=("$i");;
1187 *) pos_args+=("$i");;
1191 install_template "${template_opts[@]}" \
1192 "${APACHE_SITES_AVAILABLE}/${pos_args[1]}" \
1194 apache_enable_site "${pos_args[1]}"
1195 info_msg "installed apache site: ${pos_args[1]}"
1198apache_remove_site() {
1200 # usage: apache_remove_site <mysite.conf>
1202 info_msg "remove apache site: $1"
1203 apache_dissable_site "$1"
1204 rm -f "${APACHE_SITES_AVAILABLE}/$1"
1207apache_enable_site() {
1209 # usage: apache_enable_site <mysite.conf>
1213 info_msg "enable apache site: ${CONF}"
1215 case $DIST_ID-$DIST_VERS in
1217 sudo -H a2ensite -q "${CONF}"
1220 mkdir -p "${APACHE_SITES_ENABLED}"
1221 rm -f "${APACHE_SITES_ENABLED}/${CONF}"
1222 ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
1225 mkdir -p "${APACHE_SITES_ENABLED}"
1226 rm -f "${APACHE_SITES_ENABLED}/${CONF}"
1227 ln -s "${APACHE_SITES_AVAILABLE}/${CONF}" "${APACHE_SITES_ENABLED}/${CONF}"
1233apache_dissable_site() {
1235 # usage: apache_disable_site <mysite.conf>
1239 info_msg "disable apache site: ${CONF}"
1241 case $DIST_ID-$DIST_VERS in
1243 sudo -H a2dissite -q "${CONF}"
1246 rm -f "${APACHE_SITES_ENABLED}/${CONF}"
1249 rm -f "${APACHE_SITES_ENABLED}/${CONF}"
1258uWSGI_SETUP="${uWSGI_SETUP:=/etc/uwsgi}"
1262# How distros manage uWSGI apps is very different. From uWSGI POV read:
1263# - https://uwsgi-docs.readthedocs.io/en/latest/Management.html
1265uWSGI_distro_setup() {
1266 case $DIST_ID-$DIST_VERS in
1268 # init.d --> /usr/share/doc/uwsgi/README.Debian.gz
1269 # For uWSGI debian uses the LSB init process, this might be changed
1270 # one day, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833067
1271 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
1272 uWSGI_APPS_ENABLED="${uWSGI_SETUP}/apps-enabled"
1273 uWSGI_PACKAGES="uwsgi"
1276 # systemd --> /usr/lib/systemd/system/uwsgi@.service
1277 # For uWSGI archlinux uses systemd template units, see
1278 # - http://0pointer.de/blog/projects/instances.html
1279 # - https://uwsgi-docs.readthedocs.io/en/latest/Systemd.html#one-service-per-app-in-systemd
1280 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-archlinux"
1281 uWSGI_APPS_ENABLED="${uWSGI_SETUP}"
1282 uWSGI_PACKAGES="uwsgi"
1285 # systemd --> /usr/lib/systemd/system/uwsgi.service
1286 # The unit file starts uWSGI in emperor mode (/etc/uwsgi.ini), see
1287 # - https://uwsgi-docs.readthedocs.io/en/latest/Emperor.html
1288 uWSGI_APPS_AVAILABLE="${uWSGI_SETUP}/apps-available"
1289 uWSGI_APPS_ENABLED="${uWSGI_SETUP}.d"
1290 uWSGI_PACKAGES="uwsgi"
1295 err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
1303 info_msg "installing uwsgi ..."
1304 pkg_install "$uWSGI_PACKAGES"
1305 case $DIST_ID-$DIST_VERS in
1307 # enable & start should be called once at uWSGI installation time
1308 systemctl enable uwsgi
1309 systemctl restart uwsgi
1316 # usage: uWSGI_restart() <myapp.ini>
1320 [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1321 info_msg "restart uWSGI service"
1322 case $DIST_ID-$DIST_VERS in
1324 # the 'service' method seems broken in that way, that it (re-)starts
1325 # the whole uwsgi process.
1326 service uwsgi restart "${CONF%.*}"
1329 # restart systemd template instance
1330 if uWSGI_app_available "${CONF}"; then
1331 systemctl restart "uwsgi@${CONF%.*}"
1333 info_msg "[uWSGI:systemd-template] ${CONF} not installed (no need to restart)"
1337 # in emperor mode, just touch the file to restart
1338 if uWSGI_app_enabled "${CONF}"; then
1339 touch "${uWSGI_APPS_ENABLED}/${CONF}"
1340 # it seems, there is a polling time in between touch and restart
1344 info_msg "[uWSGI:emperor] ${CONF} not installed (no need to restart)"
1348 err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
1354uWSGI_prepare_app() {
1356 # usage: uWSGI_prepare_app <myapp.ini>
1358 [[ -z $1 ]] && die_caller 42 "missing argument <myapp.ini>"
1362 case $DIST_ID-$DIST_VERS in
1364 # in emperor mode, the uwsgi user is the owner of the sockets
1365 info_msg "prepare (uwsgi:uwsgi) /run/uwsgi/app/${APP}"
1366 mkdir -p "/run/uwsgi/app/${APP}"
1367 chown -R "uwsgi:uwsgi" "/run/uwsgi/app/${APP}"
1370 info_msg "prepare (${SERVICE_USER}:${SERVICE_GROUP}) /run/uwsgi/app/${APP}"
1371 mkdir -p "/run/uwsgi/app/${APP}"
1372 chown -R "${SERVICE_USER}:${SERVICE_GROUP}" "/run/uwsgi/app/${APP}"
1378uWSGI_app_available() {
1379 # usage: uWSGI_app_available <myapp.ini>
1382 [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1383 [[ -f "${uWSGI_APPS_AVAILABLE}/${CONF}" ]]
1386uWSGI_install_app() {
1388 # usage: uWSGI_install_app [<template option> ...] <myapp.ini>
1390 # <template option>: see install_template
1392 local pos_args=("$0")
1396 -*) template_opts+=("$i");;
1397 *) pos_args+=("$i");;
1400 uWSGI_prepare_app "${pos_args[1]}"
1401 mkdir -p "${uWSGI_APPS_AVAILABLE}"
1402 install_template "${template_opts[@]}" \
1403 "${uWSGI_APPS_AVAILABLE}/${pos_args[1]}" \
1405 uWSGI_enable_app "${pos_args[1]}"
1406 uWSGI_restart "${pos_args[1]}"
1407 info_msg "uWSGI app: ${pos_args[1]} is installed"
1412 # usage: uWSGI_remove_app <myapp.ini>
1416 [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1417 info_msg "remove uWSGI app: ${CONF}"
1418 uWSGI_disable_app "${CONF}"
1419 uWSGI_restart "${CONF}"
1420 rm -f "${uWSGI_APPS_AVAILABLE}/${CONF}"
1423uWSGI_app_enabled() {
1424 # usage: uWSGI_app_enabled <myapp.ini>
1429 [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1430 case $DIST_ID-$DIST_VERS in
1432 [[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
1436 systemctl -q is-enabled "uwsgi@${CONF%.*}"
1440 [[ -f "${uWSGI_APPS_ENABLED}/${CONF}" ]]
1445 err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
1452# shellcheck disable=SC2164
1455 # usage: uWSGI_enable_app <myapp.ini>
1459 [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1460 case $DIST_ID-$DIST_VERS in
1462 mkdir -p "${uWSGI_APPS_ENABLED}"
1463 rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
1464 ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
1465 info_msg "enabled uWSGI app: ${CONF} (restart required)"
1468 mkdir -p "${uWSGI_APPS_ENABLED}"
1469 rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
1470 ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
1471 systemctl enable "uwsgi@${CONF%.*}"
1472 info_msg "enabled uWSGI app: ${CONF} (restart required)"
1475 mkdir -p "${uWSGI_APPS_ENABLED}"
1476 rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
1477 ln -s "${uWSGI_APPS_AVAILABLE}/${CONF}" "${uWSGI_APPS_ENABLED}/${CONF}"
1478 chown "${uWSGI_USER}:${uWSGI_GROUP}" "${uWSGI_APPS_ENABLED}/${CONF}"
1479 info_msg "enabled uWSGI app: ${CONF}"
1483 err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
1488uWSGI_disable_app() {
1490 # usage: uWSGI_disable_app <myapp.ini>
1494 [[ -z $CONF ]] && die_caller 42 "missing argument <myapp.ini>"
1495 case $DIST_ID-$DIST_VERS in
1497 service uwsgi stop "${CONF%.*}"
1498 rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
1499 info_msg "disabled uWSGI app: ${CONF} (restart uWSGI required)"
1502 systemctl stop "uwsgi@${CONF%.*}"
1503 systemctl disable "uwsgi@${CONF%.*}"
1504 rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
1507 # in emperor mode, just remove the app.ini file
1508 rm -f "${uWSGI_APPS_ENABLED}/${CONF}"
1512 err_msg "$DIST_ID-$DIST_VERS: uWSGI not yet implemented"
1517# distro's package manager
1518# ------------------------
1520_apt_pkg_info_is_updated=0
1524 # usage: TITEL='install foobar' pkg_install foopkg barpkg
1526 rst_title "${TITLE:-installation of packages}" section
1527 echo -e "\npackage(s)::\n"
1528 # shellcheck disable=SC2068
1531 if ! ask_yn "Should packages be installed?" Yn 30; then
1536 if [[ $_apt_pkg_info_is_updated == 0 ]]; then
1537 export _apt_pkg_info_is_updated=1
1540 # shellcheck disable=SC2068
1541 apt-get install -m -y $@
1544 # shellcheck disable=SC2068
1545 pacman -Sy --noconfirm $@
1548 # shellcheck disable=SC2068
1552 # shellcheck disable=SC2068
1560 # usage: TITEL='remove foobar' pkg_remove foopkg barpkg
1562 rst_title "${TITLE:-remove packages}" section
1563 echo -e "\npackage(s)::\n"
1564 # shellcheck disable=SC2068
1567 if ! ask_yn "Should packages be removed (purge)?" Yn 30; then
1572 # shellcheck disable=SC2068
1573 apt-get purge --autoremove --ignore-missing -y $@
1576 # shellcheck disable=SC2068
1577 pacman -R --noconfirm $@
1580 # shellcheck disable=SC2068
1584 # shellcheck disable=SC2068
1592 # usage: pkg_is_install foopkg || pkg_install foopkg
1596 dpkg -l "$1" &> /dev/null
1600 pacman -Qsq "$1" &> /dev/null
1604 dnf list -q --installed "$1" &> /dev/null
1608 yum list -q --installed "$1" &> /dev/null
1617# shellcheck disable=SC2164
1622 # git_clone <url> <name> [<branch> [<user>]]
1623 # git_clone <url> <path> [<branch> [<user>]]
1625 # First form uses $CACHE/<name> as destination folder, second form clones
1626 # into <path>. If repository is allready cloned, pull from <branch> and
1627 # update working tree (if needed, the caller has to stash local changes).
1629 # git clone https://github.com/searx/searx searx-src origin/master searxlogin
1636 local bash_cmd="bash"
1637 local remote="origin"
1639 if [[ ! "${dest:0:1}" = "/" ]]; then
1643 [[ -z $branch ]] && branch=master
1644 [[ -z $user ]] && [[ -n "${SUDO_USER}" ]] && user="${SUDO_USER}"
1645 [[ -n $user ]] && bash_cmd="sudo -H -u $user -i"
1647 if [[ -d "${dest}" ]] ; then
1648 info_msg "already cloned: $dest"
1649 tee_stderr 0.1 <<EOF | $bash_cmd 2>&1 | prefix_stdout " ${_Yellow}|$user|${_creset} "
1651git checkout -m -B "$branch" --track "$remote/$branch"
1655 info_msg "clone into: $dest"
1656 tee_stderr 0.1 <<EOF | $bash_cmd 2>&1 | prefix_stdout " ${_Yellow}|$user|${_creset} "
1657mkdir -p "$(dirname "$dest")"
1658cd "$(dirname "$dest")"
1659git clone --branch "$branch" --origin "$remote" "$url" "$(basename "$dest")"
1668 # Test if shell runs in a container.
1670 # usage: in_container && echo "process running inside a LXC container"
1671 # in_container || echo "process is not running inside a LXC container"
1674 # hint: Reads init process environment, therefore root access is required!
1675 # to be safe, take a look at the environment of process 1 (/sbin/init)
1676 # grep -qa 'container=lxc' /proc/1/environ
1678 # see lxc_init_container_env
1683if in_container; then
1684 # shellcheck disable=SC2034
1685 LXC_ENV_FOLDER="lxc-env/$(hostname)/"
1686 PY_ENV="${LXC_ENV_FOLDER}${PY_ENV}"
1687 PY_ENV_BIN="${LXC_ENV_FOLDER}${PY_ENV_BIN}"
1688 PYDIST="${LXC_ENV_FOLDER}${PYDIST}"
1689 PYBUILD="${LXC_ENV_FOLDER}${PYBUILD}"
1690 DOCS_DIST="${LXC_ENV_FOLDER}${DOCS_DIST}"
1691 DOCS_BUILD="${LXC_ENV_FOLDER}${DOCS_BUILD}"
1694lxc_init_container_env() {
1696 # usage: lxc_init_container_env <name>
1698 # Create a /.lxcenv file in the root folder. Call this once after the
1699 # container is inital started and before installing any boilerplate stuff.
1701 info_msg "create /.lxcenv in container $1"
1702 cat <<EOF | lxc exec "${1}" -- bash | prefix_stdout "[${_BBlue}${1}${_creset}] "
1709LXC_BASE_PACKAGES_debian="bash git build-essential python3 python3-venv"
1712LXC_BASE_PACKAGES_arch="bash git base-devel python"
1715LXC_BASE_PACKAGES_fedora="bash git @development-tools python"
1718LXC_BASE_PACKAGES_centos="bash git python3"
1721 ubuntu|debian) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_debian}" ;;
1722 arch) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_arch}" ;;
1723 fedora) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_fedora}" ;;
1724 centos) LXC_BASE_PACKAGES="${LXC_BASE_PACKAGES_centos}" ;;
1725 *) err_msg "$DIST_ID-$DIST_VERS: pkg_install LXC_BASE_PACKAGES not yet implemented" ;;
1728lxc_install_base_packages() {
1729 info_msg "install LXC_BASE_PACKAGES in container $1"
1731 centos) yum groupinstall "Development Tools" -y ;;
1733 pkg_install "${LXC_BASE_PACKAGES}"
1739 # usage: lxc_image_copy <remote image> <local image>
1741 # lxc_image_copy "images:ubuntu/20.04" "ubu2004"
1743 if lxc_image_exists "local:${LXC_SUITE[i+1]}"; then
1744 info_msg "image ${LXC_SUITE[i]} already copied --> ${LXC_SUITE[i+1]}"
1746 info_msg "copy image locally ${LXC_SUITE[i]} --> ${LXC_SUITE[i+1]}"
1747 lxc image copy "${LXC_SUITE[i]}" local: \
1748 --alias "${LXC_SUITE[i+1]}" | prefix_stdout
1752lxc_init_container() {
1754 # usage: lxc_init_container <image name> <container name>
1756 local image_name="$1"
1757 local container_name="$2"
1759 if lxc info "${container_name}" &>/dev/null; then
1760 info_msg "container '${container_name}' already exists"
1762 info_msg "create container instance: ${container_name}"
1763 lxc init "local:${image_name}" "${container_name}"
1769 # usage: lxc_exists <name> || echo "container <name> does not exists"
1771 lxc info "$1" &>/dev/null
1775 # usage: lxc_image_exists <alias> || echo "image <alias> does locally not exists"
1777 lxc image info "local:$1" &>/dev/null
1781lxc_delete_container() {
1783 # usage: lxc_delete_container <container-name>
1785 if lxc info "$1" &>/dev/null; then
1786 info_msg "stop & delete instance ${_BBlue}${1}${_creset}"
1787 lxc stop "$1" &>/dev/null
1788 lxc delete "$1" | prefix_stdout
1790 warn_msg "instance '$1' does not exist / can't delete :o"
1794lxc_delete_local_image() {
1796 # usage: lxc_delete_local_image <container-name>
1798 info_msg "delete image 'local:$i'"
1799 lxc image delete "local:$i"
1809 # print list of host's SCOPE global addresses and adapters e.g::
1812 # enp4s0|192.168.1.127
1813 # lxdbr0|10.246.86.1
1814 # lxdbr0|fd42:8c58:2cd:b73f::1
1816 ip -o addr show | sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\1|\2/p'
1824 | sed -nr 's/[0-9]*:\s*([a-z0-9]*).*inet[6]?\s*([a-z0-9.:]*).*scope global.*/\2/p' \
1827 *) hostname -I | cut -d' ' -f1 ;;
1834url_replace_hostname(){
1836 # usage: url_replace_hostname <url> <new hostname>
1838 # to replace hostname by primary IP::
1840 # url_replace_hostname http://searx-ubu1604/morty $(primary_ip)
1841 # http://10.246.86.250/morty
1843 # shellcheck disable=SC2001
1844 echo "$1" | sed "s|\(http[s]*://\)[^/]*\(.*\)|\1$2\2|"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list