install-fm.sh 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # Checking root permissions
  3. if [ "x$(id -u)" != 'x0' ]; then
  4. echo "Error: Script can be run executed only by root"
  5. exit 10
  6. fi
  7. if [ -z "$HESTIA" ]; then
  8. HESTIA="/usr/local/hestia"
  9. fi
  10. user='admin'
  11. fm_error='no'
  12. source $HESTIA/func/main.sh
  13. if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
  14. echo "Error: Hestia environment vars not present"
  15. exit 2
  16. fi
  17. FM_INSTALL_DIR="$HESTIA/web/fm"
  18. FM_V="7.4.1"
  19. FM_FILE="filegator_v${FM_V}.zip"
  20. FM_URL="https://github.com/filegator/filegator/releases/download/v${FM_V}/${FM_FILE}"
  21. COMPOSER_BIN="$HOMEDIR/$user/.composer/composer"
  22. if [ ! -f "$COMPOSER_BIN" ]; then
  23. $BIN/v-add-user-composer "$user"
  24. if [ $? -ne 0 ]; then
  25. $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>.'
  26. fm_error='yes'
  27. fi
  28. fi
  29. if [ "$fm_error" != "yes" ]; then
  30. rm --recursive --force "$FM_INSTALL_DIR"
  31. mkdir -p "$FM_INSTALL_DIR"
  32. cd "$FM_INSTALL_DIR"
  33. [ ! -f "${FM_INSTALL_DIR}/${FM_FILE}" ] &&
  34. wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}"
  35. unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}"
  36. mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
  37. rm --recursive --force ${FM_INSTALL_DIR}/filegator
  38. [[ -f "${FM_INSTALL_DIR}/${FM_FILE}" ]] && rm "${FM_INSTALL_DIR}/${FM_FILE}"
  39. cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"
  40. chown $user: -R "${FM_INSTALL_DIR}"
  41. # Check if php7.3 is available and run the installer
  42. if [ -f "/usr/bin/php7.3" ]; then
  43. COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php7.3 $COMPOSER_BIN --quiet --no-dev install
  44. if [ $? -ne 0 ]; then
  45. $BIN/v-add-user-notification admin 'File Manager installation failed!' '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>.'
  46. fm_error="yes"
  47. fi
  48. else
  49. $BIN/v-add-user-notification admin 'File Manager installation failed!' '<b>Unable to proceed with installation of File Manager.</b><br><br>Package <b>php7.3-cli</b> is missing from your system. Please check your PHP installation and environment settings.'
  50. fm_error="yes"
  51. fi
  52. if [ "$fm_error" != "yes" ]; then
  53. chown root: -R "${FM_INSTALL_DIR}"
  54. chown $user: "${FM_INSTALL_DIR}/private"
  55. chown $user: "${FM_INSTALL_DIR}/private/logs"
  56. chown $user: "${FM_INSTALL_DIR}/repository"
  57. fi
  58. fi