Add support for running post mod install scripts.

Fix the use of an environment variable that conflicts with a shell variable.
This commit is contained in:
Daniel Ceregatti 2025-07-28 15:59:37 -06:00
parent fcda4d1d60
commit 0f2ecce170

View file

@ -123,6 +123,7 @@ add(){
echo -e "Mod id ${1} - ${green}${MODNAME}${default} - added"
xml ${ID}
map ${ID}
installMod ${ID}
}
# Remove a mod
@ -146,6 +147,17 @@ remove(){
echo -e "Mod id ${1} - ${red}${MODNAME}${default} - removed"
}
# Handle custom scripts after installing a mod
installMod(){
FILE="${WORKSHOP_DIR}/${1:?}/install.sh"
if [ -f "${FILE}" ]
then
MODNAME=$(get_mod_name ${1})
echo "Running custom install script ${FILE} for mod id ${1}"
${FILE}
fi
}
# Handle the Steam login information.
login(){
if [ -f "${STEAM_LOGIN}" ]
@ -324,14 +336,14 @@ Mods: "
map(){
# Install map mpmissions for mods that have them. Presumes a map.env was created for the mod, with the required metadata (git URL, etc.)
TERM="map"
WHICH="map"
if [[ "${1}" =~ ^[0-9]+$ ]]
then
TERM="mod id"
WHICH="mod id"
fi
if [ -f "${FILES}/mods/${1}/map.env" ]
then
echo "Installing mpmissions files for ${TERM} ${1}..."
echo "Installing mpmissions files for ${WHICH} ${1}..."
source ${FILES}/mods/${1}/map.env
${FILES}/bin/map.sh ${1} install
fi