Files
opensim-docker/image-opensim/config/scripts/setEnvironment.sh
T
Robert Adams 479aa9114a Rename the configuration directories to "config-${CONFIG_NAME}"
to make the configuration directories clearer and easier to understand.
2022-02-05 20:42:18 +00:00

48 lines
1.8 KiB
Bash
Executable File

#! /bin/bash
# Script that sets up the environment variables
# This script is run before the docker-compose file is run to get the
# database password and it is run when the opensim Docker container starts
# to get all the values for the configuration files.
OPENSIMBIN=${OPENSIMBIN:-/home/opensim/opensim/bin}
OPENSIMCONFIG="$OPENSIMBIN/config"
cd "$OPENSIMCONFIG"
if [[ -e "./os-config" ]] ; then
source ./os-config
echo "opensim-docker: setEnvironment.sh: CONFIG_NAME=${CONFIG_NAME} from ./os-config"
else
export CONFIG_NAME=${CONFIG_NAME:-standalone}
echo "opensim-docker: setEnvironment.sh: CONFIG_NAME=${CONFIG_NAME} as default"
fi
# See if we have encrypted secrets
unset HAVE_SECRETS
if [[ ! -z "$CONFIGKEY" ]] ; then
for secretsFile in $OPENSIMCONFIG/config-${CONFIG_NAME}/os-secrets.crypt $OPENSIMCONFIG/os-secrets.crypt ; do
if [[ -e "$secretsFile" ]] ; then
echo "opensim-docker: setEnvironment.sh: have secrets file \"{$secretsFile}\""
source <(ccrypt -c -E CONFIGKEY "$secretsFile")
HAVE_SECRETS=yes
break;
else
echo "opensim-docker: setEnvironment.sh: no secrets file"
fi
done
fi
# If no encrypted secrets, maybe unsecure plain-text secrets are available
if [[ -z "$HAVE_SECRETS" ]] ; then
echo "opensim-docker: setEnvironment.sh: trying plain text secrets"
for secretsFile in $OPENSIMCONFIG/config-${CONFIG_NAME}/os-secrets $OPENSIMCONFIG/os-secrets ; do
if [[ -e "$secretsFile" ]] ; then
echo "opensim-docker: setEnvironment.sh: plain text secrets from \"${secretsFile}\""
source "$secretsFile"
break;
else
echo "opensim-docker: setEnvironment.sh: no plain text secrets file"
fi
done
fi