Skip to content

Commit d10a1e0

Browse files
committed
Switch to if conditions for error handling instead exit 0.
1 parent 7a22d8e commit d10a1e0

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

install/deb/filemanager/install-fm.sh

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if [ -z "$HESTIA" ]; then
1111
fi
1212

1313
user='admin'
14+
fm_error='no'
1415
source $HESTIA/func/main.sh
1516

1617
if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
@@ -30,39 +31,43 @@ if [ ! -f "$COMPOSER_BIN" ]; then
3031
$BIN/v-add-user-composer "$user"
3132
if [ $? -ne 0 ]; then
3233
$BIN/v-add-user-notification admin 'Composer installation failed!' '<b>The File Manager will not work without Composer.</b><br><br>Please try running the installer from a shell session:<br>bash $HESTIA/install/deb/filemanager/install-fm.sh<br><br>If this issue continues, please open an issue report on <a href="https://github.com/hestiacp/hestiacp/issues" target="_new"><i class="fab fa-github"></i> GitHub</a>.'
33-
exit 0
34+
fm_error='yes'
3435
fi
3536
fi
3637

37-
rm --recursive --force "$FM_INSTALL_DIR"
38-
mkdir -p "$FM_INSTALL_DIR"
39-
cd "$FM_INSTALL_DIR"
38+
if [ "$fm_error" != "yes" ]; then
39+
rm --recursive --force "$FM_INSTALL_DIR"
40+
mkdir -p "$FM_INSTALL_DIR"
41+
cd "$FM_INSTALL_DIR"
4042

41-
[ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] &&
42-
wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}"
43+
[ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] &&
44+
wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}"
4345

44-
unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}"
45-
mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
46-
rm --recursive --force ${FM_INSTALL_DIR}/filegator
47-
[[ -f "${FM_INSTALL_DIR}/${FM_FILE}" ]] && rm "${FM_INSTALL_DIR}/${FM_FILE}"
46+
unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}"
47+
mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
48+
rm --recursive --force ${FM_INSTALL_DIR}/filegator
49+
[[ -f "${FM_INSTALL_DIR}/${FM_FILE}" ]] && rm "${FM_INSTALL_DIR}/${FM_FILE}"
4850

49-
cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"
51+
cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"
5052

51-
chown $user: -R "${FM_INSTALL_DIR}"
53+
chown $user: -R "${FM_INSTALL_DIR}"
5254

53-
# Check if php7.3 is available and run the installer
54-
if [ -f "/usr/bin/php7.3" ]; then
55-
COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php7.3 $COMPOSER_BIN --quiet --no-dev install
56-
if [ $? -ne 0 ]; then
57-
$BIN/v-add-user-notification admin 'FM installation failed' 'The FileManager installation had to been aborted, please try to run the installation manualy: bash $HESTIA/install/deb/filemanager/install-fm.sh'
58-
exit 0
55+
# Check if php7.3 is available and run the installer
56+
if [ -f "/usr/bin/php7.3" ]; then
57+
COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php7.3 $COMPOSER_BIN --quiet --no-dev install
58+
if [ $? -ne 0 ]; then
59+
$BIN/v-add-user-notification admin 'FM installation failed' 'The FileManager installation had to been aborted, please try to run the installation manualy: bash $HESTIA/install/deb/filemanager/install-fm.sh'
60+
fm_error="yes"
61+
fi
62+
else
63+
$BIN/v-add-user-notification admin 'FM installation failed' 'php7.3-cli is missing on your system, the FileManager installation had to been aborted - please check your php environment.'
64+
fm_error="yes"
5965
fi
60-
else
61-
$BIN/v-add-user-notification admin 'FM installation failed' 'php7.3-cli is missing on your system, the FileManager installation had to been aborted - please check your php environment.'
62-
exit 0
63-
fi
6466

65-
chown root: -R "${FM_INSTALL_DIR}"
66-
chown $user: "${FM_INSTALL_DIR}/private"
67-
chown $user: "${FM_INSTALL_DIR}/private/logs"
68-
chown $user: "${FM_INSTALL_DIR}/repository"
67+
if [ "$fm_error" != "yes" ]; then
68+
chown root: -R "${FM_INSTALL_DIR}"
69+
chown $user: "${FM_INSTALL_DIR}/private"
70+
chown $user: "${FM_INSTALL_DIR}/private/logs"
71+
chown $user: "${FM_INSTALL_DIR}/repository"
72+
fi
73+
fi

0 commit comments

Comments
 (0)