1
0

composer.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_composer() {
  11. if [ -e "${php_install_dir}/bin/phpize" ]; then
  12. if [ -e "/usr/local/bin/composer" ]; then
  13. echo "${CWARNING}PHP Composer already installed! ${CEND}"
  14. else
  15. pushd ${oneinstack_dir}/src > /dev/null
  16. if [ "${OUTIP_STATE}"x == "China"x ]; then
  17. wget --no-check-certificate -c https://mirrors.aliyun.com/composer/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
  18. ${php_install_dir}/bin/php /usr/local/bin/composer config -g repo.packagist composer https://packagist.phpcomposer.com
  19. else
  20. wget --no-check-certificate -c https://getcomposer.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
  21. fi
  22. chmod +x /usr/local/bin/composer
  23. if [ -e "/usr/local/bin/composer" ]; then
  24. echo; echo "${CSUCCESS}PHP Composer installed successfully! ${CEND}"
  25. else
  26. echo; echo "${CFAILURE}PHP Composer install failed, Please try again! ${CEND}"
  27. fi
  28. popd > /dev/null
  29. fi
  30. fi
  31. }
  32. Uninstall_composer() {
  33. if [ -e "/usr/local/bin/composer" ]; then
  34. rm -f /usr/local/bin/composer
  35. echo; echo "${CMSG}Composer uninstall completed${CEND}";
  36. else
  37. echo; echo "${CWARNING}Composer does not exist! ${CEND}"
  38. fi
  39. }