Provide credentials to Synchrony standalone using environment variables (Linux)

Still need help?

The Atlassian Community is here for you.

Ask the community

This guide applies to Confluence Data Center 6.5 and later.

This guide does NOT apply if Synchrony is managed by Confluence (available in Confluence 6.12 and later).

Purpose

If you're running Synchrony standalone in a cluster, and you prefer to store sensitive information in your environment, rather than directly in the Synchrony startup scripts you can create a synchronyenv file, and use it to provide your database credentials. 

These instructions are for Linux users. We'll assume your dedicated Synchrony user is named synchrony.

Steps

Create the synchronyenv file

  1. Change to your Synchrony user, for example:

    sudo su - synchrony
  2. In your <synchrony-home> directory, create a new file called synchronyenv.
  3. Add the following lines to the synchronyenv file, and include your database credentials.

    export SYNCHRONY_DATABASE_USERNAME="database-username"
    export SYNCHRONY_DATABASE_PASSWORD="database-password"
  4. Make sure to make this file executable, so it can be sourced by start-synchrony.sh
    chmod +x synchronyenv

Modify your Synchrony startup script

  1. Edit your start-synchrony.sh  script. 

  2. Comment out the following lines

    DATABASE_USER="<DB_USERNAME>"
    DATABASE_PASSWORD="<DB_PASSWORD>"

    Note that they may already be commented out, or have slightly different information. 

  3. Uncomment the following line, and include the path to the synchronyenv file you've just created.

    SYNCHRONY_ENV_FILE="<PATH_TO_ENV_FILE>"
  4. Save your changes. 

Modify your shell profile

Bash as login shell will load the following profiles in order. Your environment may vary, but this is an example for Ubuntu:

  • /etc/profile
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile

Note: Bash as non-login interactive shell will load ~/.bashrc

  1. Edit the appropriate profile as noted above, and to add the following code:

    # Defines the absolute path to the synchronyenv file. 
    # For example, if your synchronyenv file was located in
    /opt/synchrony-home/synchrony, you would use the example:
    source /opt/synchrony-home/synchrony/synchronyenv
  2. Confirm the variables are in place by exiting the bash session of the Synchrony user, then re-entering it, and running the following command:

    env
  3. Your database credentials defined should appear in your env output. Here's a sanitized example:

    XDG_SESSION_ID=15
    SYNCHRONY_DATABASE_PASSWORD=<sanitized>
    ...
    SYNCHRONY_DATABASE_USERNAME=<sanitized>
    ...
    _=/usr/bin/env

If the info you defined in your synchronyenv file appears correctly in the output above, you should be good to start Synchrony once again. If they don't appear, you may need to define them in a different profile config, based on your operating system and shell.

Last modified on Dec 21, 2018

Was this helpful?

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