Moves user check into Apache usecase.

This commit is contained in:
Llewellyn van der Merwe 2022-01-20 14:14:08 +02:00
parent 6b42540f50
commit 66e04002a2
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
13 changed files with 182 additions and 169 deletions

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then

View File

@ -18,6 +18,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
pound='#'
user="${user#$pound}"
group="${group#$pound}"
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
;;
*) # php-fpm
user='www-data'
@ -28,19 +42,6 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
user="$uid"
group="$gid"
fi
# set user if not exist
if ! id "$user" &>/dev/null; then
# get the user name
: "${USER_NAME:=www-data}"
# change the user name
[[ "$USER_NAME" != "www-data" ]] &&
usermod -l "$USER_NAME" www-data &&
groupmod -n "$USER_NAME" www-data
# update the user ID
groupmod -o -g "$user" "$USER_NAME"
# update the user-group ID
usermod -o -u "$group" "$USER_NAME"
fi
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$JOOMLA_DB_HOST" ]; then