From 3b60e70d888d6a7908053f5f0521aceed024a8fe Mon Sep 17 00:00:00 2001 From: Matthew Green Date: Tue, 8 Apr 2025 16:34:53 -0500 Subject: [PATCH] Swapped to a template for file where you agree to EULA. Server now runs. --- Dockerfile | 10 ++++++--- .../config_gameplay.txt | 0 .../config_localadmin_global.txt | 0 .../config_remoteadmin.txt | 0 .../localadmin_internal_data.json | 0 .../localadmin_internal_data.json.template | 1 + start.sh | 21 +++++++++++++++---- 7 files changed, 25 insertions(+), 7 deletions(-) rename {config => config-examples}/config_gameplay.txt (100%) rename {config => config-examples}/config_localadmin_global.txt (100%) rename {config => config-examples}/config_remoteadmin.txt (100%) rename {config => config-examples}/localadmin_internal_data.json (100%) create mode 100644 config-templates/localadmin_internal_data.json.template diff --git a/Dockerfile b/Dockerfile index c87caad..2c0b87d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,9 @@ ENV STEAM_DIR=/usr/lib/games/steam ENV INSTALL_DIR=/home/steam ENV SERVER_DIR=$INSTALL_DIR/server ENV CONFIG_DIR=$INSTALL_DIR/.config +ENV CONFIG_TEMPLATES_DIR=$INSTALL_DIR/.config-templates -RUN mkdir -p ${INSTALL_DIR} ${SERVER_DIR} ${CONFIG_DIR} +RUN mkdir -p ${INSTALL_DIR} ${SERVER_DIR} ${CONFIG_DIR} ${CONFIG_TEMPLATES_DIR} RUN apt-get update && \ apt-get install -y libicu-dev @@ -24,14 +25,17 @@ RUN apt-get update && \ # Create steam user and group RUN groupadd --gid $GID steam && \ useradd --create-home -c 'Steam User' -l --uid $UID --gid $GID --home-dir $INSTALL_DIR steam && \ - chown -R steam:steam ${INSTALL_DIR} ${SERVER_DIR} ${CONFIG_DIR} && \ - chmod 777 ${INSTALL_DIR} ${SERVER_DIR} ${CONFIG_DIR} + chown -R steam:steam ${INSTALL_DIR} ${SERVER_DIR} ${CONFIG_DIR} ${CONFIG_TEMPLATES_DIR} && \ + chmod 777 ${INSTALL_DIR} ${SERVER_DIR} ${CONFIG_DIR} ${CONFIG_TEMPLATES_DIR} # Copy and prepare start script COPY start.sh $INSTALL_DIR/start.sh RUN chmod +x ${INSTALL_DIR}/start.sh && \ chown -R steam:steam ${INSTALL_DIR}/start.sh +# Copy configuration template files +COPY config-templates/ ${CONFIG_TEMPLATES_DIR} + # Switch to steam user USER steam WORKDIR $INSTALL_DIR diff --git a/config/config_gameplay.txt b/config-examples/config_gameplay.txt similarity index 100% rename from config/config_gameplay.txt rename to config-examples/config_gameplay.txt diff --git a/config/config_localadmin_global.txt b/config-examples/config_localadmin_global.txt similarity index 100% rename from config/config_localadmin_global.txt rename to config-examples/config_localadmin_global.txt diff --git a/config/config_remoteadmin.txt b/config-examples/config_remoteadmin.txt similarity index 100% rename from config/config_remoteadmin.txt rename to config-examples/config_remoteadmin.txt diff --git a/config/localadmin_internal_data.json b/config-examples/localadmin_internal_data.json similarity index 100% rename from config/localadmin_internal_data.json rename to config-examples/localadmin_internal_data.json diff --git a/config-templates/localadmin_internal_data.json.template b/config-templates/localadmin_internal_data.json.template new file mode 100644 index 0000000..b642b52 --- /dev/null +++ b/config-templates/localadmin_internal_data.json.template @@ -0,0 +1 @@ +{"GitHubPersonalAccessToken":null,"EulaAccepted":"${EulaDateAccepted}","PluginManagerWarningDismissed":false,"LastPluginAliasesRefresh":null,"PluginVersionCache":{},"PluginAliases":{}} \ No newline at end of file diff --git a/start.sh b/start.sh index a17768f..a9449f0 100644 --- a/start.sh +++ b/start.sh @@ -5,11 +5,24 @@ echo "Current user is: $(whoami)" steamcmd +force_install_dir $SERVER_DIR +login anonymous +app_update 996560 validate +quit # # Ensure config directory exists -CONFIGS="$INSTALL_DIR/.config/SCP Secret Laboratory/config/" -mkdir -p "$CONFIGS" -chmod 755 "$CONFIGS" +INTERNAL_CONFIG_SUBDIR="$CONFIG_DIR/SCP Secret Laboratory/config/" +mkdir -p "$INTERNAL_CONFIG_SUBDIR" +chmod 755 "$INTERNAL_CONFIG_SUBDIR" + +# Process the internal data template to accept EULA +INTERNAL_DATA_TEMPLATE_FILE="$CONFIG_TEMPLATES_DIR/localadmin_internal_data.json.template" +INTERNAL_DATA_FILE="$INTERNAL_CONFIG_SUBDIR/localadmin_internal_data.json" +if [ ! -f "$INTERNAL_DATA_FILE" ]; then + echo "Creating \`localadmin_internal_data.json\` file with EULA acceptance..." + # Get current date in the correct format + CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%S.%7NZ") + # Replace placeholder in template + sed "s/\${EulaDateAccepted}/$CURRENT_DATE/g" "$INTERNAL_DATA_TEMPLATE_FILE" > "$INTERNAL_DATA_FILE" + chmod 644 "$INTERNAL_DATA_FILE" + echo "Successfully created \`localadmin_internal_data.json\` file with EULA acceptance." +fi # Run server directly (no need to su) -cd $SERVER_DIR && HOME=$INSTALL_DIR ./LocalAdmin $PORT --help #--config "$CONFIGS" +cd $SERVER_DIR && HOME=$INSTALL_DIR ./LocalAdmin $PORT sleep infinity \ No newline at end of file