Replace tabs with space

This commit is contained in:
2024-11-12 14:38:02 +02:00
parent 45f339fb03
commit 56d35d754f
+57 -60
View File
@@ -13,54 +13,53 @@ MOD_NAMES=("@antistasi")
MODS=(2867537125) MODS=(2867537125)
function workshop_download () { function workshop_download () {
steamcmd +login $STEAM_ACCT_USERNAME +workshop_download_item $ARMA3_ID $1 validate +quit steamcmd +login $STEAM_ACCT_USERNAME +workshop_download_item $ARMA3_ID $1 validate +quit
}; };
# Check if target folder is not available or clean it and (re)fill it. # Check if target folder is not available or clean it and (re)fill it.
# TODO: Add PWD to execute in current folder, not absolute paths. # TODO: Add PWD to execute in current folder, not absolute paths.
function move_workshop_item () { function move_workshop_item () {
if [ ! -d /app/serverfiles/mods/$2 ]; if [ ! -d /app/serverfiles/mods/$2 ]; then
then mkdir /app/serverfiles/mods/$2
mkdir /app/serverfiles/mods/$2
else else
# Clean old stuff up. # Clean old stuff up.
rm -r /app/serverfiles/mods/$2 rm -r /app/serverfiles/mods/$2
mkdir /app/serverfiles/mods/$2 mkdir /app/serverfiles/mods/$2
fi fi
# Move new mod data into appropriate folders. # Move new mod data into appropriate folders.
cp -r /data/.local/share/Steam/steamapps/workshop/content/$ARMA3_ID/$1/* /app/serverfiles/mods/$2 cp -r /data/.local/share/Steam/steamapps/workshop/content/$ARMA3_ID/$1/* /app/serverfiles/mods/$2
rm -r /data/.local/share/Steam/steamapps/workshop/* # Fix Queue not Empty: epochmod.com/forum/topic/42074-fixed-steamcmd-queue-not-empty/ rm -r /data/.local/share/Steam/steamapps/workshop/* # Fix Queue not Empty: epochmod.com/forum/topic/42074-fixed-steamcmd-queue-not-empty/
}; };
# If any mod name contains any uppercase character, clean it, since arma cannot deal with this. # If any mod name contains any uppercase character, clean it, since arma cannot deal with this.
function check_and_fix_depth () { function check_and_fix_depth () {
local depth=0 local depth=0
for x in $(find . -type d | sed "s/[^/]//g"); do for x in $(find . -type d | sed "s/[^/]//g"); do
if [ ${depth} -lt ${#x} ]; then if [ ${depth} -lt ${#x} ]; then
depth=${#x} depth=${#x}
fi fi
done done
for ((i=1;i<=${depth};i++)); do for ((i=1;i<=${depth};i++)); do
for x in $(find . -maxdepth $i | grep [A-Z]); do for x in $(find . -maxdepth $i | grep [A-Z]); do
mv $x $(echo $x | tr 'A-Z' 'a-z' ) mv $x $(echo $x | tr 'A-Z' 'a-z' )
done done
done done
}; };
function apply_mod_signing_keys_to_server () { function apply_mod_signing_keys_to_server () {
for dir in Keys keys Key key; do for dir in Keys keys Key key; do
if [ -d /app/serverfiles/mods/$1/$dir ]; then if [ -d /app/serverfiles/mods/$1/$dir ]; then
cp -r /app/serverfiles/mods/$1/$dir/*.bikey /app/serverfiles/keys/ cp -r /app/serverfiles/mods/$1/$dir/*.bikey /app/serverfiles/keys/
fi fi
done done
}; };
function remove_mod_signing_keys_from_server () { function remove_mod_signing_keys_from_server () {
pushd $(pwd) pushd $(pwd)
cd /app/serverfiles/keys/ cd /app/serverfiles/keys/
find . ! -name a3.bikey -maxdepth 1 -type f -delete find . ! -name a3.bikey -maxdepth 1 -type f -delete
popd popd
} }
check_mod_names_and_mods_array_lengths () { check_mod_names_and_mods_array_lengths () {
@@ -69,13 +68,13 @@ check_mod_names_and_mods_array_lengths () {
if [[ ! ${#array1[@]} -eq ${#array2[@]} ]]; then if [[ ! ${#array1[@]} -eq ${#array2[@]} ]]; then
echo "Arrays MOD_NAMES and MODS are not correctly filled, please check." echo "Arrays MOD_NAMES and MODS are not correctly filled, please check."
exit 1 exit 1
fi fi
} }
function replace_mods_value () { function replace_mods_value () {
local -n MOD_ARRAY=$1 local -n MOD_ARRAY=$1
local LINUXGSM_SERVER_CONFIG="/app/lgsm/config-lgsm/arma3server/arma3server.cfg" local LINUXGSM_SERVER_CONFIG="/app/lgsm/config-lgsm/arma3server/arma3server.cfg"
local MOD_LIST="" local MOD_LIST=""
if [[ ! -e "$LINUXGSM_SERVER_CONFIG" ]]; then if [[ ! -e "$LINUXGSM_SERVER_CONFIG" ]]; then
@@ -83,9 +82,9 @@ function replace_mods_value () {
return 1 return 1
fi fi
for mod in "${MOD_ARRAY[@]}"; do for mod in "${MOD_ARRAY[@]}"; do
MOD_LIST+="mods/${mod}\;" MOD_LIST+="mods/${mod}\;"
done done
# Use sed to find the line and replace the current value of mods with the new string # Use sed to find the line and replace the current value of mods with the new string
sed -i "s/^mods=\"[^\"]*\"/mods=\"$MOD_LIST\"/" "$LINUXGSM_SERVER_CONFIG" sed -i "s/^mods=\"[^\"]*\"/mods=\"$MOD_LIST\"/" "$LINUXGSM_SERVER_CONFIG"
@@ -94,29 +93,27 @@ function replace_mods_value () {
} }
function start () { function start () {
local counter=1 local counter=1
local maxtries=5 local maxtries=5
check_mod_names_and_mods_array_lengths ${MOD_NAMES} ${MODS} check_mod_names_and_mods_array_lengths ${MOD_NAMES} ${MODS}
remove_mod_signing_keys_from_server remove_mod_signing_keys_from_server
steamcmd +login $STEAM_ACCT_USERNAME +quit # buffer steam login for mod download and update! steamcmd +login $STEAM_ACCT_USERNAME +quit # buffer steam login for mod download and update!
for i in ${!MODS[*]}; for i in ${!MODS[*]}; do
do until workshop_download ${MODS[$i]}; do
until workshop_download ${MODS[$i]}; echo "Error downloading ${MOD_NAMES[$i]}... Try ${counter}/${maxtries}"
do counter=$((counter + 1))
echo "Error downloading ${MOD_NAMES[$i]}... Try ${counter}/${maxtries}" if [ $counter -ge $maxtries ]; then
counter=$((counter + 1)) echo "Mod ${MOD_NAMES[$i]} has not downloaded, check steamcmd stderr.txt: /data/.local/share/Steam/logs/stderr.txt"
if [ $counter -ge $maxtries ]; then exit 1;
echo "Mod ${MOD_NAMES[$i]} has not downloaded, check steamcmd stderr.txt: /data/.local/share/Steam/logs/stderr.txt" fi
exit 1; done
fi move_workshop_item ${MODS[$i]} ${MOD_NAMES[$i]}
done apply_mod_signing_keys_to_server ${MOD_NAMES[$i]}
move_workshop_item ${MODS[$i]} ${MOD_NAMES[$i]} sleep 5 # Prevent downloading too fast and getting rate limited.
apply_mod_signing_keys_to_server ${MOD_NAMES[$i]} done
sleep 5 # Prevent downloading too fast and getting rate limited. check_and_fix_depth
done replace_mods_value ${MODS}
check_and_fix_depth echo "Thank you for using Mod Downloader!"
replace_mods_value ${MODS}
echo "Thank you for using Mod Downloader!"
}; };
start start