fisrt
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user