sourceguardian.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_SourceGuardian() {
  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. phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
  16. [ ! -e sourceguardian ] && mkdir sourceguardian
  17. [ -e "loaders.linux-${ARCH}.tar.gz" ] && tar xzf loaders.linux-${ARCH}.tar.gz -C sourceguardian
  18. if [ -e "sourceguardian/ixed.${PHP_main_ver}.lin" ]; then
  19. [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
  20. if [ -z "`echo ${phpExtensionDir} | grep 'non-zts'`" ]; then
  21. /bin/mv sourceguardian/ixed.${PHP_main_ver}ts.lin ${phpExtensionDir}
  22. extension="ixed.${PHP_main_ver}ts.lin"
  23. else
  24. /bin/mv sourceguardian/ixed.${PHP_main_ver}.lin ${phpExtensionDir}
  25. extension="ixed.${PHP_main_ver}.lin"
  26. fi
  27. if [ -f "${phpExtensionDir}/ixed.${PHP_main_ver}.lin" ]; then
  28. echo "extension=${extension}" > ${php_install_dir}/etc/php.d/02-sourceguardian.ini
  29. echo "${CSUCCESS}PHP SourceGuardian module installed successfully! ${CEND}"
  30. rm -rf sourceguardian
  31. fi
  32. else
  33. echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support SourceGuardian! ${CEND}";
  34. fi
  35. popd > /dev/null
  36. fi
  37. }
  38. Uninstall_SourceGuardian() {
  39. if [ -e "${php_install_dir}/etc/php.d/02-sourceguardian.ini" ]; then
  40. rm -f ${php_install_dir}/etc/php.d/02-sourceguardian.ini
  41. echo; echo "${CMSG}PHP SourceGuardian module uninstall completed${CEND}"
  42. else
  43. echo; echo "${CWARNING}PHP SourceGuardian module does not exist! ${CEND}"
  44. fi
  45. }