diff --git a/image-opensim-herbal3d/config/scripts/updateConfigFiles.sh b/image-opensim-herbal3d/config/scripts/updateConfigFiles.sh index 328a603..2d3ab4f 100755 --- a/image-opensim-herbal3d/config/scripts/updateConfigFiles.sh +++ b/image-opensim-herbal3d/config/scripts/updateConfigFiles.sh @@ -32,8 +32,8 @@ fi echo "opensim-docker: updateConfigFiles.sh: replacing vars in \"${CONFIGDIR}/misc.ini\"" # If the replacement has already happened, this is a NOOP sed --in-place \ - -e "s/MYSQL_DB_USER/$MYSQL_DB_USER/" \ -e "s/MYSQL_DB_USER_PASSWORD/$MYSQL_DB_USER_PASSWORD/" \ + -e "s/MYSQL_DB_USER/$MYSQL_DB_USER/" \ -e "s/MYSQL_DB_SOURCE/$MYSQL_DB_SOURCE/" \ -e "s/MYSQL_DB_DB/$MYSQL_DB_DB/" \ -e "s/PW_FOR_DEFAULT_ESTATE_OWNER/$PW_FOR_DEFAULT_ESTATE_OWNER/" \ diff --git a/image-opensim-herbal3d/restart-herbal3d.sh b/image-opensim-herbal3d/restart-herbal3d.sh new file mode 100755 index 0000000..22c54e0 --- /dev/null +++ b/image-opensim-herbal3d/restart-herbal3d.sh @@ -0,0 +1,28 @@ +#! /bin/bash +# Stop the running opensimulator + +BASE=$(pwd) + +export CONFIG_NAME=${CONFIG_NAME:-standalone} + +# This export fakes out the environment setup script to look for files in +# build environment rather than in run environment. +export OPENSIMBIN=$BASE +source config/scripts/setEnvironment.sh +unset OPENSIMBIN + +# Use the generic docker-compose file or the one specific to the configuration if it exists +cd "$BASE" +COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose.yml" +if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then + # if using external configuration, include docker-compose with the mount + COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose-external-config.yml" +fi + + +echo "Restarting configuration $CONFIG_NAME from \"$COMPOSEFILE\"" + +docker-compose \ + --file "$COMPOSEFILE" \ + --project-name opensim-${CONFIG_NAME} \ + restart diff --git a/image-opensim-herbal3d/restart-just-opensim.sh b/image-opensim-herbal3d/restart-just-opensim.sh new file mode 100755 index 0000000..34fb446 --- /dev/null +++ b/image-opensim-herbal3d/restart-just-opensim.sh @@ -0,0 +1,28 @@ +#! /bin/bash +# Stop the running opensimulator + +BASE=$(pwd) + +export CONFIG_NAME=${CONFIG_NAME:-standalone} + +# This export fakes out the environment setup script to look for files in +# build environment rather than in run environment. +export OPENSIMBIN=$BASE +source config/scripts/setEnvironment.sh +unset OPENSIMBIN + +# Use the generic docker-compose file or the one specific to the configuration if it exists +cd "$BASE" +COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose.yml" +if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then + # if using external configuration, include docker-compose with the mount + COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose-external-config.yml" +fi + + +echo "Restarting configuration $CONFIG_NAME from \"$COMPOSEFILE\"" + +docker-compose \ + --file "$COMPOSEFILE" \ + --project-name opensim-${CONFIG_NAME} \ + restart -t 10 opensim diff --git a/image-opensim-herbal3d/run-herbal3d.sh b/image-opensim-herbal3d/run-herbal3d.sh index b2ce8b4..e388530 100755 --- a/image-opensim-herbal3d/run-herbal3d.sh +++ b/image-opensim-herbal3d/run-herbal3d.sh @@ -33,15 +33,18 @@ export CONFIG_NAME=${CONFIG_NAME:-standalone} # build environment rather than in run environment. export OPENSIMBIN=$BASE +# set all environment variables +echo "Setting environemtn vars" +source config/scripts/setEnvironment.sh +# echo "================================" +# env | sort +# echo "================================" + # if configuration files are external to the container, run the configuration if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then echo "opensim-docker: running configuration file initialization" config/scripts/updateConfigFiles.sh config/scripts/linkInConfigs.sh -else - echo "opensim-docker: delaying configuration file initialization to configuration start" - # Just set the configuration variables into the environment - source config/scripts/setEnvironment.sh fi # Use the generic docker-compose file or the one specific to the configuration if it exists @@ -51,11 +54,13 @@ if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then # if using external configuration, include docker-compose with the mount COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose-external-config.yml" fi +echo "Docker-compose file: ${COMPOSEFILE}" # Local directory for storage of sql persistant data (so region # contents persists between container restarts). # This must be the same directory as in config-$CONFIG_NAME/docker-compose.yml. if [[ ! -d "$HOME/opensim-sql-data" ]] ; then + echo "Directory \"$HOME\opensim-sql-data\" does not exist. Creating same." mkdir -p "$HOME/opensim-sql-data" chmod o+w "$HOME/opensim-sql-data" fi @@ -64,7 +69,7 @@ fi # --userns-remap="opensim:opensim" docker-compose \ --file "$COMPOSEFILE" \ - --project-name opensim-herbal3d \ + --project-name opensim-${CONFIG_NAME} \ --project-directory "$BASE" \ up \ --detach diff --git a/image-opensim-herbal3d/stop-herbal3d.sh b/image-opensim-herbal3d/stop-herbal3d.sh index e7eb0a8..b8ead19 100644 --- a/image-opensim-herbal3d/stop-herbal3d.sh +++ b/image-opensim-herbal3d/stop-herbal3d.sh @@ -13,14 +13,15 @@ unset OPENSIMBIN # Use the generic docker-compose file or the one specific to the configuration if it exists cd "$BASE" -COMPOSEFILE=./docker-compose.yml -if [[ -e "config/config-${CONFIG_NAME}/docker-compose.yml" ]] ; then - COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose.yml" +COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose.yml" +if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then + # if external configuration, include docker-compose with the mount + COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose-external-config.yml" fi echo "Stopping configuration $CONFIG_NAME from \"$COMPOSEFILE\"" docker-compose \ --file "$COMPOSEFILE" \ - --project-name opensim-standalone \ + --project-name opensim-${CONFIG_NAME} \ down diff --git a/image-opensim/config/scripts/updateConfigFiles.sh b/image-opensim/config/scripts/updateConfigFiles.sh index 328a603..2d3ab4f 100755 --- a/image-opensim/config/scripts/updateConfigFiles.sh +++ b/image-opensim/config/scripts/updateConfigFiles.sh @@ -32,8 +32,8 @@ fi echo "opensim-docker: updateConfigFiles.sh: replacing vars in \"${CONFIGDIR}/misc.ini\"" # If the replacement has already happened, this is a NOOP sed --in-place \ - -e "s/MYSQL_DB_USER/$MYSQL_DB_USER/" \ -e "s/MYSQL_DB_USER_PASSWORD/$MYSQL_DB_USER_PASSWORD/" \ + -e "s/MYSQL_DB_USER/$MYSQL_DB_USER/" \ -e "s/MYSQL_DB_SOURCE/$MYSQL_DB_SOURCE/" \ -e "s/MYSQL_DB_DB/$MYSQL_DB_DB/" \ -e "s/PW_FOR_DEFAULT_ESTATE_OWNER/$PW_FOR_DEFAULT_ESTATE_OWNER/" \ diff --git a/image-opensim/pushOpenSimImage.sh b/image-opensim/pushOpenSimImage.sh new file mode 100755 index 0000000..1e4aafb --- /dev/null +++ b/image-opensim/pushOpenSimImage.sh @@ -0,0 +1,20 @@ +#! /bin/bash +# Push the local image named "opensim-opensim" to the repository. +# The image tag is set to "latest". + +# The repository image name can be over-ridden with the environment variable REPO_IMAGE. + +export DOCKER_REPOSITORY=${DOCKER_REPOSITORY:-misterblue} +export IMAGE_NAME=${IMAGE_NAME:-opensim-opensim} +export IMAGE_VERSION=${IMAGE_VERSION:-latest} + +VERSIONLABEL=$(docker run --rm --entrypoint /home/opensim/getVersion.sh opensim-opensim VERSION_TAG) + +echo "Pushing docker image for opensim version ${VERSIONLABEL}" + +for tagg in ${VERSIONLABEL} ${IMAGE_VERSION} ; do + IMAGE=${DOCKER_REPOSITORY}/${IMAGE_NAME}:${tagg} + docker tag ${IMAGE_NAME} ${IMAGE} + echo " Pushing ${IMAGE}" + docker push ${IMAGE} +done diff --git a/image-opensim/restart-opensim.sh b/image-opensim/restart-opensim.sh new file mode 100755 index 0000000..22c54e0 --- /dev/null +++ b/image-opensim/restart-opensim.sh @@ -0,0 +1,28 @@ +#! /bin/bash +# Stop the running opensimulator + +BASE=$(pwd) + +export CONFIG_NAME=${CONFIG_NAME:-standalone} + +# This export fakes out the environment setup script to look for files in +# build environment rather than in run environment. +export OPENSIMBIN=$BASE +source config/scripts/setEnvironment.sh +unset OPENSIMBIN + +# Use the generic docker-compose file or the one specific to the configuration if it exists +cd "$BASE" +COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose.yml" +if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then + # if using external configuration, include docker-compose with the mount + COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose-external-config.yml" +fi + + +echo "Restarting configuration $CONFIG_NAME from \"$COMPOSEFILE\"" + +docker-compose \ + --file "$COMPOSEFILE" \ + --project-name opensim-${CONFIG_NAME} \ + restart diff --git a/image-opensim/run-opensim.sh b/image-opensim/run-opensim.sh index d195ee6..87ed7af 100755 --- a/image-opensim/run-opensim.sh +++ b/image-opensim/run-opensim.sh @@ -1,5 +1,5 @@ #! /bin/bash -# Run the default Docker image using the standalone configuration. +# Run the OpenSimulator image # Since the initial run has to create and initialize the MYSQL database # the first time, this sets the passwords into the environment before @@ -33,15 +33,18 @@ export CONFIG_NAME=${CONFIG_NAME:-standalone} # build environment rather than in run environment. export OPENSIMBIN=$BASE +# set all environment variables +echo "Setting environment vars" +source config/scripts/setEnvironment.sh +# echo "================================" +# env | sort +# echo "================================" + # if configuration files are external to the container, run the configuration if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then echo "opensim-docker: running configuration file initialization" config/scripts/updateConfigFiles.sh config/scripts/linkInConfigs.sh -else - echo "opensim-docker: delaying configuration file initialization to configuration start" - # Just set the configuration variables into the environment - source config/scripts/setEnvironment.sh fi # Use the generic docker-compose file or the one specific to the configuration if it exists @@ -51,18 +54,22 @@ if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then # if using external configuration, include docker-compose with the mount COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose-external-config.yml" fi +echo "Docker-compose file: ${COMPOSEFILE}" # Local directory for storage of sql persistant data (so region # contents persists between container restarts). # This must be the same directory as in config-$CONFIG_NAME/docker-compose.yml. if [[ ! -d "$HOME/opensim-sql-data" ]] ; then + echo "Directory \"$HOME/opensim-sql-data/\" does not exist. Creating same." mkdir -p "$HOME/opensim-sql-data" chmod o+w "$HOME/opensim-sql-data" fi +# https://docs.docker.com/engine/security/userns-remap/ +# --userns-remap="opensim:opensim" docker-compose \ --file "$COMPOSEFILE" \ - --project-name opensim-standalone \ + --project-name opensim-${CONFIG_NAME} \ --project-directory "$BASE" \ up \ --detach diff --git a/image-opensim/stop-opensim.sh b/image-opensim/stop-opensim.sh index e7eb0a8..7da4ebc 100755 --- a/image-opensim/stop-opensim.sh +++ b/image-opensim/stop-opensim.sh @@ -13,14 +13,15 @@ unset OPENSIMBIN # Use the generic docker-compose file or the one specific to the configuration if it exists cd "$BASE" -COMPOSEFILE=./docker-compose.yml -if [[ -e "config/config-${CONFIG_NAME}/docker-compose.yml" ]] ; then - COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose.yml" +COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose.yml" +if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then + # if using external configuration, include docker-compose with the mount + COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose-external-config.yml" fi echo "Stopping configuration $CONFIG_NAME from \"$COMPOSEFILE\"" docker-compose \ --file "$COMPOSEFILE" \ - --project-name opensim-standalone \ + --project-name opensim-${CONFIG_NAME} \ down