diff --git a/build/latest/Dockerfile.alpine b/build/latest/Dockerfile.alpine index a4f6ec4..ed1254c 100644 --- a/build/latest/Dockerfile.alpine +++ b/build/latest/Dockerfile.alpine @@ -25,7 +25,7 @@ EXPOSE 9000 WORKDIR /opt/opensim/bin -COPY docker-entrypoint.ash /usr/local/bin/docker-entrypoint.sh +COPY docker-entrypoint.sh /usr/local/bin/ ENTRYPOINT ["docker-entrypoint.sh"] CMD [ "screen", "-S", "OpenSim", "-D", "-m", "dotnet", "OpenSim.dll" ] diff --git a/build/latest/docker-entrypoint.ash b/build/latest/docker-entrypoint.ash deleted file mode 100644 index 903093b..0000000 --- a/build/latest/docker-entrypoint.ash +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env ash -set -Eeo pipefail - -chown -R $(id -u):$(id -g) defaults - -if [ ! -e OpenSim.ini ]; then - echo >&2 "INFO: No OpenSim configuration found, pulling one together." - cp defaults/OpenSim.ini OpenSim.ini - - if [ -n "${PHYSICS_ENGINE}" ]; then - echo -e "\n[Startup] - physics = ${PHYSICS_ENGINE:-BulletSim}" >> OpenSim.ini - fi - - echo -e "\n[Estates] - DefaultEstateName = ${ESTATE_NAME:-Default Estate} - DefaultEstateOwnerName = ${ESTATE_OWNER_NAME:-Foo Bar} - DefaultEstateOwnerUUID = ${ESTATE_OWNER_UUID:-00000000-0000-0000-0000-000000000000} - DefaultEstateOwnerEMail = ${ESTATE_OWNER_EMAIL:-user@example.com} - DefaultEstateOwnerPassword = ${ESTATE_OWNER_PASSWORD:-password}" >> OpenSim.ini - - if [[ "${DATABASE_ENGINE}" == "mysql" ]]; then - echo -e "\n[Messaging] - StorageProvider = \"OpenSim.Data.MySQL.dll\" - ConectionString = \"Data Source=${MYSQL_SERVER:-db};Database=${MYSQL_DATABASE:-opensim};User ID=${MYSQL_USER:-root};Password=${MYSQL_PASSWORD};Old Guids=true;\"" >> OpenSim.ini - fi -else - echo >&2 "INFO: OpenSimulator general configuration found. Skipping..." -fi - -if [ ! -e config-include/StandaloneCommon.ini ] && [ ! -e config-include/GridCommon.ini ]; then - echo >&2 "INFO: No Grid Common configuration found, pulling one together." - cp defaults/StandaloneCommon.ini config-include/StandaloneCommon.ini - - echo "[DatabaseService]" >> config-include/StandaloneCommon.ini - if [[ "${DATABASE_ENGINE}" == "mysql" ]]; then - echo " StorageProvider = \"OpenSim.Data.MySQL.dll\"" >> config-include/StandaloneCommon.ini - echo " ConnectionString = \"Data Source=${MYSQL_SERVER:-db};Database=${MYSQL_DATABASE:-opensim};User ID=${MYSQL_USER:-root};Password=${MYSQL_PASSWORD};Old Guids=true;\"" >> config-include/StandaloneCommon.ini - else - echo " Include-Storage = \"config-include/storage/SQLiteStandalone.ini\"" >> config-include/StandaloneCommon.ini - fi - - echo "[GridService] - StorageProvider = \"OpenSim.Data.Null.dll:NullRegionData\" - Region_${REGION_NAME:-Region} = \"DefaultRegion, FallbackRegion\" - ExportSupported = true" >> config-include/StandaloneCommon.ini - - if [ -n "${GRID_WELCOME}" ]; then - sed -i -e "s/OpenSimulator is running!/${GRID_WELCOME}/g" config-include/StandaloneCommon.ini - fi - - if [ -n "${GRID_NAME}" ]; then - sed -i -e "s/OpenSimulator Instance/${GRID_NAME}/g" config-include/StandaloneCommon.ini - fi -else - echo >&2 "INFO: Standalone or Grid configuration found. Skipping..." -fi - -if [ `find Regions -maxdepth 1 -name '*.ini' | wc -l` -eq 0 ]; then - echo >&2 "INFO: No region details found, pulling one together." - - echo "[${REGION_NAME:-Region}] - RegionUUID = $(uuidgen) - Location = ${REGION_LOCATION:-1000,1000} - InternalAddress = 0.0.0.0 - InternalPort = 9000 - AllowAlternatePorts = False - ExternalHostName = ${REGION_EXTERNAL_HOSTNAME:-localhost}" >> Regions/Regions.ini -else - echo >&2 "INFO: Looks like there's region definitions. Skipping..." -fi - -if [ ! -e config-include/storage/SQLiteStandalone.ini ]; then - cp defaults/SQLiteStandalone.ini config-include/storage/SQLiteStandalone.ini - mkdir -p sqlite-database -fi - -exec "$@" diff --git a/build/latest/docker-entrypoint.sh b/build/latest/docker-entrypoint.sh index 3b213f7..9248fef 100755 --- a/build/latest/docker-entrypoint.sh +++ b/build/latest/docker-entrypoint.sh @@ -1,73 +1,65 @@ -#!/usr/bin/env bash -set -Eeo pipefail +#!/usr/bin/env sh +set -eu -chown -R $(id -u):$(id -g) defaults +chown -R "$(id -u):$(id -g)" defaults if [ ! -e OpenSim.ini ]; then - echo >&2 "INFO: No OpenSim configuration found, pulling one together." + printf '%s\n' "INFO: No OpenSim configuration found, pulling one together." >&2 cp defaults/OpenSim.ini OpenSim.ini - if [ -n "${PHYSICS_ENGINE}" ]; then - echo -e "\n[Startup] - physics = ${PHYSICS_ENGINE:-BulletSim}" >> OpenSim.ini + if [ -n "${PHYSICS_ENGINE:-}" ]; then + printf '\n[Startup]\nphysics = %s\n' "${PHYSICS_ENGINE:-BulletSim}" >> OpenSim.ini fi - echo -e "\n[Estates] - DefaultEstateName = ${ESTATE_NAME:-Default Estate} - DefaultEstateOwnerName = ${ESTATE_OWNER_NAME:-Foo Bar} - DefaultEstateOwnerUUID = ${ESTATE_OWNER_UUID:-00000000-0000-0000-0000-000000000000} - DefaultEstateOwnerEMail = ${ESTATE_OWNER_EMAIL:-user@example.com} - DefaultEstateOwnerPassword = ${ESTATE_OWNER_PASSWORD:-password}" >> OpenSim.ini + printf '\n[Estates]\n DefaultEstateName = %s\n DefaultEstateOwnerName = %s\n DefaultEstateOwnerUUID = %s\n DefaultEstateOwnerEMail = %s\n DefaultEstateOwnerPassword = %s\n' \ + "${ESTATE_NAME:-Default Estate}" \ + "${ESTATE_OWNER_NAME:-Foo Bar}" \ + "${ESTATE_OWNER_UUID:-00000000-0000-0000-0000-000000000000}" \ + "${ESTATE_OWNER_EMAIL:-user@example.com}" \ + "${ESTATE_OWNER_PASSWORD:-password}" >> OpenSim.ini - if [[ "${DATABASE_ENGINE}" == "mysql" ]]; then - echo -e "\n[Messaging] - StorageProvider = \"OpenSim.Data.MySQL.dll\" - ConectionString = \"Data Source=${MYSQL_SERVER:-db};Database=${MYSQL_DATABASE:-opensim};User ID=${MYSQL_USER:-root};Password=${MYSQL_PASSWORD};Old Guids=true;\"" >> OpenSim.ini + if [ "${DATABASE_ENGINE:-}" = "mysql" ]; then + printf '\n[Messaging]\n StorageProvider = "OpenSim.Data.MySQL.dll"\n ConectionString = "Data Source=%s;Database=%s;User ID=%s;Password=%s;Old Guids=true;"\n' \ + "${MYSQL_SERVER:-db}" "${MYSQL_DATABASE:-opensim}" "${MYSQL_USER:-root}" "${MYSQL_PASSWORD:-}" >> OpenSim.ini fi else - echo >&2 "INFO: OpenSimulator general configuration found. Skipping..." + printf '%s\n' "INFO: OpenSimulator general configuration found. Skipping..." >&2 fi if [ ! -e config-include/StandaloneCommon.ini ] && [ ! -e config-include/GridCommon.ini ]; then - echo >&2 "INFO: No Grid Common configuration found, pulling one together." + printf '%s\n' "INFO: No Grid Common configuration found, pulling one together." >&2 cp defaults/StandaloneCommon.ini config-include/StandaloneCommon.ini - echo "[DatabaseService]" >> config-include/StandaloneCommon.ini - if [[ "${DATABASE_ENGINE}" == "mysql" ]]; then - echo " StorageProvider = \"OpenSim.Data.MySQL.dll\"" >> config-include/StandaloneCommon.ini - echo " ConnectionString = \"Data Source=${MYSQL_SERVER:-db};Database=${MYSQL_DATABASE:-opensim};User ID=${MYSQL_USER:-root};Password=${MYSQL_PASSWORD};Old Guids=true;\"" >> config-include/StandaloneCommon.ini + printf '[DatabaseService]\n' >> config-include/StandaloneCommon.ini + if [ "${DATABASE_ENGINE:-}" = "mysql" ]; then + printf ' StorageProvider = "OpenSim.Data.MySQL.dll"\n' >> config-include/StandaloneCommon.ini + printf ' ConnectionString = "Data Source=%s;Database=%s;User ID=%s;Password=%s;Old Guids=true;"\n' \ + "${MYSQL_SERVER:-db}" "${MYSQL_DATABASE:-opensim}" "${MYSQL_USER:-root}" "${MYSQL_PASSWORD:-}" >> config-include/StandaloneCommon.ini else - echo " Include-Storage = \"config-include/storage/SQLiteStandalone.ini\"" >> config-include/StandaloneCommon.ini + printf ' Include-Storage = "config-include/storage/SQLiteStandalone.ini"\n' >> config-include/StandaloneCommon.ini fi - echo "[GridService] - StorageProvider = \"OpenSim.Data.Null.dll:NullRegionData\" - Region_${REGION_NAME:-Region} = \"DefaultRegion, FallbackRegion\" - ExportSupported = true" >> config-include/StandaloneCommon.ini + printf '\n[GridService]\n StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"\n Region_%s = "DefaultRegion, FallbackRegion"\n ExportSupported = true\n' "${REGION_NAME:-Region}" >> config-include/StandaloneCommon.ini - if [ -n "${GRID_WELCOME}" ]; then + if [ -n "${GRID_WELCOME:-}" ]; then sed -i -e "s/OpenSimulator is running!/${GRID_WELCOME}/g" config-include/StandaloneCommon.ini fi - if [ -n "${GRID_NAME}" ]; then + if [ -n "${GRID_NAME:-}" ]; then sed -i -e "s/OpenSimulator Instance/${GRID_NAME}/g" config-include/StandaloneCommon.ini fi else - echo >&2 "INFO: Standalone or Grid configuration found. Skipping..." + printf '%s\n' "INFO: Standalone or Grid configuration found. Skipping..." >&2 fi -if [ `find Regions -maxdepth 1 -name '*.ini' | wc -l` -eq 0 ]; then - echo >&2 "INFO: No region details found, pulling one together." +count="$(find Regions -maxdepth 1 -name '*.ini' 2>/dev/null | wc -l)" +if [ "${count}" -eq 0 ]; then + printf '%s\n' "INFO: No region details found, pulling one together." >&2 - echo "[${REGION_NAME:-Region}] - RegionUUID = $(uuidgen) - Location = ${REGION_LOCATION:-1000,1000} - InternalAddress = 0.0.0.0 - InternalPort = 9000 - AllowAlternatePorts = False - ExternalHostName = ${REGION_EXTERNAL_HOSTNAME:-localhost}" >> Regions/Regions.ini + printf '\n[%s]\n\tRegionUUID = %s\n\tLocation = %s\n\tInternalAddress = 0.0.0.0\n InternalPort = 9000\n AllowAlternatePorts = False\n ExternalHostName = %s\n' \ + "${REGION_NAME:-Region}" "$(uuidgen)" "${REGION_LOCATION:-1000,1000}" "${REGION_EXTERNAL_HOSTNAME:-localhost}" >> Regions/Regions.ini else - echo >&2 "INFO: Looks like there's region definitions. Skipping..." + printf '%s\n' "INFO: Looks like there's region definitions. Skipping..." >&2 fi if [ ! -e config-include/storage/SQLiteStandalone.ini ]; then