Browse Source

codacy changes

pull/3120/head
Daniel Gibbs 4 years ago
parent
commit
b513e8c8b8
  1. 72
      lgsm/functions/mods_core.sh

72
lgsm/functions/mods_core.sh

@ -570,15 +570,15 @@ fn_mod_install_liblist_gam_file(){
logentry="sed replace (dlls\\${moddll}) ${modinstalldir}/liblist.gam"
echo -en "modifying gamedll in liblist.gam..."
rpldll="s/dlls\\\\${moddll}/addons\/metamod\/dlls\/metamod.dll/g"
sed -i $rpldll ${modinstalldir}/liblist.gam
grep -q "addons/metamod/dlls/metamod.dll" ${modinstalldir}/liblist.gam
sed -i $rpldll "${modinstalldir}/liblist.gam"
grep -q "addons/metamod/dlls/metamod.dll" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out.
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal $logentry
fn_script_log_fatal ${logentry}
fn_print_fail_eol_nl
else
fn_script_log_pass $logentry
fn_script_log_pass ${logentry}
fn_print_ok_eol_nl
fi
@ -586,15 +586,15 @@ fn_mod_install_liblist_gam_file(){
logentry="sed replace (dlls\\${modso}) ${modinstalldir}/liblist.gam"
echo -en "modifying gamedll_linux in liblist.gam..."
rplso="s/dlls\/${modso}/addons\/metamod\/dlls\/metamod.so/g"
sed -i $rplso ${modinstalldir}/liblist.gam
grep -q "addons/metamod/dlls/metamod.so" ${modinstalldir}/liblist.gam
sed -i $rplso "${modinstalldir}/liblist.gam"
grep -q "addons/metamod/dlls/metamod.so" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal $logentry
fn_script_log_fatal ${logentry}
fn_print_fail_eol_nl
else
fn_script_log_pass $logentry
fn_script_log_pass ${logentry}
fn_print_ok_eol_nl
fi
@ -605,14 +605,14 @@ fn_mod_install_liblist_gam_file(){
echo -en "modifying gamedll_osx in liblist.gam..."
rpldylib="s/dlls\/${moddylib}/addons\/metamod\/dlls\/metamod.dylib/g"
sed -i $rpldylib ${modinstalldir}/liblist.gam
grep -q "addons/metamod/dlls/metamod.dylib" ${modinstalldir}/liblist.gam
grep -q "addons/metamod/dlls/metamod.dylib" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out.
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal $logentry
fn_script_log_fatal ${logentry}
fn_print_fail_eol_nl
else
fn_script_log_pass $logentry
fn_script_log_pass ${logentry}
fn_print_ok_eol_nl
fi
fi
@ -628,15 +628,15 @@ fn_mod_remove_liblist_gam_file(){
logentry="sed replace (addons/metamod/dlls/metamod.dll) ${modinstalldir}/liblist.gam"
echo -en "modifying gamedll in liblist.gam..."
rpldll="s/addons\/metamod\/dlls\/metamod.dll/dlls\\\\${moddll}/g"
sed -i $rpldll ${modinstalldir}/liblist.gam
grep -q "${moddll}" ${modinstalldir}/liblist.gam
sed -i $rpldll "${modinstalldir}/liblist.gam"
grep -q "${moddll}" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out.
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal $logentry
fn_script_log_fatal ${logentry}
fn_print_fail_eol_nl
else
fn_script_log_pass $logentry
fn_script_log_pass ${logentry}
fn_print_ok_eol_nl
fi
@ -644,15 +644,15 @@ fn_mod_remove_liblist_gam_file(){
logentry="sed replace (addons/metamod/dlls/metamod.so) ${modinstalldir}/liblist.gam"
echo -en "modifying gamedll_linux in liblist.gam..."
rplso="s/addons\/metamod\/dlls\/metamod.so/dlls\/${modso}/g"
sed -i $rplso ${modinstalldir}/liblist.gam
grep -q "${modso}" ${modinstalldir}/liblist.gam
sed -i $rplso "${modinstalldir}/liblist.gam"
grep -q "${modso}" "${modinstalldir}/liblist.gam"
exitcode=$?
# if replacement back didn't happen, error out
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal $logentry
fn_script_log_fatal ${logentry}
fn_print_fail_eol_nl
else
fn_script_log_pass $logentry
fn_script_log_pass ${logentry}
fn_print_ok_eol_nl
fi
@ -662,15 +662,15 @@ fn_mod_remove_liblist_gam_file(){
logentry="sed replace (addons/metamod/dlls/metamod.dylib) ${modinstalldir}/liblist.gam"
echo -en "modifying gamedll_osx in liblist.gam..."
rpldylib="s/addons\/metamod\/dlls\/metamod.dylib/dlls\/${moddylib}/g"
sed -i $rpldylib ${modinstalldir}/liblist.gam
grep -q "${moddylib}" ${modinstalldir}/liblist.gam
sed -i $rpldylib "${modinstalldir}/liblist.gam"
grep -q "${moddylib}" "${modinstalldir}/liblist.gam"
# if replacement back didn't happen, error out.
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal $logentry
fn_script_log_fatal ${logentry}
fn_print_fail_eol_nl
else
fn_script_log_pass $logentry
fn_script_log_pass ${logentry}
fn_print_ok_eol_nl
fi
fi
@ -683,30 +683,30 @@ fn_mod_install_amxmodx_file(){
# since it does exist, is the entry already in plugins.ini
logentry="line (linux addons/amxmodx/dlls/amxmodx_mm_i386.so) inserted into ${modinstalldir}/addons/metamod/plugins.ini"
echo -en "adding amxmodx_mm_i386.so in plugins.ini..."
grep -q "amxmodx_mm_i386.so" ${modinstalldir}/addons/metamod/plugins.ini
grep -q "amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
# file exists but the entry does not, let's add it
echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> ${modinstalldir}/addons/metamod/plugins.ini
echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal $logentry
fn_script_log_fatal ${logentry}
fn_print_fail_eol_nl
else
fn_script_log_pass $logentry
fn_script_log_pass ${logentry}
fn_print_ok_eol_nl
fi
fi
else
# create new file and add the mod to it
echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" > ${modinstalldir}/addons/metamod/plugins.ini
echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" > "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal $logentry
fn_script_log_fatal ${logentry}
fn_print_fail_eol_nl
core_exit.sh
else
fn_script_log_pass $logentry
fn_script_log_pass ${logentry}
fn_print_ok_eol_nl
fi
fi
@ -717,26 +717,26 @@ fn_mod_remove_amxmodx_file(){
# since it does exist, is the entry already in plugins.ini
logentry="line (linux addons/amxmodx/dlls/amxmodx_mm_i386.so) removed from ${modinstalldir}/addons/metamod/plugins.ini"
echo -en "removing amxmodx_mm_i386.so in plugins.ini..."
grep -q "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" ${modinstalldir}/addons/metamod/plugins.ini
grep -q "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini"
# iIs it found? If so remove it and clean up
exitcode=$?
if [ "${exitcode}" == 0 ]; then
# delete the line we inserted
sed -i '/linux addons\/amxmodx\/dlls\/amxmodx_mm_i386.so/d' ${modinstalldir}/addons/metamod/plugins.ini
sed -i '/linux addons\/amxmodx\/dlls\/amxmodx_mm_i386.so/d' "${modinstalldir}/addons/metamod/plugins.ini"
# remove empty lines
sed -i '/^$/d' ${modinstalldir}/addons/metamod/plugins.ini
sed -i '/^$/d' "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" != 0 ]; then
fn_script_log_fatal $logentry
fn_script_log_fatal ${logentry}
fn_print_fail_eol_nl
else
fn_script_log_pass $logentry
fn_script_log_pass ${logentry}
fn_print_ok_eol_nl
fi
# if file is empty, remove it.
if [ -f "${modinstalldir}/addons/metamod/plugins.ini" ]; then
rm ${modinstalldir}/addons/metamod/plugins.ini
rm "${modinstalldir}/addons/metamod/plugins.ini"
fn_script_log_pass "file removed ${modinstalldir}/addons/metamod/plugins.ini because it was empty"
fi
fi

Loading…
Cancel
Save