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