scp-secret-laboratory-serve.../start.sh

51 lines
2.2 KiB
Bash

#!/bin/sh
set -e
echo "Current user is: $(whoami)"
# Install/update SCP:SL server
if [ "$MANIFEST_ID" = "none" ]; then
echo "MANIFEST_ID not set, downloading latest server version..."
steamcmd +force_install_dir $SERVER_DIR +login anonymous +app_update 996560 validate +quit
else
echo "MANIFEST_ID set to $MANIFEST_ID, downloading specific server version..."
# download_depot downloads to a specific folder, not the one specified by force_install_dir
# It will be downloaded to <install_dir>/steamapps/content/app_<id>/depot_<id>
steamcmd +login anonymous +download_depot 996560 $DEPOT_ID $MANIFEST_ID +quit
DEPOT_DOWNLOAD_DIR="$INSTALL_DIR/steamapps/content/app_996560/depot_$DEPOT_ID"
if [ -d "$DEPOT_DOWNLOAD_DIR" ] && [ "$(ls -A "$DEPOT_DOWNLOAD_DIR")" ]; then
echo "Depot downloaded successfully. Clearing server directory..."
find "$SERVER_DIR" -mindepth 1 -delete
echo "Copying downloaded files from $DEPOT_DOWNLOAD_DIR to $SERVER_DIR"
cp -rT "$DEPOT_DOWNLOAD_DIR" "$SERVER_DIR"
echo "Successfully copied files."
else
echo "Error: Depot download failed or the directory is empty." >&2
echo "Please check MANIFEST_ID ($MANIFEST_ID) and DEPOT_ID ($DEPOT_ID)" >&2
exit 1
fi
fi
# Ensure config directory exists
INTERNAL_CONFIG_SUBDIR="$CONFIG_DIR/SCP Secret Laboratory/config/"
mkdir -p "$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
cd $SERVER_DIR && HOME=$INSTALL_DIR ./LocalAdmin $PORT
sleep infinity