This commit is contained in:
2023-11-20 21:43:19 -06:00
parent 5e1e8045fe
commit 99a8e96db7
2 changed files with 168 additions and 113 deletions

View File

@@ -16,6 +16,14 @@ export REMOTE_MODS="$REMOTE_DIR/mods"
export REMOTE_STOCK_SERVER="$REMOTE_DIR/stock/DayZServer" export REMOTE_STOCK_SERVER="$REMOTE_DIR/stock/DayZServer"
export REMOTE_STOCK_GAME="$REMOTE_DIR/stock/DayZ" export REMOTE_STOCK_GAME="$REMOTE_DIR/stock/DayZ"
export CHERNARUS_MAP_NAME=dayzOffline.chernarusplus
export NAMALSK_MAP_NAME=regular.namalsk
export TAKISTAN_MAP_NAME=Offline.TakistanPlus
export NAMALSK_MOD_ID=2289461232
export TAKISTAN_MOD_ID=2563233742
################### GLOBAL VARS ############################## ################### GLOBAL VARS ##############################
################### GLOBAL ALIASES ########################### ################### GLOBAL ALIASES ###########################
@@ -24,102 +32,93 @@ alias do_sync='rsync -rvltDhu --delete --partial --progress'
################### GLOBAL FUNCTIONS ######################### ################### GLOBAL FUNCTIONS #########################
msg() { msg() {
printf '[*] %s\n' "$*" printf '[*] %s\n' "$*"
} }
errmsg() { errmsg() {
>&2 printf '[Error]: %s\n' "$*" >&2 printf '[Error]: %s\n' "$*"
} }
die() { die() {
errmsg "$*" errmsg "$*"
exit 1 exit 1
}
isnum() {
case $1 in
''|*[!0-9]*)
exit 1
;;
*)
exit 0
esac
} }
isempty() { isempty() {
for arg in "$@" ; do for arg in "$@" ; do
# exit in error if file # exit in error if file
if [ -f "$arg" ] ; then if [ -f "$arg" ] ; then
exit 1 exit 1
elif [ -L "$arg" ] ; then elif [ -L "$arg" ] ; then
# if is a symlink, check what it points to # if is a symlink, check what it points to
# note: this only checks one-link level deep # note: this only checks one-link level deep
if [ -d "$(readlink "$arg")" ] ; then if [ -d "$(readlink "$arg")" ] ; then
exit 0 exit 0
else else
exit 1 exit 1
fi fi
elif [ -d "$arg" ] ; then elif [ -d "$arg" ] ; then
: :
else else
# is not a directory or a link to a directory # is not a directory or a link to a directory
exit 1 exit 1
fi fi
# there should be a way to make this be builtins only # there should be a way to make this be builtins only
# using printf and glob expansions, look into later # using printf and glob expansions, look into later
if /bin/rmdir "$arg" 2>/dev/null ; then if /bin/rmdir "$arg" 2>/dev/null ; then
/bin/mkdir -p "$arg" /bin/mkdir -p "$arg"
exit 0 exit 0
else else
exit 1 exit 1
fi fi
done done
} }
mount_dayz_network_drive() { mount_dayz_network_drive() {
if ! is_network_drive_mounted ; then if ! is_network_drive_mounted ; then
sudo mkdir -p /mnt/dayz sudo mkdir -p /mnt/dayz
if [ -e /proc/version ] ; then if [ -e /proc/version ] ; then
read -r ver < /proc/version read -r ver < /proc/version
case $ver in case $ver in
# WSL # WSL
*icrosoft*) *icrosoft*)
msg "Detected WSL, mounting via drvfs" msg "Detected WSL, mounting via drvfs"
sudo mount -t drvfs -o user=samba \ sudo mount -t drvfs -o user=samba \
//truenas.local.wvr.sh/dayz /mnt/dayz //truenas.local.wvr.sh/dayz /mnt/dayz
;; ;;
*) *)
msg "Detected Linux, mounting via cifs" msg "Detected Linux, mounting via cifs"
# shellcheck disable=2046 # shellcheck disable=2046
sudo mount -t cifs //truenas.local.wvr.sh/dayz /mnt/dayz \ sudo mount -t cifs //truenas.local.wvr.sh/dayz /mnt/dayz \
-o rw \ -o rw \
-o credentials=/root/sambacreds.txt \ -o credentials=/root/sambacreds.txt \
-o iocharset=utf8 \ -o iocharset=utf8 \
-o vers=3.0 \ -o vers=3.0 \
-o uid=$(id -u) \ -o uid=$(id -u) \
-o gid=$(id -g) -o gid=$(id -g)
esac esac
unset ver unset ver
else else
errmsg 'could not find /proc/version' errmsg 'could not find /proc/version'
exit 1 exit 1
fi fi
fi fi
if ! is_network_drive_mounted ; then if ! is_network_drive_mounted ; then
errmsg 'Could not mount network drive' errmsg 'Could not mount network drive'
exit 1 exit 1
fi fi
} }
is_network_drive_mounted() { is_network_drive_mounted() {
if [ ! -f "$REMOTE_DIR/canary" ] ; then if [ ! -f "$REMOTE_DIR/canary" ] ; then
return 1 return 1
fi fi
# test write # test write
touch /mnt/dayz/canary.test touch /mnt/dayz/canary.test
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
rm /mnt/dayz/canary.test rm /mnt/dayz/canary.test
else else
errmsg "Mounted network drive but we do not have write access." errmsg "Mounted network drive but we do not have write access."
exit 1 exit 1
fi fi
} }
################### GLOBAL FUNCTIONS ######################### ################### GLOBAL FUNCTIONS #########################

View File

@@ -134,29 +134,29 @@ update_mods_for_server() {
*) *)
mod=${mod%%^*} mod=${mod%%^*}
# check validity of syntax # check validity of syntax
if [ -z "$mod" ] ; then if [ -z "$mod" ] ; then
die "mod for $map_name appears to be empty - syntax error" die "mod for $map_name appears to be empty - syntax error"
fi fi
printf "+workshop_download_item $DAYZ_GAME_ID %s\n" "$mod" >> "$tempfile" printf "+workshop_download_item $DAYZ_GAME_ID %s\n" "$mod" >> "$tempfile"
mkdir -p "$LOCAL_MODS/$mod" mkdir -p "$LOCAL_MODS/$mod"
esac esac
done <"$mods_file" done <"$mods_file"
unset mod unset mod
# shellcheck disable=2046 # shellcheck disable=2046
steamcmd \ steamcmd \
-tcp \ -tcp \
+force_install_dir "$LOCAL_MODS" \ +force_install_dir "$LOCAL_MODS" \
+@sSteamCmdForcePlatformType windows \ +@sSteamCmdForcePlatformType windows \
+@ShutdownOnFailedCommand 1 \ +@ShutdownOnFailedCommand 1 \
+login "$STEAM_USER" \ +login "$STEAM_USER" \
$(xargs < "$tempfile") \ $(xargs < "$tempfile") \
+quit +quit
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
die "Problem downloading mods for $map_name" die "Problem downloading mods for $map_name"
fi fi
echo echo
@@ -168,19 +168,19 @@ update_mods_for_server() {
:> "$mods_to_copy/mods.txt" :> "$mods_to_copy/mods.txt"
while read -r mod ; do while read -r mod ; do
# skip comments, blank lines # skip comments, blank lines
case "$mod" in case "$mod" in
\#*|''|' ') \#*|''|' ')
;; ;;
*) *)
mod_id=${mod%%^*} mod_id=${mod%%^*}
mod_name=${mod##*^} mod_name=${mod##*^}
if [ ! -d "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id" ] ; then if [ ! -d "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id" ] ; then
die "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id does not exist" die "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id does not exist"
fi fi
do_sync "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id"/ "$mods_to_copy/@${mod_name}" do_sync "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$mod_id"/ "$mods_to_copy/@${mod_name}"
printf '@%s\n' "$mod_name" >> "$mods_to_copy/mods.txt" printf '@%s\n' "$mod_name" >> "$mods_to_copy/mods.txt"
esac esac
done < "$mods_file" done < "$mods_file"
echo echo
@@ -196,16 +196,72 @@ update_mods_for_server() {
echo echo
} }
update_stock_maps() {
msg "----------- UPDATING MAPS -------------"
msg "Copying Stock Chernarus"
do_sync \
"$LOCAL_STOCK_SERVER/mpmissions/$CHERNARUS_MAP_NAME"/ \
"$REMOTE_MAPS/$CHERNARUS_MAP_NAME"
msg "Updating Namalsk Survival"
steamcmd \
-tcp \
+force_install_dir "$LOCAL_MODS" \
+@sSteamCmdForcePlatformType windows \
+@ShutdownOnFailedCommand 1 \
+login "$STEAM_USER" \
+workshop_download_item \
"$DAYZ_GAME_ID" \
"$NAMALSK_MOD_ID" \
+quit
if [ $? -ne 0 ] ; then
die "Failed to update Namalsk Survival"
fi
if [ -d "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$NAMALSK_MOD_ID/Extras/Regular/$NAMALSK_MAP_NAME" ] ; then
do_sync "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$NAMALSK_MOD_ID/Extras/Regular/$NAMALSK_MAP_NAME"/ \
"$REMOTE_MAPS/$NAMALSK_MAP_NAME" || \
die "failed to copy Namalsk map files"
fi
####################TODO: # msg "Updating Optimized Namalsk Server PBOs"
msg "Updating TakistanPlus"
steamcmd \
-tcp \
+force_install_dir "$LOCAL_MODS" \
+@sSteamCmdForcePlatformType windows \
+@ShutdownOnFailedCommand 1 \
+login "$STEAM_USER" \
+workshop_download_item \
"$DAYZ_GAME_ID" \
"$TAKISTAN_MOD_ID" \
+quit
if [ $? -ne 0 ] ; then
die "Failed to update TakistanPlus"
fi
if [ -d "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$TAKISTAN_MOD_ID/Mission/$TAKISTAN_MAP_NAME" ] ; then
do_sync "$LOCAL_MODS/steamapps/workshop/content/$DAYZ_GAME_ID/$TAKISTAN_MOD_ID/Mission/$TAKISTAN_MAP_NAME"/ \
"$REMOTE_MAPS/$TAKISTAN_MAP_NAME" || \
die "failed to copy Takistan map files"
fi
}
main() { main() {
update_server update_server
update_game update_game
update_stock_maps
for server in $(ls "$MODLISTS" | xargs) ; do for server in $(ls "$MODLISTS" | xargs) ; do
[ -f "$MODLISTS/$server" ] || continue [ -f "$MODLISTS/$server" ] || continue
update_mods_for_server "$server" update_mods_for_server "$server"
unset server unset server
# rm -rf "$HOME/.steam/debian-installation/steamapps/workshop/downloads" # rm -rf "$HOME/.steam/debian-installation/steamapps/workshop/downloads"
# mkdir -p "$HOME/.steam/debian-installation/steamapps/workshop/downloads" # mkdir -p "$HOME/.steam/debian-installation/steamapps/workshop/downloads"
done done
} }