1
0

pecl_imap.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_pecl_imap() {
  11. if [ -e "${php_install_dir}/bin/phpize" ]; then
  12. pushd ${oneinstack_dir}/src > /dev/null
  13. if [ "${PM}" == 'yum' ]; then
  14. if [ "${RHEL_ver}" == '9' ]; then
  15. cat > /etc/yum.repos.d/remi.repo << EOF
  16. [remi]
  17. name=Remi's RPM repository for Enterprise Linux 9 - \$basearch
  18. mirrorlist=http://cdn.remirepo.net/enterprise/9/remi/\$basearch/mirror
  19. enabled=0
  20. gpgcheck=0
  21. EOF
  22. dnf -y --enablerepo=remi install uw-imap-devel
  23. else
  24. yum -y install libc-client-devel
  25. [ ! -e /usr/lib/libc-client.so ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
  26. fi
  27. else
  28. apt-get -y install libc-client2007e-dev
  29. fi
  30. phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
  31. PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
  32. src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
  33. tar xzf php-${PHP_detail_ver}.tar.gz
  34. pushd php-${PHP_detail_ver}/ext/imap > /dev/null
  35. ${php_install_dir}/bin/phpize
  36. ./configure --with-php-config=${php_install_dir}/bin/php-config --with-kerberos --with-imap --with-imap-ssl
  37. make -j ${THREAD} && make install
  38. popd > /dev/null
  39. if [ -f "${phpExtensionDir}/imap.so" ]; then
  40. echo 'extension=imap.so' > ${php_install_dir}/etc/php.d/04-imap.ini
  41. echo "${CSUCCESS}PHP imap module installed successfully! ${CEND}"
  42. rm -rf php-${PHP_detail_ver}
  43. else
  44. echo "${CFAILURE}PHP imap module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  45. fi
  46. popd > /dev/null
  47. fi
  48. }
  49. Uninstall_pecl_imap() {
  50. if [ -e "${php_install_dir}/etc/php.d/04-imap.ini" ]; then
  51. rm -f ${php_install_dir}/etc/php.d/04-imap.ini
  52. echo; echo "${CMSG}PHP imap module uninstall completed${CEND}"
  53. else
  54. echo; echo "${CWARNING}PHP imap module does not exist! ${CEND}"
  55. fi
  56. }