From c66cacd2316c7e37677bfccd8d3697feb901029e Mon Sep 17 00:00:00 2001 From: Mitch Weaver Date: Sun, 26 Nov 2023 09:23:26 -0600 Subject: [PATCH] adjust_types.sh rewritten --- archive/adjust_type.sh | 112 -------------- .../discord}/bots/num1/Config.json | 0 .../bots/num1/DiscordPlayerCountBot.exe | Bin .../discord}/bots/num1/log4net.config | 0 .../bots/num1/warnings_and_errors.log | 0 .../discord}/discord_bot_info.txt | 0 {discord => archive/discord}/logo.png | Bin {discord => archive/discord}/vc1-id.txt | 0 lib/globals.sh | 5 +- lib/typestool.sh | 145 ++++++++++++++++++ modserver_update.sh | 5 +- scripts/choco_win2022_node_setup.bat | 1 + server_start.sh | 2 +- 13 files changed, 153 insertions(+), 117 deletions(-) delete mode 100644 archive/adjust_type.sh rename {discord => archive/discord}/bots/num1/Config.json (100%) rename {discord => archive/discord}/bots/num1/DiscordPlayerCountBot.exe (100%) rename {discord => archive/discord}/bots/num1/log4net.config (100%) rename {discord => archive/discord}/bots/num1/warnings_and_errors.log (100%) rename {discord => archive/discord}/discord_bot_info.txt (100%) rename {discord => archive/discord}/logo.png (100%) rename {discord => archive/discord}/vc1-id.txt (100%) create mode 100644 lib/typestool.sh create mode 100644 scripts/choco_win2022_node_setup.bat diff --git a/archive/adjust_type.sh b/archive/adjust_type.sh deleted file mode 100644 index 1ce1994..0000000 --- a/archive/adjust_type.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env bash -# -# Wrapper for editing DayZ types.xml using xmlstarlet -# -#---------------------------------------------------------- - -# example: swap_flag M16A2 count_in_cargo 1 file -swap_flag() { - file=$4 - - if ! command -v xmlstarlet >/dev/null ; then - >&2 echo "NOT IN \$PATH: xmlstarlet" - exit 1 - fi - - if [ ! -f "$file" ] ; then - >&2 echo "File: '$file' is not a file" - exit 1 - fi - - if [ "$1" ] && [ "$2" ] && [ "$3" ] ; then - _name=$1 - _flag=$2 - _value=$3 - xmlstarlet ed -P -L \ - -u \ "//types/type[@name=\"$_name\"]/flags[@$_flag]/@$_flag" \ - -v \ - "$_value" \ - "$file" - else - >&2 echo "Bad params in swap_flag" - exit 1 - fi -} - -# example: swap_value M4A1 nominal 3 file -swap_value() { - file=$4 - - if ! command -v xmlstarlet >/dev/null ; then - >&2 echo "NOT IN \$PATH: xmlstarlet" - exit 1 - fi - - if [ ! -f "$file" ] ; then - >&2 echo "File: '$file' is not a file" - exit 1 - fi - - if [ "$1" ] && [ "$2" ] && [ "$3" ] ; then - _name=$1 - _tag=$2 - _value=$3 - xmlstarlet ed -P -L \ - -u \ "//types/type[@name=\"$_name\"]/$_tag" \ - -v \ - "$_value" \ - "$file" - else - >&2 echo "Bad params in swap_value" - exit 1 - fi -} - -usage() { -cat < - 28800 - - -${0##*/} -v M16A2 lifetime 20000 some_file.xml - -# example #2: - - - - - -${0##*/} -f M16A2 count_in_player 1 some_file.xml - -EOF -exit 1 -} - -if [ "$DEBUG" ] ; then - echo "ADJUSTING TYPE: $2 $3" -fi - -case $1 in - -h|--help) - usage - ;; - -f) - shift - swap_flag "$1" "$2" "$3" "$4" || exit 1 - ;; - -v) - shift - swap_value "$1" "$2" "$3" "$4" || exit 1 - ;; -esac diff --git a/discord/bots/num1/Config.json b/archive/discord/bots/num1/Config.json similarity index 100% rename from discord/bots/num1/Config.json rename to archive/discord/bots/num1/Config.json diff --git a/discord/bots/num1/DiscordPlayerCountBot.exe b/archive/discord/bots/num1/DiscordPlayerCountBot.exe similarity index 100% rename from discord/bots/num1/DiscordPlayerCountBot.exe rename to archive/discord/bots/num1/DiscordPlayerCountBot.exe diff --git a/discord/bots/num1/log4net.config b/archive/discord/bots/num1/log4net.config similarity index 100% rename from discord/bots/num1/log4net.config rename to archive/discord/bots/num1/log4net.config diff --git a/discord/bots/num1/warnings_and_errors.log b/archive/discord/bots/num1/warnings_and_errors.log similarity index 100% rename from discord/bots/num1/warnings_and_errors.log rename to archive/discord/bots/num1/warnings_and_errors.log diff --git a/discord/discord_bot_info.txt b/archive/discord/discord_bot_info.txt similarity index 100% rename from discord/discord_bot_info.txt rename to archive/discord/discord_bot_info.txt diff --git a/discord/logo.png b/archive/discord/logo.png similarity index 100% rename from discord/logo.png rename to archive/discord/logo.png diff --git a/discord/vc1-id.txt b/archive/discord/vc1-id.txt similarity index 100% rename from discord/vc1-id.txt rename to archive/discord/vc1-id.txt diff --git a/lib/globals.sh b/lib/globals.sh index ff09436..e1d39e0 100644 --- a/lib/globals.sh +++ b/lib/globals.sh @@ -1,4 +1,4 @@ -#!/bin/sh -ex +#!/bin/sh -e # # values used on both the modserver and individual servers # ------------------------------------------------------------ @@ -8,7 +8,8 @@ export DAYZ_GAME_ID=221100 export DAYZ_SERVER_ID=223350 export STEAM_USER="yzaddayz" -export DEBUG=false +# blank debug to unset it by default +export DEBUG= export REMOTE_DAYZ_TRUENAS_SHARE='\\dayz-truenas.local.wvr.sh\dayz' export REMOTE_DIR="/mnt/dayz" diff --git a/lib/typestool.sh b/lib/typestool.sh new file mode 100644 index 0000000..25c5526 --- /dev/null +++ b/lib/typestool.sh @@ -0,0 +1,145 @@ +#!/bin/sh -e +# +# Wrapper for editing DayZ types.xml using xmlstarlet +# +# 01. "should check code directly not $?" +# shellcheck disable=2181 +# +# 02. "can't follow . import" +# shellcheck disable=1090,1091 +# +# 03. "possible misspelling" +# shellcheck disable=2153 +# +# 04. "use find .. over ls" +# shellcheck disable=2011 +#---------------------------------------------------------- + +# ================================================================= +# LOAD GLOBALS FILE +# ================================================================= +GLOBALS_FILE="$PWD/globals.sh" +if [ -e "$GLOBALS_FILE" ] ; then + chmod +x "$GLOBALS_FILE" + . "$GLOBALS_FILE" +else + >&2 echo "Could not load: $GLOBALS_FILE" + exit 1 +fi +# ================================================================= + +# example: swap_flag M16A2 count_in_cargo 1 file +swap_flags() { + file=$4 + + if [ ! -f "$file" ] ; then + >&2 echo "File: '$file' is not a file" + exit 1 + fi + + if [ "$1" ] && [ "$2" ] && [ "$3" ] ; then + _name=$1 + _flag=$2 + _value=$3 + xmlstarlet ed -P -L \ + -u \ "//types/type[@name=\"$_name\"]/flags[@$_flag]/@$_flag" \ + -v \ + "$_value" \ + "$file" + else + >&2 echo "Bad params in swap_flag" + exit 1 + fi +} + +# example: swap_value M4A1 nominal 3 file +swap_value() { + file=$4 + + if [ ! -f "$file" ] ; then + >&2 echo "File: '$file' is not a file" + exit 1 + fi + + if [ "$1" ] && [ "$2" ] && [ "$3" ] ; then + _name=$1 + _tag=$2 + _value=$3 + xmlstarlet ed -P -L \ + -u \ "//types/type[@name=\"$_name\"]/$_tag" \ + -v \ + "$_value" \ + "$file" + else + >&2 echo "Bad params in swap_value" + exit 1 + fi +} + +usage() { +cat < + 1 + + +${0##*/} --swap-value M4A1 nominal 2 some_file.xml + +# -------------------------------- +# Ex #2: Swapping a flags value +# -------------------------------- + + + + + +${0##*/} --swap-flags M16A2 count_in_player 1 some_file.xml + +EOF +exit 1 +} + +check() { + if ! command -v xmlstarlet >/dev/null ; then + die "Please install xmlstarlet" + fi +} + +main() { + check || die "Failed check" + + if [ "$DEBUG" ] ; then + echo "ADJUSTING TYPE: $2 $3" + fi + + case $1 in + -h|--help) + usage + ;; + -v|--swap-value) + shift + swap_value "$1" "$2" "$3" "$4" || exit 1 + ;; + -f|--swap-flags) + shift + swap_flags "$1" "$2" "$3" "$4" || exit 1 + ;; + esac +} + +main "$@" + diff --git a/modserver_update.sh b/modserver_update.sh index 74694e1..5193769 100644 --- a/modserver_update.sh +++ b/modserver_update.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e # # 01. "should check code directly not $?" # shellcheck disable=2181 @@ -23,7 +23,8 @@ if [ -e "$GLOBALS_FILE" ] ; then chmod +x "$GLOBALS_FILE" . "$GLOBALS_FILE" else - die "Could not load: $GLOBALS_FILE" + >&2 echo "Could not load: $GLOBALS_FILE" + exit 1 fi # =================================================== diff --git a/scripts/choco_win2022_node_setup.bat b/scripts/choco_win2022_node_setup.bat new file mode 100644 index 0000000..d7b90e5 --- /dev/null +++ b/scripts/choco_win2022_node_setup.bat @@ -0,0 +1 @@ +choco install -y firefox 7zip cpu-z hwinfo vcredist2015 directx directx-sdk \ No newline at end of file diff --git a/server_start.sh b/server_start.sh index c103608..8b8ea81 100644 --- a/server_start.sh +++ b/server_start.sh @@ -1,4 +1,4 @@ -#!/bin/sh -ex +#!/bin/sh -e # # 01. "should check code directly not $?" # shellcheck disable=2181