From 9b5a7f7559faf121e44ba3e7260290bd7efe74bf Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 20 Jan 2020 16:55:05 +0100 Subject: utils/searx.sh: add script to install isolated searx service First version which serves searx over uwsgi at http://127.0.0.1:8888 Signed-off-by: Markus Heiser --- utils/lib.sh | 64 ++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 23 deletions(-) (limited to 'utils/lib.sh') diff --git a/utils/lib.sh b/utils/lib.sh index 827862b7c..fadbcd648 100755 --- a/utils/lib.sh +++ b/utils/lib.sh @@ -373,66 +373,84 @@ uWSGI_restart() { sudo -H systemctl restart uwsgi } +uWSGI_app_available() { + # usage: uWSGI_app_available + local CONF="$1" + if [[ -z $CONF ]]; then + err_msg "uWSGI_app_available: missing arguments" + return 42 + fi + [[ -f "${uWSGI_SETUP}/apps-available/${CONF}" ]] +} + uWSGI_install_app() { - # usage: uWSGI_install_app [--no-eval] /etc/uwsgi/apps-available/myapp.ini + # usage: uWSGI_install_app [--no-eval] local no_eval="" - local CONF="" + local CONF="$1" if [[ "$1" == "--no-eval" ]]; then no_eval=$1; shift fi - CONF=$1 # shellcheck disable=SC2086 - install_template $no_eval "${CONF}" root root 644 - uWSGI_enable_app "$(basename "${CONF}")" + install_template $no_eval "${uWSGI_SETUP}/apps-available/${CONF}" root root 644 + uWSGI_enable_app "${CONF}" uWSGI_restart - info_msg "installed uWSGI app: $(basename "${CONF}")" + info_msg "installed uWSGI app: ${CONF}" } uWSGI_remove_app() { - # usage: uWSGI_remove_app + # usage: uWSGI_remove_app - local CONF=$1 - uWSGI_disable_app "$(basename "${CONF}")" + local CONF="$1" + uWSGI_disable_app "${CONF}" uWSGI_restart - rm -f "$CONF" - info_msg "removed uWSGI app: $(basename "${CONF}")" + rm -f "${uWSGI_SETUP}/apps-available/${CONF}" + info_msg "removed uWSGI app: ${CONF}" +} + +uWSGI_app_enabled() { + # usage: uWSGI_app_enabled + local CONF="$1" + if [[ -z $CONF ]]; then + err_msg "uWSGI_app_enabled: missing arguments" + return 42 + fi + [[ -f "${uWSGI_SETUP}/apps-enabled/${CONF}" ]] } # shellcheck disable=SC2164 uWSGI_enable_app() { - # usage: uWSGI_enable_app + # usage: uWSGI_enable_app - local CONF=$1 + local CONF="$1" if [[ -z $CONF ]]; then - err_msg "uWSGI_enable_app missing arguments" + err_msg "uWSGI_enable_app: missing arguments" return 42 fi pushd "${uWSGI_SETUP}/apps-enabled" >/dev/null - rm -f "$(basename "${CONF}")" + rm -f "$CONF" # shellcheck disable=SC2226 - ln -s "../apps-available/$(basename "${CONF}")" - info_msg "enabled uWSGI app: $(basename "${CONF}") (restart uWSGI required)" + ln -s "../apps-available/${CONF}" + info_msg "enabled uWSGI app: ${CONF} (restart uWSGI required)" popd >/dev/null } uWSGI_disable_app() { - # usage: uWSGI_disable_app + # usage: uWSGI_disable_app - local CONF=$1 + local CONF="$1" if [[ -z $CONF ]]; then - err_msg "uWSGI_enable_app missing arguments" + err_msg "uWSGI_enable_app: missing arguments" return 42 fi - - rm -f "${uWSGI_SETUP}/apps-enabled/$CONF" - info_msg "disabled uWSGI app: $(basename "${CONF}") (restart uWSGI required)" + rm -f "${uWSGI_SETUP}/apps-enabled/${CONF}" + info_msg "disabled uWSGI app: ${CONF} (restart uWSGI required)" } # distro's package manager -- cgit v1.2.3