You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2013/12/12 09:29:26 UTC
svn commit: r1550373 - in
/directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers:
apacheds bin/install.sh bin/variables.sh
Author: elecharny
Date: Thu Dec 12 08:29:26 2013
New Revision: 1550373
URL: http://svn.apache.org/r1550373
Log:
Added the RUN_AS_GROUP variable, so that the user can define a different group when installing apacheDS (cf DIRSERVER-1911)
Modified:
directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds
directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/install.sh
directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/variables.sh
Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds?rev=1550373&r1=1550372&r2=1550373&view=diff
==============================================================================
--- directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds (original)
+++ directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds Thu Dec 12 08:29:26 2013
@@ -51,7 +51,7 @@ PIDDIR=$INSTANCE_DIRECTORY/run
# TERM signals.
#IGNORE_SIGNALS=true
-# If specified, the Wrapper will be run as the specified user.
+# If specified, the Wrapper will be run as the specified user and group.
# IMPORTANT - Make sure that the user has the required privileges to write
# the PID file and wrapper.log files. Failure to be able to write the log
# file will cause the Wrapper to exit without any way to write out an error
@@ -60,6 +60,7 @@ PIDDIR=$INSTANCE_DIRECTORY/run
# the JVM and is not useful in situations where a privileged resource or
# port needs to be allocated prior to the user being changed.
RUN_AS_USER="@user@"
+RUN_AS_GROUP="@group@"
# Do not modify anything beyond this point
#-----------------------------------------------------------------------------
@@ -279,7 +280,7 @@ checkUser() {
if [ "X$1" != "X" ]
then
# Resolve the primary group
- RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1`
+ RUN_AS_GROUP=`groups $RUN_AS_GROUP| awk '{print $3}' | tail -1`
if [ "X$RUN_AS_GROUP" = "X" ]
then
RUN_AS_GROUP=$RUN_AS_USER
Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/install.sh
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/install.sh?rev=1550373&r1=1550372&r2=1550373&view=diff
==============================================================================
--- directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/install.sh (original)
+++ directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/install.sh Thu Dec 12 08:29:26 2013
@@ -56,6 +56,8 @@ mv ../server/bin/apacheds.tmp ../server/
verifyExitCode
sed -e "s;@user@;${RUN_AS_USER};" ../server/bin/apacheds > ../server/bin/apacheds.tmp
verifyExitCode
+sed -e "s;@group@;${RUN_AS_GROUP};" ../server/bin/apacheds > ../server/bin/apacheds.tmp
+verifyExitCode
mv ../server/bin/apacheds.tmp ../server/bin/apacheds
verifyExitCode
@@ -117,13 +119,28 @@ verifyExitCode
chmod +x $APACHEDS_HOME_DIRECTORY/bin/wrapper
verifyExitCode
-# Creating the apacheds user (only if needed)
+# Creating the apacheds user and group (only if needed)
USER=`eval "id -u -n $RUN_AS_USER"`
-if [ ! "X$RUN_AS_USER" = "X$USER" ]
+
+# If we don't have any group, use the user's group
+if [ "X$RUN_AS_GROUP" = "X" ]
then
- /usr/sbin/groupadd $RUN_AS_USER >/dev/null 2>&1 || :
+ RUN_AS_GROUP=$RUN_AS_USER
+fi
+
+# Check that the group exists
+GROUP=`eval "if grep -q $RUN_AS_GROUP /etc/group; then echo "$RUN_AS_GROUP"; else echo ""; fi"`
+
+# Create the group if it does not exist
+if [ ! "X$RUN_AS_GROUP" = "XGROUP" ]
+then
+ /usr/sbin/groupadd $RUN_AS_GROUP >/dev/null 2>&1 || :
verifyExitCode
- /usr/sbin/useradd -g $RUN_AS_USER -d $APACHEDS_HOME_DIRECTORY $RUN_AS_USER >/dev/null 2>&1 || :
+fi
+
+if [ ! "X$RUN_AS_USER" = "X$USER" ]
+then
+ /usr/sbin/useradd -g $RUN_AS_GROUP -d $APACHEDS_HOME_DIRECTORY $RUN_AS_USER >/dev/null 2>&1 || :
verifyExitCode
fi
Modified: directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/variables.sh
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/variables.sh?rev=1550373&r1=1550372&r2=1550373&view=diff
==============================================================================
--- directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/variables.sh (original)
+++ directory/apacheds/trunk/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/bin/variables.sh Thu Dec 12 08:29:26 2013
@@ -22,3 +22,4 @@ Where do you want to install ApacheDS in
What name do you want for the default instance|DEFAULT_INSTANCE_NAME|default||
Where do you want to install the startup script|STARTUP_SCRIPT_DIRECTORY|/etc/init.d||
Which user do you want to run the server with (if not already existing, the specified user will be created)|RUN_AS_USER|apacheds||
+Which group do you want to run the server with (if not already existing, the specified group will be created)|RUN_AS_GROUP|apacheds||