fix: Ensure Steam credentials are used for downloads
This commit is contained in:
parent
0b76ab9022
commit
f00af75333
2 changed files with 32 additions and 26 deletions
15
compose.yaml
15
compose.yaml
|
|
@ -5,18 +5,13 @@ services:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: scp-sl-server
|
container_name: scp-sl-server
|
||||||
ports:
|
ports:
|
||||||
- "7777:7777/udp"
|
- 7777:7777/udp
|
||||||
volumes:
|
volumes:
|
||||||
- ./config:/home/steam/.config
|
- /home/oliwier/dockerData/scpsl/config:/home/steam/.config
|
||||||
environment:
|
environment:
|
||||||
- UID=1000
|
- UID=1000
|
||||||
- GID=1000
|
- GID=1000
|
||||||
# To set a timezone, uncomment the next line and change Etc/UTC to a TZ identifier from this [list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List).
|
- STEAM_USER=thestopa
|
||||||
# - TZ=Etc/UTC
|
- STEAM_PASSWORD=${ST_PASSWORD}
|
||||||
# To download a specific version of the server, uncomment the next line and set the value to a valid manifest ID.
|
|
||||||
# - MANIFEST_ID=none
|
|
||||||
# If you need to use your own Steam credentials, uncomment and set the following variables.
|
|
||||||
# - STEAM_USER=your_steam_username
|
|
||||||
# - STEAM_PASSWORD=your_steam_password
|
|
||||||
# - STEAM_GUARD_CODE=your_2fa_code
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
networks: {}
|
||||||
|
|
|
||||||
43
start.sh
43
start.sh
|
|
@ -3,16 +3,27 @@ set -e
|
||||||
|
|
||||||
echo "Current user is: $(whoami)"
|
echo "Current user is: $(whoami)"
|
||||||
|
|
||||||
# Install/update SCP:SL server
|
# Construct the SteamCMD login arguments.
|
||||||
if [ "$MANIFEST_ID" = "none" ]; then
|
# We build a string that will be evaluated by the shell to handle credentials correctly.
|
||||||
echo "MANIFEST_ID not set, downloading latest server version..."
|
if [ -z "$STEAM_USER" ] || [ "$STEAM_USER" = "anonymous" ]; then
|
||||||
steamcmd +force_install_dir $SERVER_DIR +login "$STEAM_USER" "$STEAM_PASSWORD" "$STEAM_GUARD_CODE" +app_update 996560 validate +quit
|
echo "Using anonymous Steam login."
|
||||||
|
LOGIN_ARGS="anonymous"
|
||||||
else
|
else
|
||||||
echo "MANIFEST_ID set to $MANIFEST_ID, downloading specific server version..."
|
echo "Using Steam credentials for user '$STEAM_USER'."
|
||||||
# download_depot downloads to a specific folder, not the one specified by force_install_dir
|
# Quoting the variables ensures that empty passwords or special characters are handled correctly.
|
||||||
# It will be downloaded to <install_dir>/steamapps/content/app_<id>/depot_<id>
|
LOGIN_ARGS="\"$STEAM_USER\" \"$STEAM_PASSWORD\" \"$STEAM_GUARD_CODE\""
|
||||||
steamcmd +login "$STEAM_USER" "$STEAM_PASSWORD" "$STEAM_GUARD_CODE" +download_depot 996560 $DEPOT_ID $MANIFEST_ID +quit
|
fi
|
||||||
|
|
||||||
|
# The 'eval' command is used here to correctly parse the quoted LOGIN_ARGS string.
|
||||||
|
# This is a safe use of eval because the variables are controlled by the user running the container.
|
||||||
|
if [ -z "$MANIFEST_ID" ] || [ "$MANIFEST_ID" = "none" ]; then
|
||||||
|
echo "MANIFEST_ID is not set. Downloading the latest stable version of the server..."
|
||||||
|
eval steamcmd +force_install_dir "$SERVER_DIR" +login $LOGIN_ARGS +app_update 996560 validate +quit
|
||||||
|
else
|
||||||
|
echo "MANIFEST_ID is set to $MANIFEST_ID. Downloading specific server version..."
|
||||||
|
eval steamcmd +login $LOGIN_ARGS +download_depot 996560 "$DEPOT_ID" "$MANIFEST_ID" +quit
|
||||||
|
|
||||||
|
# download_depot downloads to a specific folder, not the one specified by force_install_dir
|
||||||
DEPOT_DOWNLOAD_DIR="$INSTALL_DIR/steamapps/content/app_996560/depot_$DEPOT_ID"
|
DEPOT_DOWNLOAD_DIR="$INSTALL_DIR/steamapps/content/app_996560/depot_$DEPOT_ID"
|
||||||
|
|
||||||
if [ -d "$DEPOT_DOWNLOAD_DIR" ] && [ "$(ls -A "$DEPOT_DOWNLOAD_DIR")" ]; then
|
if [ -d "$DEPOT_DOWNLOAD_DIR" ] && [ "$(ls -A "$DEPOT_DOWNLOAD_DIR")" ]; then
|
||||||
|
|
@ -23,29 +34,29 @@ else
|
||||||
echo "Successfully copied files."
|
echo "Successfully copied files."
|
||||||
else
|
else
|
||||||
echo "Error: Depot download failed or the directory is empty." >&2
|
echo "Error: Depot download failed or the directory is empty." >&2
|
||||||
echo "Please check MANIFEST_ID ($MANIFEST_ID) and DEPOT_ID ($DEPOT_ID)" >&2
|
echo "Please check MANIFEST_ID ($MANIFEST_ID) and DEPOT_ID ($DEPOT_ID), and ensure credentials are correct." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure config directory exists
|
# Ensure config directory exists for server settings
|
||||||
INTERNAL_CONFIG_SUBDIR="$CONFIG_DIR/SCP Secret Laboratory/config/"
|
INTERNAL_CONFIG_SUBDIR="$CONFIG_DIR/SCP Secret Laboratory/config/"
|
||||||
mkdir -p "$INTERNAL_CONFIG_SUBDIR"
|
mkdir -p "$INTERNAL_CONFIG_SUBDIR"
|
||||||
|
|
||||||
# Process the internal data template to accept EULA
|
# Process the internal data template to accept the EULA, which is required on first run
|
||||||
INTERNAL_DATA_TEMPLATE_FILE="$CONFIG_TEMPLATES_DIR/localadmin_internal_data.json.template"
|
INTERNAL_DATA_TEMPLATE_FILE="$CONFIG_TEMPLATES_DIR/localadmin_internal_data.json.template"
|
||||||
INTERNAL_DATA_FILE="$INTERNAL_CONFIG_SUBDIR/localadmin_internal_data.json"
|
INTERNAL_DATA_FILE="$INTERNAL_CONFIG_SUBDIR/localadmin_internal_data.json"
|
||||||
if [ ! -f "$INTERNAL_DATA_FILE" ]; then
|
if [ ! -f "$INTERNAL_DATA_FILE" ]; then
|
||||||
echo "Creating \`localadmin_internal_data.json\` file with EULA acceptance..."
|
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")
|
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"
|
sed "s/\${EulaDateAccepted}/$CURRENT_DATE/g" "$INTERNAL_DATA_TEMPLATE_FILE" > "$INTERNAL_DATA_FILE"
|
||||||
chmod 644 "$INTERNAL_DATA_FILE"
|
chmod 644 "$INTERNAL_DATA_FILE"
|
||||||
echo "Successfully created \`localadmin_internal_data.json\` file with EULA acceptance."
|
echo "Successfully created \`localadmin_internal_data.json\` file."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run server
|
echo "Starting SCP: Secret Laboratory server on port $PORT..."
|
||||||
cd $SERVER_DIR && HOME=$INSTALL_DIR ./LocalAdmin $PORT
|
# Change to the server directory and execute the server binary
|
||||||
|
cd "$SERVER_DIR" && HOME="$INSTALL_DIR" ./LocalAdmin "$PORT"
|
||||||
|
|
||||||
|
# Fallback to keep the container alive if the server process exits
|
||||||
sleep infinity
|
sleep infinity
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue