diff --git a/add_missing_columns.sh b/add_missing_columns.sh index 6c4af73..59455bd 100755 --- a/add_missing_columns.sh +++ b/add_missing_columns.sh @@ -285,103 +285,9 @@ fi NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then - - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi +source ${snippet_dir}/get-webservice-environment.sh # Check PHP Version # diff --git a/add_missing_indices.sh b/add_missing_indices.sh index ca718f4..d9590ca 100755 --- a/add_missing_indices.sh +++ b/add_missing_indices.sh @@ -285,103 +285,9 @@ fi NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then - - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi +source ${snippet_dir}/get-webservice-environment.sh # Check PHP Version # diff --git a/add_missing_primary-keys.sh b/add_missing_primary-keys.sh index 9ac1e5c..fb21f53 100755 --- a/add_missing_primary-keys.sh +++ b/add_missing_primary-keys.sh @@ -285,103 +285,9 @@ fi NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then - - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi +source ${snippet_dir}/get-webservice-environment.sh # Check PHP Version # diff --git a/check_encryption_scan_legacy-format.sh b/check_encryption_scan_legacy-format.sh index 078d32e..09cd168 100755 --- a/check_encryption_scan_legacy-format.sh +++ b/check_encryption_scan_legacy-format.sh @@ -293,106 +293,14 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi # Check PHP Version # diff --git a/check_for_old_files.sh b/check_for_old_files.sh index 5e79e07..c777528 100755 --- a/check_for_old_files.sh +++ b/check_for_old_files.sh @@ -294,106 +294,14 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi # Check PHP Version # diff --git a/convert_filecache_bigint.sh b/convert_filecache_bigint.sh index 9634275..e6d554d 100755 --- a/convert_filecache_bigint.sh +++ b/convert_filecache_bigint.sh @@ -293,106 +293,14 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi # Check PHP Version # diff --git a/occ_file_scan_all_accounts.sh b/occ_file_scan_all_accounts.sh index 8906141..0c56cc4 100755 --- a/occ_file_scan_all_accounts.sh +++ b/occ_file_scan_all_accounts.sh @@ -266,106 +266,14 @@ fi DEFAULT_HTTP_USER="www-data" DEFAULT_HTTP_GROUP="www-data" + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then PHP_BIN="/usr/local/php/bin/php" diff --git a/occ_file_scan_app-data.sh b/occ_file_scan_app-data.sh index 32b2763..dde321f 100755 --- a/occ_file_scan_app-data.sh +++ b/occ_file_scan_app-data.sh @@ -279,106 +279,14 @@ fi DEFAULT_HTTP_USER="www-data" DEFAULT_HTTP_GROUP="www-data" + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then PHP_BIN="/usr/local/php/bin/php" diff --git a/occ_maintenance.sh b/occ_maintenance.sh index 258ae80..581f654 100755 --- a/occ_maintenance.sh +++ b/occ_maintenance.sh @@ -284,106 +284,14 @@ fi DEFAULT_HTTP_USER="www-data" DEFAULT_HTTP_GROUP="www-data" + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then PHP_BIN="/usr/local/php/bin/php" diff --git a/occ_manual_upgrade.sh b/occ_manual_upgrade.sh index 15a7f40..a84fa0d 100755 --- a/occ_manual_upgrade.sh +++ b/occ_manual_upgrade.sh @@ -284,106 +284,14 @@ fi DEFAULT_HTTP_USER="www-data" DEFAULT_HTTP_GROUP="www-data" + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then PHP_BIN="/usr/local/php/bin/php" diff --git a/occ_update_apps.sh b/occ_update_apps.sh index 509285b..8a7dc62 100755 --- a/occ_update_apps.sh +++ b/occ_update_apps.sh @@ -216,37 +216,11 @@ if [[ -z "$WEBSITE" ]] ; then # - IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}")) - WEBSITE= - _OK=false - echo "" - echo "Which site would you like to update?" - echo "" - declare -i i=0 - for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) - done - echo - echononl " Eingabe: " - while ! $_OK ; do - read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - _WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi - done - WEBSITE="$_WEBSITE" + # Which cloud instance (website) would you like to update + # + source ${snippet_dir}/get-cloud-instance-to-update - #fatal "No website ios given on commandline - Missing Parameter '-s '" fi @@ -313,103 +287,10 @@ DEFAULT_HTTP_GROUP="www-data" NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then PHP_BIN="/usr/local/php/bin/php" diff --git a/remove_user_from_group.sh b/remove_user_from_group.sh index 3ba129d..f716cdd 100755 --- a/remove_user_from_group.sh +++ b/remove_user_from_group.sh @@ -321,106 +321,14 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi # Check PHP Version # diff --git a/replace_favicon.sh b/replace_favicon.sh index 9ea4c25..0735f33 100755 --- a/replace_favicon.sh +++ b/replace_favicon.sh @@ -282,106 +282,14 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi # Check PHP Version # diff --git a/replace_logo.sh b/replace_logo.sh index c5f6b9e..bf4f50c 100755 --- a/replace_logo.sh +++ b/replace_logo.sh @@ -282,106 +282,14 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then +source ${snippet_dir}/get-webservice-environment.sh - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP -fi # Check PHP Version # diff --git a/restore_nextcloud.sh b/restore_nextcloud.sh index 78332af..6594349 100755 --- a/restore_nextcloud.sh +++ b/restore_nextcloud.sh @@ -287,97 +287,13 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then - - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi +source ${snippet_dir}/get-webservice-environment.sh # Check PHP Version diff --git a/snippets/get-webservice-environment.sh b/snippets/get-webservice-environment.sh new file mode 100644 index 0000000..10aa45b --- /dev/null +++ b/snippets/get-webservice-environment.sh @@ -0,0 +1,97 @@ +if $(systemctl -q is-enabled nginx 2> /dev/null) ; then + + NGINX_IS_ENABLED=true + + # - Determin user of the webserver + # - + nginx_binary="$(which nginx)" + if [[ -z "$nginx_binary" ]] ; then + nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" + if [[ -z "$nginx_binary" ]] ; then + if [[ -x "/usr/local/nginx/bin/nginx" ]]; then + nginx_binary="/usr/local/nginx/bin/nginx" + elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then + nginx_binary="/usr/local/nginx/sbin/nginx" + fi + fi + fi + + if [[ -x "$nginx_binary" ]] ; then + _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" + fi + + # - Is webserver running ? + # - + PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') + if [[ "X${PID}X" = "XX" ]] ;then + IS_HTTPD_RUNNING=false + else + IS_HTTPD_RUNNING=true + fi + + +elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then + + APACHE2_IS_ENABLED=true + + # - Determin user of the webserver + # - + httpd_binary="`which httpd`" + if [ -z "$httpd_binary" ]; then + httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" + if [ -z "$httpd_binary" ]; then + if [ -x "/usr/local/apache2/bin/httpd" ]; then + httpd_binary="/usr/local/apache2/bin/httpd" + fi + fi + fi + if [ -x "$httpd_binary" ];then + + # - Determin websever user + # - + _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" + _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" + + # - Is webserver running ? + # - + PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') + if [[ "X${PID}X" = "XX" ]] ;then + IS_HTTPD_RUNNING=false + else + IS_HTTPD_RUNNING=true + fi + fi + +else + error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted by user" +fi + + +if [[ -n "$_HTTP_USER" ]] ; then + if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then + warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." + else + HTTP_USER=$_HTTP_USER + fi +else + [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER +fi + +if [[ -n "$_HTTP_GROUP" ]] ; then + if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then + warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." + else + HTTP_GROUP=$_HTTP_GROUP + fi +else + [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$HTTP_USER +fi diff --git a/update_nextcloud.sh b/update_nextcloud.sh index 4fad4aa..50177e5 100755 --- a/update_nextcloud.sh +++ b/update_nextcloud.sh @@ -372,108 +372,13 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi + NGINX_IS_ENABLED=false APACHE2_IS_ENABLED=false -# Check if NGINX webserver is ctive +# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP.. # -if $(systemctl -q is-enabled nginx 2> /dev/null) ; then - - NGINX_IS_ENABLED=true - - # - Determin user of the webserver - # - - nginx_binary="$(which nginx)" - if [[ -z "$nginx_binary" ]] ; then - nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")" - if [[ -z "$nginx_binary" ]] ; then - if [[ -x "/usr/local/nginx/bin/nginx" ]]; then - nginx_binary="/usr/local/nginx/bin/nginx" - elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then - nginx_binary="/usr/local/nginx/sbin/nginx" - fi - fi - fi - - if [[ -x "$nginx_binary" ]] ; then - _HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')" - fi - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - - -elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then - - APACHE2_IS_ENABLED=true - - # - Determin user of the webserver - # - - httpd_binary="`which httpd`" - if [ -z "$httpd_binary" ]; then - httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" - if [ -z "$httpd_binary" ]; then - if [ -x "/usr/local/apache2/bin/httpd" ]; then - httpd_binary="/usr/local/apache2/bin/httpd" - fi - fi - fi - if [ -x "$httpd_binary" ];then - - # - Determin websever user - # - - _HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - _HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" - - # - Is webserver running ? - # - - PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}') - if [[ "X${PID}X" = "XX" ]] ;then - IS_HTTPD_RUNNING=false - else - IS_HTTPD_RUNNING=true - fi - fi - -else - error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine" - - echononl "continue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " - read OK - done - [[ $OK = "yes" ]] || fatal "Interrupted by user" -fi - - -if [[ -n "$_HTTP_USER" ]] ; then - if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then - warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence." - else - HTTP_USER=$_HTTP_USER - fi -else - [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER -fi - -if [[ -n "$_HTTP_GROUP" ]] ; then - if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then - warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence." - else - HTTP_GROUP=$_HTTP_GROUP - fi -else - [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$HTTP_USER -fi +source ${snippet_dir}/get-webservice-environment.sh # Check PHP Version