#!/bin/sh # # shellcheck disable=1090,2034,2011 # --------------------------------------------------- # =================================================== # 01. Attempt to load global DayZ values # =================================================== echo "Starting, attempting to load globals.sh" GLOBALS_FILE="$PWD/globals.sh" if [ -e "$GLOBALS_FILE" ] ; then chmod +x "$GLOBALS_FILE" . "$GLOBALS_FILE" else die "Could not load: $GLOBALS_FILE" fi # =================================================== # 02. Local script variables # =================================================== export STEAMCMD_USER=steam export MODLISTS="$PWD/modlists" export LOCAL_STOCK="$HOME/stock/DayZ" export LOCAL_STOCK_GAME="$LOCAL_STOCK/DayZ" export LOCAL_STOCK_SERVER="$LOCAL_STOCK/DayZServer" # =================================================== # 03. Mount network drive # =================================================== if ! is_network_drive_mounted ; then mount_dayz_network_drive if ! is_network_drive_mounted ; then die "Could not mount network drive" fi fi # =================================================== # 04. Checks # =================================================== mkdir -p "$LOCAL_STOCK_GAME" "$LOCAL_STOCK_SERVER" if [ "$USER" != "$STEAMCMD_USER" ] ; then die "Current user: '$USER' does not match '$STEAMCMD_USER'" fi if [ ! -d "$MODLISTS" ] ; then die "Could not find modlists at: $MODLISTS" fi if [ ! -d "$REMOTE_MODS" ] ; then die "Could not find remote mods at: $REMOTE_MODS" fi if [ ! -d "$REMOTE_MAPS" ] ; then die "Could not find remote maps at: $REMOTE_MAPS" fi # =================================================== # 05. Begin functions # =================================================== update_server() { msg "-------- UPDATING DAYZ SERVER -------------------" steamcmd -tcp \ +force_install_dir "$LOCAL_STOCK_SERVER" \ +@sSteamCmdForcePlatformType windows \ +@ShutdownOnFailedCommand 1 \ +login "$STEAM_USER" \ +app_update "$DAYZ_SERVER_ID" \ +quit is_network_drive_mounted && do_sync "$LOCAL_STOCK_SERVER"/ "$REMOTE_STOCK_SERVER" msg "-------- DONE UPDATING SERVER -------------------" } update_game() { msg "-------- UPDATING DAYZ GAME -------------------" steamcmd -tcp \ +force_install_dir "$LOCAL_STOCK_GAME" \ +@sSteamCmdForcePlatformType windows \ +@ShutdownOnFailedCommand 1 \ +login "$STEAM_USER" \ +app_update "$DAYZ_GAME_ID" \ +quit is_network_drive_mounted && do_sync "$LOCAL_STOCK_GAME"/ "$REMOTE_STOCK_GAME" msg "-------- DONE UPDATING GAME -------------------" } # args: $1 = server_modlist.txt to update update_mods_for_server() { MODS_FILE="$MODLISTS/$1" REMOTE_MODS_DIR="$REMOTE_MODS_DIR/${1%.txt}" mkdir -p "$REMOTE_MODS_DIR/${1%.txt}" # Create temporary file to list all the mod_id's we are # going to download. This speeds up steamcmd and avoids rate limits. tempfile=/tmp/mods-to-download.txt :> "$tempfile" # load the server_modlist.txt, copying the mod id's we need to update # to the temp file, while skipping comments and blank lines # # format should be: "mod_id^nickname" # # # Dabs Framework # # https://steamcommunity.com/sharedfiles/filedetails/?id=2545327648 # 2545327648^dabsframework # while read -r mod ; do case "$mod" in \#*|'') ;; *) mod=${mod%%^*} if [ -z "$mod" ] ; then die "mod for $server appears to be empty - syntax error" fi printf "+workshop_download_item $DAYZ_GAME_ID %s\n" "$mod" >> "$tempfile" mkdir -p "$LOCAL_MODS_DIR/$mod" esac done < "$MODS_FILE" rm "$tempfile" 2>/dev/null ||: unset tempfile mod } main() { update_server update_game for server in $(ls "$MODLISTS" | xargs) ; do [ -f "$server" ] || continue update_mods_for_server "$server" unset server # rm -rf "$HOME/.steam/debian-installation/steamapps/workshop/downloads" # mkdir -p "$HOME/.steam/debian-installation/steamapps/workshop/downloads" done } main "$@"