Browse Source

refactor: simplified fix.sh

pull/3836/head
Lucas Briese 3 years ago
parent
commit
a9bd66a16a
  1. 119
      lgsm/functions/fix.sh

119
lgsm/functions/fix.sh

@ -31,101 +31,58 @@ fn_fix_msg_end() {
fi
}
fn_exists_fix() {
local short="${1:?}"
if [ "$(type -t "fix_${short}.sh")" == 'function' ]; then
return 0
else
return 1
fi
}
fn_apply_fix() {
local phase_message="${1:?}"
local short="${2:?}"
if fn_exists_fix "${short}"; then
"fix_${short}.sh"
else
fn_print_error_nl "${shortname} is marked to apply pre start fix but there is no fix registered"
fi
}
local apply_pre_start_fix=(arma3 armar ark av bt bo csgo cmw dst hw ins nmrih onset rust rw sdtd sfc sof2 squad st tf2 terraria ts3 mcb mta unt vh wurm zmr)
local apply_post_install_fix=(av kf kf2 lo ro samp ut2k4 ut ut3)
# validate registered fixes for safe development
for fix in "${apply_pre_start_fix[@]}" "${apply_post_install_fix[@]}"; do
if ! fn_exists_fix "${fix}"; then
fn_print_fail_nl "fix_${fix}.sh is registered but doesn't exist. Typo or did you miss to modify core_functions.sh?"
exitcode 1
core_exit.sh
fi
done
# Fixes that are run on start.
if [ "${commandname}" != "INSTALL" ] && [ -z "${fixbypass}" ]; then
if [ "${commandname}" != "INSTALL" ]&&[ -z "${fixbypass}" ]; then
if [ "${appid}" ]; then
fix_steamcmd.sh
fi
if [ "${shortname}" == "arma3" ]; then
fix_arma3.sh
elif [ "${shortname}" == "armar" ]; then
fix_armar.sh
elif [ "${shortname}" == "ark" ]; then
fix_ark.sh
elif [ "${shortname}" == "av" ]; then
fix_av.sh
elif [ "${shortname}" == "bt" ]; then
fix_bt.sh
elif [ "${shortname}" == "bo" ]; then
fix_bo.sh
elif [ "${shortname}" == "csgo" ]; then
fix_csgo.sh
elif [ "${shortname}" == "cmw" ]; then
fix_cmw.sh
elif [ "${shortname}" == "dst" ]; then
fix_dst.sh
elif [ "${shortname}" == "hw" ]; then
fix_hw.sh
elif [ "${shortname}" == "ins" ]; then
fix_ins.sh
elif [ "${shortname}" == "nmrih" ]; then
fix_nmrih.sh
elif [ "${shortname}" == "onset" ]; then
fix_onset.sh
elif [ "${shortname}" == "rust" ]; then
fix_rust.sh
elif [ "${shortname}" == "rw" ]; then
fix_rw.sh
elif [ "${shortname}" == "sdtd" ]; then
fix_sdtd.sh
elif [ "${shortname}" == "sfc" ]; then
fix_sfc.sh
elif [ "${shortname}" == "sof2" ]; then
fix_sof2.sh
elif [ "${shortname}" == "squad" ]; then
fix_squad.sh
elif [ "${shortname}" == "st" ]; then
fix_st.sh
elif [ "${shortname}" == "tf2" ]; then
fix_tf2.sh
elif [ "${shortname}" == "terraria" ]; then
fix_terraria.sh
elif [ "${shortname}" == "ts3" ]; then
fix_ts3.sh
elif [ "${shortname}" == "mcb" ]; then
fix_mcb.sh
elif [ "${shortname}" == "mta" ]; then
fix_mta.sh
elif [ "${shortname}" == "unt" ]; then
fix_unt.sh
elif [ "${shortname}" == "vh" ]; then
fix_vh.sh
elif [ "${shortname}" == "wurm" ]; then
fix_wurm.sh
elif [ "${shortname}" == "zmr" ]; then
fix_zmr.sh
if grep -qEe "(^|\s)${shortname}(\s|$)" <<< "${apply_pre_start_fix[@]}"; then
fn_apply_fix "pre start" "${shortname}"
fi
fi
# Fixes that are run on install only.
if [ "${commandname}" == "INSTALL" ]; then
if [ "${shortname}" == "av" ] || [ "${shortname}" == "cmw" ] || [ "${shortname}" == "kf" ] || [ "${shortname}" == "kf2" ] || [ "${shortname}" == "lo" ] || [ "${shortname}" == "onset" ] || [ "${shortname}" == "ro" ] || [ "${shortname}" == "samp" ] || [ "${shortname}" == "ut2k4" ] || [ "${shortname}" == "ut" ] || [ "${shortname}" == "ut3" ]; then
if grep -qEe "(^|\s)${shortname}(\s|$)" <<< "${apply_post_install_fix[@]}"; then
echo -e ""
echo -e "${lightyellow}Applying Post-Install Fixes${default}"
echo -e "================================="
fn_sleep_time
postinstall=1
if [ "${shortname}" == "av" ]; then
fix_av.sh
elif [ "${shortname}" == "kf" ]; then
fix_kf.sh
elif [ "${shortname}" == "kf2" ]; then
fix_kf2.sh
elif [ "${shortname}" == "lo" ]; then
fix_lo.sh
elif [ "${shortname}" == "ro" ]; then
fix_ro.sh
elif [ "${shortname}" == "samp" ]; then
fix_samp.sh
elif [ "${shortname}" == "ut2k4" ]; then
fix_ut2k4.sh
elif [ "${shortname}" == "ut" ]; then
fix_ut.sh
elif [ "${shortname}" == "ut3" ]; then
fix_ut3.sh
else
fn_print_information_nl "No fixes required."
fi
fn_apply_fix "post install" "${shortname}"
fi
fi

Loading…
Cancel
Save