arma3-docker/entrypoint.sh

97 lines
2.3 KiB
Bash
Raw Permalink Normal View History

2022-08-27 12:24:17 +00:00
#!/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"
2022-08-29 11:53:17 +00:00
if [ -n "$LIMIT_FPS" ]; then
SERVER_ARGS="${SERVER_ARGS} -limitFPS=${LIMIT_FPS}"
2022-08-27 12:24:17 +00:00
fi
2022-08-29 11:53:17 +00:00
if [ -n "$PORT" ]; then
SERVER_ARGS="${SERVER_ARGS} -port=${PORT}"
2022-08-27 12:24:17 +00:00
fi
#
# PREAPRE MODS
#
2022-08-28 12:46:41 +00:00
MOD_LINK_DIR="/home/steam/server/mods"
2022-08-27 12:24:17 +00:00
mkdir -p "$MOD_LINK_DIR"
rm -f "$MOD_LINK_DIR"/*
MODS_TO_LOAD=""
2022-09-15 11:28:44 +00:00
MOD_EXCLUDE=${MOD_EXCLUDE:=""}
2022-08-27 12:24:17 +00:00
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
2022-09-15 11:28:44 +00:00
# Check if mod is excluded
2022-09-15 11:34:56 +00:00
if [[ "$MOD_EXCLUDE" != *"$mod_id"* ]]; then
2022-09-15 11:28:44 +00:00
# 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}mods/${mod_id};"
fi
2022-08-27 12:24:17 +00:00
done
if [ -n "$MODS_TO_LOAD" ]; then
2022-08-28 12:46:41 +00:00
SERVER_ARGS="${SERVER_ARGS} -mod=${MODS_TO_LOAD::-1}"
2022-08-27 12:24:17 +00:00
fi
2022-08-30 14:05:20 +00:00
#
# LINK MISSIONS
#
2022-09-05 16:00:37 +00:00
# rm -r /home/steam/server/mpmissions
# ln -s "$VOLUME_HOME/missions" "/home/steam/server/mpmissions"
2022-08-27 12:24:17 +00:00
# SERVER_ARGS="${SERVER_ARGS} -serverMod=${SERVER_MODS}"
#
# RUN GAME
#
echo "Starting server with args: "
echo "$SERVER_ARGS"
# Start the server
echo "Starting the server..."
2022-08-28 12:46:41 +00:00
/home/steam/server/arma3server_x64 ${SERVER_ARGS}