new
This commit is contained in:
169
start.sh
169
start.sh
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh -e
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# shellcheck disable=2043
|
||||
#
|
||||
@@ -9,34 +9,21 @@
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
export DAYZ_FILES=/mnt/dayz
|
||||
export STOCK_SERVER_DATA="$DAYZ_FILES/stock/DayZServer"
|
||||
|
||||
export MAIN="/mnt/c/DAYZ"
|
||||
export SERVERS="$MAIN/servers"
|
||||
export CACHE="$MAIN/cache"
|
||||
|
||||
export MOD_CACHE="$CACHE/mods"
|
||||
export RESTART_INTERVAL=$((60 * 60 * 4 + 3))
|
||||
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
# SERVER SPECIFIC SETTINGS
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
export SERVER_NAME='ZyaD Chernarus'
|
||||
export SERVER_HOME="$SERVERS/$SERVER_NAME"
|
||||
export MAP_FOLDER_NAME='chernarus'
|
||||
export LOCAL_FOLDER_MAP_NAME='dayzOffline.chernarusplus'
|
||||
export SERVER_PORT=2302
|
||||
export SERVER_CPU=8
|
||||
export SERVER_CONFIG_FILE="serverDZ.cfg"
|
||||
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
# Helper functions
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
if [ ! "$DEBUG" ] ; then
|
||||
alias do_sync='rsync -rltDhu --delete --partial'
|
||||
alias do_secure_sync='rsync -crltDhu --delete --partial'
|
||||
alias do_sync='rsync -rltDhu --delete --partial'
|
||||
alias do_secure_sync='rsync -crltDhu --delete --partial'
|
||||
else
|
||||
alias do_sync='rsync -vrltDhu --delete --partial --progress'
|
||||
alias do_secure_sync='rsync -cvrltDhu --delete --partial --progress'
|
||||
alias do_sync='rsync -vrltDhu --delete --partial --progress'
|
||||
alias do_secure_sync='rsync -cvrltDhu --delete --partial --progress'
|
||||
fi
|
||||
|
||||
msg() {
|
||||
@@ -85,18 +72,10 @@ setup_environment() {
|
||||
|
||||
# list of all stock files
|
||||
for file in ban.txt dayz.gproj dayzsetting.xml serverDZ.cfg whitelist.txt \
|
||||
DayZServer_x64.exe steam_api64.dll steamclient64.dll tier0_s64.dll vstdlib_s64.dll ; do
|
||||
DayZServer_x64.exe steam_api64.dll steamclient64.dll tier0_s64.dll vstdlib_s64.dll ; do
|
||||
do_sync "$STOCK_SERVER_DATA/$file" "$SERVER_HOME/$file" || die "Failed to copy stock: $file"
|
||||
done
|
||||
|
||||
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
# NOTE: TODO: Namalsk etc will need this changed!@@!@!@!@!@
|
||||
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
msg "Copying stock mpmissions data"
|
||||
do_sync --exclude="*storage_1*" "$STOCK_SERVER_DATA/mpmissions/dayzOffline.enoch"/ "$SERVER_HOME/mpmissions/dayzOffline.enoch"
|
||||
do_sync --exclude="*storage_1*" "$STOCK_SERVER_DATA/mpmissions/dayzOffline.chernarusplus"/ "$SERVER_HOME/mpmissions/dayzOffline.chernarusplus"
|
||||
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
msg "Copying mod files"
|
||||
do_sync "$DAYZ_FILES/mods/$MAP_FOLDER_NAME"/ "$MOD_CACHE/$MAP_FOLDER_NAME" || die "Failed to copy mod files"
|
||||
|
||||
@@ -149,6 +128,123 @@ load_mods() {
|
||||
printf '%s\n' "$_modstring" > .modstring
|
||||
}
|
||||
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
# Load Map
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
load_stock_map_data() {
|
||||
msg "Loading stock map data"
|
||||
do_sync --exclude="*storage_1*" \
|
||||
"$DAYZ_FILES/stock/maps/$MAP_FOLDER_NAME"/ \
|
||||
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME"
|
||||
}
|
||||
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
# Types Patching
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
patch_types() {
|
||||
|
||||
if [ ! -f "$DAYZ_FILES/server_configs/types/default_types_to_delete.txt" ] ; then
|
||||
die "CANNOT REACH FILE: default_types_to_delete.txt"
|
||||
fi
|
||||
|
||||
# deletes
|
||||
while read -r line ; do
|
||||
case "$line" in
|
||||
'#'*|' '*|'')
|
||||
;;
|
||||
*)
|
||||
debug "TYPES -- deleting object: $line"
|
||||
xmlstarlet ed -L -P -d "//types/type[@name=\"$line\"]" \
|
||||
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/db/types.xml"
|
||||
esac
|
||||
done < "$DAYZ_FILES/server_configs/types/default_types_to_delete.txt"
|
||||
|
||||
# copy types edit tool
|
||||
if [ -f "$DAYZ_FILES/scripts/adjust_type.sh" ] ; then
|
||||
cp -f "$DAYZ_FILES/scripts/adjust_type.sh" "$SERVER_HOME"/
|
||||
else
|
||||
die "Could not find adjust_type.sh"
|
||||
fi
|
||||
|
||||
if [ -f "$DAYZ_FILES/server_configs/types/$MAP_FOLDER_NAME.sh" ] ; then
|
||||
|
||||
cp -f "$DAYZ_FILES/server_configs/types/$MAP_FOLDER_NAME.sh" \
|
||||
"$SERVER_HOME"/
|
||||
|
||||
cd "$SERVER_HOME" || die "could not cd to $SERVER_HOME"
|
||||
|
||||
sh "$SERVER_HOME/$MAP_FOLDER_NAME.sh" \
|
||||
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/db/types.xml" || \
|
||||
die "Failed while running maps types edit script"
|
||||
|
||||
else
|
||||
die "Could not find $DAYZ_FILES/server_configs/types/$MAP_FOLDER_NAME.sh"
|
||||
fi
|
||||
}
|
||||
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
# Configs
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
load_configs() {
|
||||
msg "Loading server configs"
|
||||
|
||||
if [ -d "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME" ] ; then
|
||||
|
||||
for xml in "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME"/*.xml ; do
|
||||
if [ -f "$xml" ] ; then
|
||||
debug "Found: $xml -- Copying."
|
||||
do_sync "$xml" "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/${xml##*/}" || \
|
||||
die "Failed to copy: ${xml##*/}"
|
||||
fi
|
||||
done
|
||||
|
||||
for json in "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME"/*.json ; do
|
||||
if [ -f "$json" ] ; then
|
||||
debug "Found: $json -- Copying."
|
||||
do_sync "$json" "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/${json##*/}" || \
|
||||
die "Failed to copy: ${json##*/}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -f "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/init.c" ] ; then
|
||||
debug "Found: init.c -- Copying."
|
||||
do_secure_sync \
|
||||
"$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/init.c" \
|
||||
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/init.c" || \
|
||||
die "failed to copy init.c"
|
||||
fi
|
||||
|
||||
if [ -f "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/areaflags.map" ] ; then
|
||||
debug "Found: areaflags.map -- Copying."
|
||||
do_sync \
|
||||
"$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/areaflags.map" \
|
||||
"$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/areaflags.map" || \
|
||||
die "failed to copy areaflags.map"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [ -d "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/db" ] ; then
|
||||
for xml in "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/db"/*.xml ; do
|
||||
if [ -f "$xml" ] ; then
|
||||
debug "Found: $xml -- Copying."
|
||||
do_sync "$xml" "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/db/${xml##*/}" || \
|
||||
die "Failed to copy: ${xml##*/}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -d "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/env" ] ; then
|
||||
for xml in "$DAYZ_FILES/server_configs/mpmissions/$MAP_FOLDER_NAME/env"/*.xml ; do
|
||||
if [ -f "$xml" ] ; then
|
||||
debug "Found: $xml -- Copying."
|
||||
do_sync "$xml" "$SERVER_HOME/mpmissions/$MAP_FOLDER_NAME/env/${xml##*/}" || \
|
||||
die "Failed to copy: ${xml##*/}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
# Main
|
||||
# -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
@@ -165,7 +261,17 @@ main() {
|
||||
load_mods || die "Could not load mods"
|
||||
mod_string=$(cat .modstring)
|
||||
|
||||
>&2 printf 'MOD_STRING: %s\n' "$mod_string"
|
||||
msg "Loading stock map data"
|
||||
load_stock_map_data || die "Could not load map"
|
||||
|
||||
msg "Patching types.xml"
|
||||
patch_types || die "Failed to patch types"
|
||||
|
||||
msg "Copying server configs"
|
||||
load_configs || die "Failed to load configs"
|
||||
|
||||
# msg "Creating custom types list"
|
||||
#############################
|
||||
|
||||
echo '===================================='
|
||||
printf '%s - Server started.\n' "$(date)"
|
||||
@@ -198,6 +304,11 @@ EOF
|
||||
msg "SERVER IS RESTARTING"
|
||||
}
|
||||
|
||||
while : ; do
|
||||
while msg 'Starting loop' ; do
|
||||
if [ -f ./SERVER.ENV ] ; then
|
||||
. ./SERVER.ENV
|
||||
else
|
||||
die "Could not source ./SERVER.ENV"
|
||||
fi
|
||||
main "$@"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user