88 lines
2.1 KiB
Bash
Executable File
88 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eo pipefail
|
|
|
|
VOLUME_HOME="/home/steam/volumes"
|
|
|
|
#
|
|
# STEAM/INSTALL GAME
|
|
#
|
|
|
|
# If STEAM_USER or STEAM_PASSWORD is not set
|
|
if [ -z "$STEAM_USER" ] || [ -z "$STEAM_PASSWORD" ]; then
|
|
echo "STEAM_USER or STEAM_PASSWORD is not set. Its recommended to create a new steam user for the server."
|
|
exit 1
|
|
fi
|
|
|
|
# Update or install Arma 3
|
|
echo "Updating or installing Arma 3..."
|
|
|
|
# https://developer.valvesoftware.com/wiki/SteamCMD
|
|
/home/steam/steamcmd/steamcmd.sh +force_install_dir /home/steam/server +login "$STEAM_USER" "$STEAM_PASSWORD" +app_update 233780 +quit
|
|
|
|
#
|
|
# PREPARE GAME
|
|
#
|
|
|
|
# Check if config file exists
|
|
if [ ! -f "$VOLUME_HOME/config/config.cfg" ]; then
|
|
echo "Config file not found, creating..."
|
|
# TODO: Create config file
|
|
touch "$VOLUME_HOME/config/config.cfg"
|
|
fi
|
|
|
|
# https://community.bistudio.com/wiki/Arma_3:_Startup_Parameters#Server_Options
|
|
SERVER_ARGS="-name server -config=$VOLUME_HOME/config/config.cfg -profiles=$VOLUME_HOME/config/profiles"
|
|
|
|
if [ -n "$A3_LIMIT_FPS" ]; then
|
|
SERVER_ARGS="${SERVER_ARGS} -limitFPS=${A3_LIMIT_FPS}"
|
|
fi
|
|
|
|
if [ -n "$A3_PORT" ]; then
|
|
SERVER_ARGS="${SERVER_ARGS} -port=${A3_PORT}"
|
|
fi
|
|
|
|
#
|
|
# PREAPRE MODS
|
|
#
|
|
|
|
MOD_LINK_DIR="/tmp/arma3mods"
|
|
mkdir -p "$MOD_LINK_DIR"
|
|
rm -f "$MOD_LINK_DIR"/*
|
|
|
|
MODS_TO_LOAD=""
|
|
|
|
for mod_id in $(curl -s "https://steamcommunity.com/sharedfiles/filedetails/?id=$WORKSHOP_COLLECTION" | grep -E 'id="sharedfile_[0-9]+"' | sed 's/.*id="sharedfile_\([0-9]\+\)".*/\1/')
|
|
do
|
|
# Check if directory exists
|
|
if [ ! -d "$VOLUME_HOME/mods/$mod_id" ]; then
|
|
echo "Could not find mod directory for $mod_id"
|
|
echo "Try to download it first"
|
|
exit 1
|
|
fi
|
|
|
|
ln -s "$VOLUME_HOME/mods/$mod_id" "$MOD_LINK_DIR/$mod_id"
|
|
MODS_TO_LOAD="${MODS_TO_LOAD}$MOD_LINK_DIR/${mod_id};"
|
|
done
|
|
|
|
# MODS_TO_LOAD="$VOLUME_HOME/mods/463939057"
|
|
|
|
if [ -n "$MODS_TO_LOAD" ]; then
|
|
SERVER_ARGS="${SERVER_ARGS} -mod=${MODS_TO_LOAD}"
|
|
fi
|
|
|
|
|
|
# SERVER_ARGS="${SERVER_ARGS} -serverMod=${SERVER_MODS}"
|
|
|
|
#
|
|
# RUN GAME
|
|
#
|
|
|
|
|
|
echo "Starting server with args: "
|
|
echo "$SERVER_ARGS"
|
|
|
|
# Start the server
|
|
echo "Starting the server..."
|
|
/home/steam/server/arma3server ${SERVER_ARGS}
|