Files
opensim-docker/image-opensim/config-osgrid/scripts/setEnvironment.sh
T
LordfoxandLordfox c7dc77ee66 ISSUE-17: fixes obsolete "version" attribute inside docker-compose.ym… (#18)
* ISSUE-17: fixes obsolete "version" attribute inside docker-compose.yml files

* added .gitignore with some general basic settings

* dockerfiles fixes
- fixes missing permissions for .sh files inside the images
- fixes COPY of multiple files (missing trailing slash '/' on target path
- fixes use of hardcoded username:usergroup on COPY --chown

* dockerfiles fixes
- fixes COPY of multiple files (missing trailing slash '/' on target path

* fixes missing OS_CONFIGKEY on setEnvironment.sh files

---------

Co-authored-by: Lordfox <c.haendler@lordfox.de>
2025-10-03 14:12:44 -07:00

44 lines
1.6 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=${OPENSIMCONFIG:-$OPENSIMBIN/config}
cd "$OPENSIMCONFIG"
# See if we have encrypted secrets
unset HAVE_SECRETS
if [[ ! -z "$OS_CONFIGKEY" ]] ; then
for secretsFile in $OPENSIMCONFIG/os-secrets.crypt ; do
if [[ -e "$secretsFile" ]] ; then
echo "opensim-docker: setEnvironment.sh: have secrets file \"{$secretsFile}\""
# export key for ccrypt - otherwise it fails
export OS_CONFIGKEY=$OS_CONFIGKEY;
source <(ccrypt -c -E OS_CONFIGKEY "$secretsFile")
# unset the key again
unset OS_CONFIGKEY;
HAVE_SECRETS=yes
break;
else
echo "opensim-docker: setEnvironment.sh: no encrypted 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/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