v-delete-web-php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. # info: delete php fpm version
  3. # options: VERSION
  4. #
  5. # The function checks and delete a fpm php version if not used by any domain.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. version=$1
  11. # Includes
  12. source $HESTIA/func/osal.sh
  13. source $HESTIA/func/main.sh
  14. source $HESTIA/conf/hestia.conf
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. check_args '1' "$#" 'VERSION'
  19. php_prefix=$(multiphp_php_package_prefix $version)
  20. # Verify php version format
  21. if [[ ! $version =~ ^[0-9]\.[0-9]+ ]]; then
  22. echo "The php version format is invalid, it should look like [0-9].[0-9]..."
  23. exit
  24. fi
  25. # Remove backend template
  26. [ -f $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl ] && rm -f $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl
  27. # Check if php version exists
  28. if [ ! $(multiphp_fpm_isinstalled $version) ] && [ ! -f "$HESTIA/data/templates/$WEB_SYSTEM/PHP-$version.sh" ]; then
  29. echo "Version is not installed..."
  30. exit
  31. fi
  32. # Perform verification if read-only mode is enabled
  33. check_hestia_demo_mode
  34. #----------------------------------------------------------#
  35. # Action #
  36. #----------------------------------------------------------#
  37. mph="$php_prefix-mbstring $php_prefix-bcmath $php_prefix-cli $php_prefix-curl
  38. $php_prefix-fpm $php_prefix-gd $php_prefix-intl $php_prefix-mysql
  39. $php_prefix-soap $php_prefix-xml $php_prefix-zip $php_prefix-mbstring
  40. $php_prefix-json $php_prefix-bz2 $php_prefix-pspell"
  41. # Check is version is 7.1 or below to add mcrypt
  42. if [[ `echo "$version 7.2" | awk '{print ($1 < $2)}'` == 1 ]]; then
  43. mph="$mph $php_prefix-mcrypt"
  44. fi
  45. # Purge php packages
  46. execute_with_spinner package_remove $mph
  47. # Check if uninstallation was sucessfully
  48. if [ $(multiphp_fpm_isinstalled $version) ]; then
  49. echo "Uninstallation failed, please run the following command manualy for debuging:"
  50. echo "$CMD_PACKAGE_MANAGER (remove or purge) ${mph//\\n/ \\}"
  51. fi
  52. # Cleanup php folder
  53. etc_folder=$(multiphp_etc_folder $version)
  54. [[ -d "$etc_folder" ]] && rm -rf "$etc_folder"
  55. #----------------------------------------------------------#
  56. # Hestia #
  57. #----------------------------------------------------------#
  58. # Logging
  59. log_history "removed php $version" '' 'admin'
  60. log_event "$OK" "$ARGUMENTS"
  61. exit