Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 79765a2

Browse files
committed
Merge pull request #54 from jdeathe/issue/52
ISSUE 52: Prevent output of test for existing user.
2 parents 69b98b6 + 2086cdb commit 79765a2

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

etc/apache-bootstrap

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ set_apache_server_name ()
5959
/etc/httpd/conf/httpd.conf
6060
}
6161

62+
set_new_username ()
63+
{
64+
local USER_FROM=${1:-app}
65+
local USER_TO=${2:-app}
66+
67+
if [[ ${USER_TO} != root ]] && [[ ${USER_FROM} != root ]] && [[ ${USER_TO} != ${USER_FROM} ]] && [[ -n $(getent passwd ${USER_FROM}) ]]; then
68+
usermod -l ${USER_TO} ${USER_FROM}
69+
fi
70+
}
71+
6272
APP_HOME_DIR_TEMPLATE="/var/www/.app-skel"
6373

6474
OPTS_APACHE_EXTENDED_STATUS_ENABLED="${APACHE_EXTENDED_STATUS_ENABLED:-false}"
@@ -157,13 +167,8 @@ else
157167
fi
158168

159169
# Set the service user / service group user
160-
if getent passwd app && [[ ${OPTS_SERVICE_USER} != app ]]; then
161-
usermod -l ${OPTS_SERVICE_USER} app
162-
fi
163-
164-
if getent passwd app-www && [[ ${OPTS_SERVICE_USER_GROUP} != app-www ]]; then
165-
usermod -l ${OPTS_SERVICE_USER_GROUP} app-www
166-
fi
170+
set_new_username app ${OPTS_SERVICE_USER}
171+
set_new_username app-www ${OPTS_SERVICE_USER_GROUP}
167172

168173
# Set the Apache (run) service user/group
169174
if [[ ${OPTS_SUEXECUSERGROUP} == true ]]; then

0 commit comments

Comments
 (0)