Browse Source

fix: handle invalid directory paths

The code now checks if the server files or system directory exist before proceeding. If either directory does not exist, an error message is printed and the script exits.
pull/4262/head
Daniel Gibbs 2 years ago
parent
commit
369f52771a
  1. 16
      lgsm/modules/check_system_dir.sh

16
lgsm/modules/check_system_dir.sh

@ -7,16 +7,18 @@
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ "${commandname}" != "VALIDATE" ]; then
checkdir="${serverfiles}"
else
checkdir="${systemdir}"
if [ ! -d "${serverfiles}" ]; then
fn_print_fail_nl "Cannot access ${serverfiles}: No such directory"
if [ -d "${lgsmlogdir}" ]; then
fn_script_log_fatal "Cannot access ${serverfiles}: No such directory."
fi
core_exit.sh
fi
if [ ! -d "${checkdir}" ]; then
fn_print_fail_nl "Cannot access ${checkdir}: No such directory"
if [ ! -d "${systemdir}" ]; then
fn_print_fail_nl "Cannot access ${systemdir}: No such directory"
if [ -d "${lgsmlogdir}" ]; then
fn_script_log_fatal "Cannot access ${checkdir}: No such directory."
fn_script_log_fatal "Cannot access ${systemdir}: No such directory."
fi
core_exit.sh
fi

Loading…
Cancel
Save