adjust_types.sh rewritten
This commit is contained in:
@@ -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 <<EOF
|
||||
Usage: ${0##*/} [-f|-v] name tag value file
|
||||
|
||||
-f swap a flag from flags
|
||||
-v swap a normal value
|
||||
|
||||
# --------------------------------
|
||||
# Examples
|
||||
# --------------------------------
|
||||
|
||||
# examples #1:
|
||||
|
||||
<type name="M16A2">
|
||||
<lifetime>28800</lifetime>
|
||||
</type>
|
||||
|
||||
${0##*/} -v M16A2 lifetime 20000 some_file.xml
|
||||
|
||||
# example #2:
|
||||
|
||||
<type name="M16A2">
|
||||
<flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="0" crafted="0" deloot="0"/>
|
||||
</type>
|
||||
|
||||
${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
|
||||
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
@@ -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"
|
||||
|
||||
145
lib/typestool.sh
Normal file
145
lib/typestool.sh
Normal file
@@ -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 <<EOF
|
||||
Usage: ${0##*/} [--swap-flags|--swap-value] item_name tag value types.xml
|
||||
|
||||
--swap-value swap an item tag's value
|
||||
--swap-flags swap an item's flags sub-value
|
||||
|
||||
|
||||
|
||||
# ================================
|
||||
# Examples
|
||||
# ================================
|
||||
|
||||
# --------------------------------
|
||||
# Ex #1: Swapping a value
|
||||
# --------------------------------
|
||||
|
||||
<type name="M4A1">
|
||||
<nominal>1</nominal>
|
||||
</type>
|
||||
|
||||
${0##*/} --swap-value M4A1 nominal 2 some_file.xml
|
||||
|
||||
# --------------------------------
|
||||
# Ex #2: Swapping a flags value
|
||||
# --------------------------------
|
||||
|
||||
<type name="M16A2">
|
||||
<flags count_in_cargo="0" count_in_hoarder="0" count_in_map="1" count_in_player="0" crafted="0" deloot="0"/>
|
||||
</type>
|
||||
|
||||
${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 "$@"
|
||||
|
||||
@@ -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
|
||||
|
||||
# ===================================================
|
||||
|
||||
1
scripts/choco_win2022_node_setup.bat
Normal file
1
scripts/choco_win2022_node_setup.bat
Normal file
@@ -0,0 +1 @@
|
||||
choco install -y firefox 7zip cpu-z hwinfo vcredist2015 directx directx-sdk
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh -ex
|
||||
#!/bin/sh -e
|
||||
#
|
||||
# 01. "should check code directly not $?"
|
||||
# shellcheck disable=2181
|
||||
|
||||
Reference in New Issue
Block a user