Skip to content

Commit 2f496b6

Browse files
authored
Improve error handling for Maldet installation
Enhanced error handling during Maldet installation process.
1 parent 11834cc commit 2f496b6

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

scripts/install/tools/security/maldet.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@ source /usr/local/bin/enginescript/scripts/functions/shared/enginescript-common.
2020

2121
# Maldet Install
2222
cd /usr/local/src || { echo "Error: Failed to change to /usr/local/src" >&2; exit 1; }
23-
download_and_extract "https://www.rfxn.com/downloads/maldetect-current.tar.gz" "/usr/local/src/maldetect-current.tar.gz" "/usr/local/src"
24-
cd /usr/local/src/maldetect-*/ || { echo "Error: Failed to locate extracted maldetect directory in /usr/local/src" >&2; exit 1; }
23+
download_and_extract "https://www.rfxn.com/downloads/maldetect-current.tar.gz" "/usr/local/src/maldetect-current.tar.gz" "/usr/local/src" || { echo "Error: Failed to download and extract Maldet from https://www.rfxn.com/downloads/maldetect-current.tar.gz" >&2; exit 1; }
24+
shopt -s nullglob
25+
maldet_dirs=(/usr/local/src/maldetect-*/)
26+
shopt -u nullglob
27+
if [ "${#maldet_dirs[@]}" -ne 1 ]; then
28+
echo "Error: Expected exactly one extracted maldetect directory in /usr/local/src, found ${#maldet_dirs[@]}" >&2
29+
exit 1
30+
fi
31+
cd "${maldet_dirs[0]}/" || { echo "Error: Failed to change to extracted maldetect directory" >&2; exit 1; }
2532
./install.sh || { echo "Error: Maldet installation failed while running install.sh" >&2; exit 1; }
2633
echo "/sys" >> /usr/local/maldetect/ignore_paths || { echo "Error: Failed to update maldetect ignore_paths" >&2; exit 1; }
2734

0 commit comments

Comments
 (0)