| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #!/bin/bash
- # info: delete php fpm version
- # options: VERSION
- #
- # The function checks and delete a fpm php version if not used by any domain.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument definition
- version=$1
- # Includes
- source $HESTIA/func/osal.sh
- source $HESTIA/func/main.sh
- source $HESTIA/conf/hestia.conf
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- check_args '1' "$#" 'VERSION'
- php_prefix=$(osal_multiphp_php_package_prefix $version)
- # Verify php version format
- if [[ ! $version =~ ^[0-9]\.[0-9]+ ]]; then
- echo "The php version format is invalid, it should look like [0-9].[0-9]..."
- exit
- fi
- # Remove backend template
- [ -f $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl ] && rm -f $HESTIA/data/templates/web/php-fpm/PHP-${version/\./_}.tpl
- # Check if php version exists
- if [ ! $(osal_multiphp_fpm_isinstalled $version) ] && [ ! -f "$HESTIA/data/templates/$WEB_SYSTEM/PHP-$version.sh" ]; then
- echo "Version is not installed..."
- exit
- fi
- # Perform verification if read-only mode is enabled
- check_hestia_demo_mode
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- mph="$php_prefix-mbstring $php_prefix-bcmath $php_prefix-cli $php_prefix-curl
- $php_prefix-fpm $php_prefix-gd $php_prefix-intl $php_prefix-mysql
- $php_prefix-soap $php_prefix-xml $php_prefix-zip $php_prefix-mbstring
- $php_prefix-json $php_prefix-bz2 $php_prefix-pspell"
- # Check is version is 7.1 or below to add mcrypt
- if [[ `echo "$version 7.2" | awk '{print ($1 < $2)}'` == 1 ]]; then
- mph="$mph $php_prefix-mcrypt"
- fi
- # Purge php packages
- osal_execute_with_spinner osal_package_remove $mph
- # Check if uninstallation was sucessfully
- if [ $(multiphp_fpm_isinstalled $version) ]; then
- echo "Uninstallation failed, please run the following command manualy for debuging:"
- echo "$OSAL_CMD_PACKAGE_MANAGER (remove or purge) ${mph//\\n/ \\}"
- fi
- # Cleanup php folder
- etc_folder=$(osal_multiphp_etc_folder $version)
- [[ -d "$etc_folder" ]] && rm -rf "$etc_folder"
- #----------------------------------------------------------#
- # Hestia #
- #----------------------------------------------------------#
- # Logging
- log_history "removed php $version" '' 'admin'
- log_event "$OK" "$ARGUMENTS"
- exit
|