Setting Crowd to Run Automatically and Use an Unprivileged System User on UNIX

Please note this script is just for your reference and Atlassian does not guarantee that this will work for you. This script has been tested against some particular variant of Linux but then due to ever changing nature of Linux distribution, this may or may not work for you. In case this script does not work for you, please reach out to your Infrastructure Administrator for more complete and tested solution. 

This page contains some useful information about running Crowd under Linux/UNIX:

  • Dedicated system user. For security reasons, and to keep your system administrator happy, you should probably create a dedicated non-root user to run Crowd.
  • Automatic startup. It is useful to set up Crowd to run automatically on UNIX startup.

Running Crowd as an Unprivileged User

Here is an example of some of the changes you can make to harden up the directory and file permissions for Crowd to run as a non-root user.

You will need to update the environment variables to suit your installation. This is also for use in BASH. If you are using a different shell, you might need to tweak some things.

sudo chgrp ${CROWD_GROUP} ${INSTALL_BASE}/{*.sh,apache-tomcat/bin/*.sh}
sudo chmod g+x ${INSTALL_BASE}/{*.sh,apache-tomcat/bin/*.sh}
sudo chown -R ${CROWD_USER} ${CROWD_HOME} ${INSTALL_BASE}/apache-tomcat/{logs,work,temp}
sudo touch -a ${INSTALL_BASE}/atlassian-crowd-openid-server.log
sudo mkdir ${INSTALL_BASE}/database
sudo chown -R ${CROWD_USER} ${INSTALL_BASE}/{database,atlassian-crowd-openid-server.log}

Getting Crowd to Start Automatically

  1. Create an init.d file (for example, 'crowd.init.d') inside your {CROWD_INSTALL} directory:

    #!/bin/sh -e
    # Crowd startup script
    #chkconfig: 2345 80 05
    #description: Crowd
    # Define some variables
    # Name of app ( JIRA, Confluence, etc )
    # Name of the user to run as
    # Location of Crowd install directory
    # Location of Java JDK
    export JAVA_HOME=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64
    case "$1" in
      # Start command
        echo "Starting $APP"
        /bin/su -m $USER -c "$CATALINA_HOME/ &> /dev/null"
      # Stop command
        echo "Stopping $APP"
        /bin/su -m $USER -c "$CATALINA_HOME/ &> /dev/null"
        echo "$APP stopped successfully"
       # Restart command
            $0 stop
            sleep 5
            $0 start
        echo "Usage: /etc/init.d/$APP {start|restart|stop}"
        exit 1
    exit 0
  2. Create a symbolic link from /etc/init.d/crowd to the init.d file file.
tip/resting Created with Sketch.

Hint for Red Hat systems

On Red Hat and Red Hat-based systems such as CentOS, if you put the above script in /etc/init.d, you can create the necessary symbolic links with the chkconfig script, since all the rrequired information is in the script header.

sudo /sbin/chkconfig --add SCRIPT_NAME

Replace "SCRIPT_NAME" with whatever the real name of the script is.

Thank you for this information

Thank you to Matthew Block and Pete Toscano for the original comments that we based this information on.

Last modified on Jun 17, 2021

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.