pecl_yar.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_yar() {
  11. if [ -e "${php_install_dir}/bin/phpize" ]; then
  12. pushd ${oneinstack_dir}/src > /dev/null
  13. PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
  14. PHP_main_ver=${PHP_detail_ver%.*}
  15. if [[ "${PHP_main_ver}" =~ ^7.[0-4]$|^8.0$ ]]; then
  16. phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
  17. src_url=https://pecl.php.net/get/yar-${yar_ver}.tgz && Download_src
  18. tar xzf yar-${yar_ver}.tgz
  19. pushd yar-${yar_ver} > /dev/null
  20. ${php_install_dir}/bin/phpize
  21. ./configure --with-php-config=${php_install_dir}/bin/php-config --with-curl=${curl_install_dir}
  22. make -j ${THREAD} && make install
  23. popd > /dev/null
  24. if [ -f "${phpExtensionDir}/yar.so" ]; then
  25. echo 'extension=yar.so' > ${php_install_dir}/etc/php.d/04-yar.ini
  26. echo "${CSUCCESS}PHP yar module installed successfully! ${CEND}"
  27. rm -rf yar-${yar_ver}
  28. else
  29. echo "${CFAILURE}PHP yar module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  30. fi
  31. else
  32. echo "${CWARNING}Your php ${PHP_detail_ver} does not support yar! ${CEND}";
  33. fi
  34. popd > /dev/null
  35. fi
  36. }
  37. Uninstall_pecl_yar() {
  38. if [ -e "${php_install_dir}/etc/php.d/04-yar.ini" ]; then
  39. rm -f ${php_install_dir}/etc/php.d/04-yar.ini
  40. echo; echo "${CMSG}PHP yar module uninstall completed${CEND}"
  41. else
  42. echo; echo "${CWARNING}PHP yar module does not exist! ${CEND}"
  43. fi
  44. }