From 9e38b08a0e3d5c27ae79c08c28163353312d073e Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 11 Apr 2021 12:47:13 +0200 Subject: [PATCH] update_nextcloud.sh: support nginx webserver. --- update_nextcloud.sh | 107 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 96 insertions(+), 11 deletions(-) diff --git a/update_nextcloud.sh b/update_nextcloud.sh index 2b8dfd9..a2688be 100755 --- a/update_nextcloud.sh +++ b/update_nextcloud.sh @@ -382,6 +382,14 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi +# Check if NGINX webserver is ctive +# +if $(systemctl -q is-active nginx) ; then + NGINX_IS_ACTIVE=true +else + NGINX_IS_ACTIVE=false +fi + # Check PHP Version # if [[ "$PHP_ENGINE" = "FPM" ]] ; then @@ -623,22 +631,52 @@ fi # - echo "" echononl " Stop Apache Webserver.." -if $SYSTEMD_EXISTS ; then - systemctl stop apache2 - if [[ $? -eq 0 ]]; then - echo_ok +if $IS_HTTPD_RUNNING ; then + if $SYSTEMD_EXISTS ; then + systemctl stop apache2 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi else - echo_failed - fatal "$(cat $log_file)" + /etc/init.d/apache2 stop + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi fi else - /etc/init.d/apache2 stop - if [[ $? -eq 0 ]]; then - echo_ok + echo_skipped +fi + +# - Stop Nginx Webservice +# - +echo "" +echononl " Stop Nginx Webserver.." +if $NGINX_IS_ACTIVE ; then + if $SYSTEMD_EXISTS ; then + systemctl stop apache2 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi else - echo_failed - fatal "$(cat $log_file)" + /etc/init.d/apache2 stop + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi fi +else + echo_skipped fi echo "" @@ -1331,6 +1369,53 @@ else warn "The webserver was not running, so it will be keept down!" fi + +# - Start NGINX Webservise +# - +echo "" +echononl " Start Nginx Webserver.." +if $NGINX_IS_ACTIVE ; then + if $SYSTEMD_EXISTS ; then + systemctl start nginx > $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + + fi + else + /etc/init.d/nginx start > $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user." + fi + fi +else + echo_skipped + warn "The NGINX is not configured as active - so nothing to do." +fi + _redis_cli_bin="$(which redis-cli)" if [[ -z "$_redis_cli_bin" ]]; then if [[ -x "/usr/local/bin/redis-cli" ]]; then