forgot script 'add_user_to_group.sh'..

This commit is contained in:
Christoph 2023-08-02 23:19:58 +02:00
parent 14f062908f
commit 1df7bb124b

View File

@ -320,106 +320,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
#