sourceguardian.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
  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 -r 'echo PHP_VERSION;'`
  14. PHP_main_ver=${PHP_detail_ver%.*}
  15. phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
  16. if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]] || [ "${TARGET_ARCH}" == "armv8" ]; then
  17. [ ! -e sourceguardian ] && mkdir sourceguardian
  18. if [ "${TARGET_ARCH}" == "armv8" ]; then
  19. tar xzf loaders.linux-aarch64.tar.gz -C sourceguardian
  20. else
  21. tar xzf loaders.linux-${SYS_BIT_c}.tar.gz -C sourceguardian
  22. fi
  23. [ -e "${php_install_dir}/bin/phpize" ] && [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
  24. if [ -z "`echo ${phpExtensionDir} | grep 'non-zts'`" ]; then
  25. /bin/mv sourceguardian/ixed.${PHP_main_ver}ts.lin ${phpExtensionDir}
  26. extension="ixed.${PHP_main_ver}ts.lin"
  27. else
  28. /bin/mv sourceguardian/ixed.${PHP_main_ver}.lin ${phpExtensionDir}
  29. extension="ixed.${PHP_main_ver}.lin"
  30. fi
  31. if [ -f "${phpExtensionDir}/ixed.${PHP_main_ver}.lin" ]; then
  32. echo "extension=${extension}" > ${php_install_dir}/etc/php.d/02-sourceguardian.ini
  33. echo "${CSUCCESS}PHP SourceGuardian module installed successfully! ${CEND}"
  34. rm -rf sourceguardian
  35. fi
  36. else
  37. echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support SourceGuardian! ${CEND}";
  38. fi
  39. popd > /dev/null
  40. fi
  41. }
  42. Uninstall_SourceGuardian() {
  43. if [ -e "${php_install_dir}/etc/php.d/02-sourceguardian.ini" ]; then
  44. rm -f ${php_install_dir}/etc/php.d/02-sourceguardian.ini
  45. echo; echo "${CMSG}PHP SourceGuardian module uninstall completed${CEND}"
  46. else
  47. echo; echo "${CWARNING}PHP SourceGuardian module does not exist! ${CEND}"
  48. fi
  49. }