installing deprecated mods carefully

This commit is contained in:
leca 2024-09-29 20:05:12 +03:00
parent c57d701656
commit f093a47b66
1 changed files with 19 additions and 2 deletions

View File

@ -53,11 +53,28 @@ is_game () {
# 1 = mod id
download_and_install_mod () {
#Parse mod name
oIFS="$IFS"
IFS=$'/'
read -r -a modid <<< "$1"
IFS="$oIFS"
modauthor="${modid[0]}"
modname="${modid[1]}"
mod_url=$(curl --silent -X GET "$API_URL/packages/${1}/" | jq ".url" | tr -d '"')
mod_file="${mods_path}/mod.zip"
mod_file="${mods_path}/${modname}.zip"
echo "Writing to ${mod_file} content from url ${mod_url}"
wget -O "${mod_file}" "${mod_url}"
unzip -l "${mod_file}" | grep -q mod.conf
if [[ "$?" == "0" ]]; then # mod.conf found, this is a normal mod
unzip -oq "${mod_file}" -d "${mods_path}"
else # mod.conf not found, mod is deprecated
echo "Warning! mod ${modname} is deprecated!"
deprecated_mod_path="${mods_path}/${modname}"
echo "Installing it to ${deprecated_mod_path}"
mkdir -p "${deprecated_mod_path}"
unzip -oq "${mod_file}" -d "${deprecated_mod_path}"
fi
rm "${mod_file}"
}