diff --git a/modserver/globals.sh b/modserver/globals.sh index a7f0ee1..d731057 100644 --- a/modserver/globals.sh +++ b/modserver/globals.sh @@ -29,6 +29,10 @@ msg() { errmsg() { >&2 printf '[Error]: %s\n' "$*" } +die() { + errmsg "$*" + exit 1 +} mount_dayz_network_drive() { if ! is_network_drive_mounted ; then sudo mkdir -p /mnt/dayz diff --git a/modserver/modlists/chernarus.txt b/modserver/modlists/chernarus.txt new file mode 100644 index 0000000..530d883 --- /dev/null +++ b/modserver/modlists/chernarus.txt @@ -0,0 +1,9 @@ +# ================================================================== +# Generic / All Servers +# ================================================================== + +# Dabs Framework +# https://steamcommunity.com/sharedfiles/filedetails/?id=2545327648 +2545327648^dabsframework + + diff --git a/modserver/old/update.sh b/modserver/old/update.sh index 790f374..8bdb1c1 100644 --- a/modserver/old/update.sh +++ b/modserver/old/update.sh @@ -10,28 +10,28 @@ # alias do_sync='rsync -rvltDhu --delete --partial --progress' # msg() { -# printf '[*] %s\n' "$*" +# printf '[*] %s\n' "$*" # } # ==================================================================================== -update_server() { - msg "------------------ UPDATING DAYZ SERVER -------------------" +# update_server() { +# msg "------------------ UPDATING DAYZ SERVER -------------------" - LOCAL_INSTALL_DIR="${HOME}/.steam/debian-installation/steamapps/common/DayZServer" - REMOTE_INSTALL_DIR="/mnt/dayz/stock/DayZServer" +# LOCAL_INSTALL_DIR="${HOME}/.steam/debian-installation/steamapps/common/DayZServer" +# REMOTE_INSTALL_DIR="/mnt/dayz/stock/DayZServer" - steamcmd -tcp +login "$STEAM_USER" +app_update "$DAYZ_GAME_ID" +quit - steamcmd -tcp +login "$STEAM_USER" +app_update "$DAYZ_SERVER_ID" +quit +# steamcmd -tcp +login "$STEAM_USER" +app_update "$DAYZ_GAME_ID" +quit +# steamcmd -tcp +login "$STEAM_USER" +app_update "$DAYZ_SERVER_ID" +quit - do_sync "$LOCAL_INSTALL_DIR"/ "$REMOTE_INSTALL_DIR" - msg "------- DONE UPDATING SERVER ---------------------" -} +# do_sync "$LOCAL_INSTALL_DIR"/ "$REMOTE_INSTALL_DIR" +# msg "------- DONE UPDATING SERVER ---------------------" +# } # args: $1=server_name update_mods() { - MODS_FILE="$HOME/modlists/$1.txt" - REMOTE_MODS_DIR="/mnt/dayz/mods/$1" + MODS_FILE="$HOME/modlists/$1" + REMOTE_MODS_DIR="/mnt/dayz/mods/${1%.txt}" mkdir -p "$REMOTE_MODS_DIR" tempfile=/tmp/mods-to-download.txt @@ -51,7 +51,6 @@ update_mods() { msg "----------- DOWNLOAD MODS -------------" steamcmd -tcp +login "$STEAM_USER" $(cat "$tempfile" | xargs) +quit || exit 1 - msg "----------- RENAMING MODS -------------" rm -rf "$HOME/mods_to_copy" 2>/dev/null ||: @@ -107,20 +106,17 @@ update_stock_maps() { do_sync "$LOCAL_MODS_DIR/$TAKISTAN_MOD_ID/Mission/$takistan"/ "$REMOTE_MAPS/$takistan" || \ die "failed to copy Takistan map files" fi - - - msg "NOTE: deer isle doesn't get automatic updates... Skipping" } -main () { - update_server - update_stock_maps +# main () { +# update_server +# update_stock_maps - for server in $(ls "$HOME/modlists" | xargs | sed 's/\.txt//g') ; do - rm -rf "$HOME/.steam/debian-installation/steamapps/workshop/downloads" - mkdir -p "$HOME/.steam/debian-installation/steamapps/workshop/downloads" - update_mods "$server" - done -} +# for server in $(ls "$HOME/modlists" | xargs | sed 's/\.txt//g') ; do +# rm -rf "$HOME/.steam/debian-installation/steamapps/workshop/downloads" +# mkdir -p "$HOME/.steam/debian-installation/steamapps/workshop/downloads" +# update_mods "$server" +# done +# } -main "$@" +# main "$@" diff --git a/modserver/update_mods.sh b/modserver/update_mods.sh index 28491b6..10a99a6 100644 --- a/modserver/update_mods.sh +++ b/modserver/update_mods.sh @@ -1,6 +1,7 @@ #!/bin/sh # -# shellcheck disable=1090,2034 +# shellcheck disable=1090,2034,2011 +# --------------------------------------------------- # =================================================== # 01. Attempt to load global DayZ values @@ -12,78 +13,133 @@ if [ -e "$GLOBALS_FILE" ] ; then chmod +x "$GLOBALS_FILE" . "$GLOBALS_FILE" else - >&2 echo "Could not load: $GLOBALS_FILE" - exit 1 + die "Could not load: $GLOBALS_FILE" fi # =================================================== -# 02. Local script variables and checks +# 02. Local script variables # =================================================== export STEAMCMD_USER=steam -export LOCAL_STOCK_GAME="$HOME/stock/DayZ" -export LOCAL_STOCK_SERVER="$HOME/stock/DayZServer" -mkdir -p "$LOCAL_STOCK_GAME" "$LOCAL_STOCK_SERVER" +export MODLISTS="$PWD/modlists" -if [ "$USER" != "$STEAMCMD_USER" ] ; then - errmsg "Current user: '$USER' does not match '$STEAMCMD_USER'" - exit 1 -fi +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 + mount_dayz_network_drive - if ! is_network_drive_mounted ; then - errmsg "Could not mount network drive" - exit 1 - fi + if ! is_network_drive_mounted ; then + die "Could not mount network drive" + fi fi # =================================================== -# 04. Begin functions +# 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 + 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 -------------------" - # LOCAL_INSTALL_DIR="${HOME}/.steam/debian-installation/steamapps/common/DayZServer" + 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 + 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 -------------------" + 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 + 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 "$@" - -##### GARBAGE BELOW -# LOCAL_MODS_DIR="$HOME/steam_data/steamapps/workshop/content/$DAYZ_GAME_ID" -# LOCAL_SERVER_INSTALL_DIR="$HOME/steam_data/steamapps/workshop/content/$DAYZ_GAME_ID" - -