install-fm.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. source $HESTIA/install/upgrade/upgrade.conf
  14. if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
  15. echo "Error: Hestia environment vars not present"
  16. exit 2
  17. fi
  18. FM_INSTALL_DIR="$HESTIA/web/fm"
  19. FM_FILE="filegator_latest"
  20. FM_URL="https://github.com/filegator/static/raw/master/builds/filegator_latest.zip"
  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 <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on 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}" ] && wget "$FM_URL" --quiet -O "${FM_INSTALL_DIR}/${FM_FILE}.zip"
  34. unzip -qq "${FM_INSTALL_DIR}/${FM_FILE}.zip"
  35. mv --force ${FM_INSTALL_DIR}/filegator/* "${FM_INSTALL_DIR}"
  36. rm --recursive --force ${FM_INSTALL_DIR}/${FM_FILE}
  37. [[ -f "${FM_INSTALL_DIR}/${FM_FILE}" ]] && rm "${FM_INSTALL_DIR}/${FM_FILE}"
  38. cp --recursive --force ${HESTIA_INSTALL_DIR}/filemanager/filegator/* "${FM_INSTALL_DIR}"
  39. chown $user: -R "${FM_INSTALL_DIR}"
  40. # Check if php7.3 is available and run the installer
  41. if [ -f "/usr/bin/php7.3" ]; then
  42. COMPOSER_HOME="$HOMEDIR/$user/.config/composer" user_exec /usr/bin/php7.3 $COMPOSER_BIN --quiet --no-dev install
  43. if [ $? -ne 0 ]; then
  44. $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 <a href="https://github.com/hestiacp/hestiacp/issues" target="_blank">open an issue on GitHub</a>.'
  45. fm_error="yes"
  46. fi
  47. else
  48. $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.'
  49. fm_error="yes"
  50. fi
  51. if [ "$fm_error" != "yes" ]; then
  52. chown root: -R "${FM_INSTALL_DIR}"
  53. chown $user: "${FM_INSTALL_DIR}/private"
  54. chown $user: "${FM_INSTALL_DIR}/private/logs"
  55. chown $user: "${FM_INSTALL_DIR}/repository"
  56. fi
  57. fi