Files
dayz-servers/server_start.sh
2023-11-25 01:05:22 -06:00

73 lines
1.8 KiB
Bash

#!/usr/bin/env bash
#
# 01. "should check code directly not $?"
# shellcheck disable=2181
#
# 02. "can't follow . import"
# shellcheck disable=1090
#
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
##################### CHANGE ME #################################
export SERVER_NAME="XXXXXXXXXX"
##################### CHANGE ME #################################
# ===================================================
# 01. Attempt to load global DayZ values
# ===================================================
echo "Starting, attempting to load globals.sh"
GLOBALS_FILE="$PWD/lib/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
# ===================================================
#
#
# Local server file hierarchy:
#
# c:/DAYZ
# ^--/servers
# ^--/cache
#
export MAIN="/mnt/c/DAYZ"
export CACHE="$MAIN/cache"
export MOD_CACHE="$CACHE/mods"
export SERVERS="$MAIN/servers"
export SERVER_HOME="$SERVERS/$SERVER_NAME"
export RESTART_INTERVAL=$((60 * 60 * 4 + 3))
# ===================================================
# 03. init and checks
# ===================================================
check() {
if [ ! -d "$MAIN" ] ; then
die "dir: $MAIN does not exist"
fi
if [ ! -d "$SERVER_HOME" ] ; then
die "dir: $SERVER_HOME does not exist"
fi
msg "Health checks completed successfully."
}
init() {
check || die "Failed check()"
mkdir -p "$CACHE" "$MOD_CACHE"
msg "Completed intialization. Using server restart time of $RESTART_INTERVAL seconds."
}
# ===================================================
main() {
check || die "Failed check()"
}
main "$@" || exit 1