occ_file_scan_all_accounts.sh: add support for nginx webservice..

This commit is contained in:
Christoph 2021-12-04 14:34:53 +01:00
parent 1ed083f60d
commit 0a4997484c

View File

@ -249,8 +249,48 @@ fi
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# - Determin user/group of the webserver
# Check if NGINX webserver is ctive
#
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
@ -278,6 +318,19 @@ if [ -x "$httpd_binary" ];then
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."