Browse Source

Switch to if conditions for error handling instead exit 0.

Raphael Schneeberger 5 years ago
parent
commit
d10a1e088d
1 changed files with 31 additions and 26 deletions
  1. 31 26
      install/deb/filemanager/install-fm.sh

+ 31 - 26
install/deb/filemanager/install-fm.sh

@@ -11,6 +11,7 @@ if [ -z "$HESTIA" ]; then
 fi
 
 user='admin'
+fm_error='no'
 source $HESTIA/func/main.sh
 
 if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
@@ -30,39 +31,43 @@ if [ ! -f "$COMPOSER_BIN" ]; then
     $BIN/v-add-user-composer "$user"
     if [ $? -ne 0 ]; then
         $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>.'
-        exit 0
+        fm_error='yes'
     fi
 fi
 
-rm --recursive --force "$FM_INSTALL_DIR"
-mkdir -p "$FM_INSTALL_DIR"
-cd "$FM_INSTALL_DIR"
+if [ "$fm_error" != "yes" ]; then
+    rm --recursive --force "$FM_INSTALL_DIR"
+    mkdir -p "$FM_INSTALL_DIR"
+    cd "$FM_INSTALL_DIR"
 
-[ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] && 
-    wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}"
+    [ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] && 
+        wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}"
 
-unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}"
-mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
-rm --recursive --force ${FM_INSTALL_DIR}/filegator
-[[ -f "${FM_INSTALL_DIR}/${FM_FILE}" ]] && rm "${FM_INSTALL_DIR}/${FM_FILE}"
+    unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}"
+    mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
+    rm --recursive --force ${FM_INSTALL_DIR}/filegator
+    [[ -f "${FM_INSTALL_DIR}/${FM_FILE}" ]] && rm "${FM_INSTALL_DIR}/${FM_FILE}"
 
-cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"
+    cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"
 
-chown $user: -R "${FM_INSTALL_DIR}"
+    chown $user: -R "${FM_INSTALL_DIR}"
 
-# Check if php7.3 is available and run the installer
-if [ -f "/usr/bin/php7.3" ]; then
-    COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php7.3 $COMPOSER_BIN --quiet --no-dev install
-    if [ $? -ne 0 ]; then
-        $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'
-        exit 0
+    # Check if php7.3 is available and run the installer
+    if [ -f "/usr/bin/php7.3" ]; then
+        COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php7.3 $COMPOSER_BIN --quiet --no-dev install
+        if [ $? -ne 0 ]; then
+            $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'
+            fm_error="yes"
+        fi
+    else
+        $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.'
+        fm_error="yes"
     fi
-else
-    $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.'
-    exit 0
-fi
 
-chown root: -R "${FM_INSTALL_DIR}"
-chown $user: "${FM_INSTALL_DIR}/private"
-chown $user: "${FM_INSTALL_DIR}/private/logs"
-chown $user: "${FM_INSTALL_DIR}/repository"
+    if [ "$fm_error" != "yes" ]; then
+        chown root: -R "${FM_INSTALL_DIR}"
+        chown $user: "${FM_INSTALL_DIR}/private"
+        chown $user: "${FM_INSTALL_DIR}/private/logs"
+        chown $user: "${FM_INSTALL_DIR}/repository"
+    fi
+fi