Files
swg-server-docker/entrypoint.sh
2025-07-21 12:39:53 -05:00

68 lines
1.9 KiB
Bash

#!/bin/sh
# entrypoint.sh
# Get the container's own IP address at runtime
CONTAINER_IP=$(hostname -i)
# Define the path to the configuration file
CONFIG_FILE="/swg-main/exe/linux/servercommon.cfg"
# Define unique markers for the beginning and end of our configuration block
START_MARKER="# BEGIN DOCKER-MANAGED CONFIG"
END_MARKER="# END DOCKER-MANAGED CONFIG"
# 1. Remove the entire block from the start marker to the end marker.
# The -i flag modifies the file in-place.
# On the first run, this command will do nothing if the markers don't exist, which is fine.
sed -i "/${START_MARKER}/,/${END_MARKER}/d" ${CONFIG_FILE}
# 2. Now, append the new, updated configuration block, including the markers.
cat <<EOF >> ${CONFIG_FILE}
${START_MARKER}
# This block is automatically managed by the container's entrypoint script.
# Do not edit it manually, as changes will be overwritten on container restart.
[dbProcess]
DSN=//oracle/FREEPDB1
databaseUID=DBUSERNAME
centralServerAddress=${CONTAINER_IP}
[LoginServer]
DSN=//oracle/FREEPDB1
databaseUID=DBUSERNAME
developmentMode=true
useExternalAuth=false
[CentralServer]
developmentMode=true
[ChatServer]
centralServerAddress=${CONTAINER_IP}
[GameServer]
centralServerAddress=${CONTAINER_IP}
adminGodToAll=1
adminGodToAllGodLevel=50
debugMode=1
[TaskManager]
loginServerAddress=${CONTAINER_IP}
node0=${CONTAINER_IP}
environmentVariable=PATH+=/usr/lib/jvm/java-11-openjdk-i386/bin:./
environmentVariable=LD_LIBRARY_PATH+=/usr/lib/jvm/java-11-openjdk-i386/lib:/usr/lib/jvm/java-11-openjdk-i386/lib/server:./
${END_MARKER}
EOF
# Change to the /swg-main directory and run 'ant update_configs'
cd /swg-main
ant update_configs
# Update the cluster_list to use the local host IP address for connections.
/usr/lib/oracle/18.3/client/bin/sqlplus -S ${DB_USER}/${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/FREEPDB1 <<EOT
UPDATE CLUSTER_LIST SET ADDRESS = '127.0.0.1';
COMMIT;
EOT
# This command executes the original CMD from the Dockerfile
exec "$@"