You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
3.3 KiB

  1. #!/bin/bash
  2. # Colors
  3. CSI="\\033["
  4. CEND="${CSI}0m"
  5. CRED="${CSI}1;31m"
  6. CGREEN="${CSI}1;32m"
  7. # Check if user is root
  8. if [ "$(id -u)" != "0" ]; then
  9. echo "Error: You must be root to run this script, please use the root user to install the software."
  10. exit 1
  11. fi
  12. if [ ! -f $HOME/.acme.sh/acme.sh ]; then
  13. echo ""
  14. echo "installing acme.sh"
  15. echo ""
  16. wget -O - https://get.acme.sh | sh
  17. fi
  18. # ACME validation choice
  19. echo ""
  20. echo "Welcome to the ee-acme-sh installation."
  21. echo ""
  22. BASHRC_EE_ACME_FIRST_RELEASE=$(grep "ee-acme" $HOME/.bashrc)
  23. BASHRC_EE_ACME_LAST_RELEASE=$(grep "ee-acme.sh" $HOME/.bashrc)
  24. # install ee-acme-cf or ee-acme-standalone
  25. if [ -f $HOME/.ee-acme/ee-acme ] && [ -z "$BASHRC_EE_ACME_LAST_RELEASE" ]; then
  26. rm -rf $HOME/.ee-acme/*
  27. echo 'alias ee-acme="/root/.ee-acme/ee-acme.sh"' >> $HOME/.ee-acme/ee-acme
  28. wget -qO $HOME/.ee-acme/ee-acme.sh https://raw.githubusercontent.com/VirtuBox/ee-acme-sh/master/script/ee-acme.sh
  29. chmod +x $HOME/.ee-acme/ee-acme.sh
  30. elif [ -x $HOME/.ee-acme/ee-acme.sh ]; then
  31. rm $HOME/.ee-acme/ee-acme.sh
  32. wget -qO $HOME/.ee-acme/ee-acme.sh https://raw.githubusercontent.com/VirtuBox/ee-acme-sh/master/script/ee-acme.sh
  33. chmod +x $HOME/.ee-acme/ee-acme.sh
  34. elif [ ! -d $HOME/.ee-acme ]; then
  35. mkdir -p $HOME/.ee-acme
  36. wget -qO $HOME/.ee-acme/ee-acme.sh https://raw.githubusercontent.com/VirtuBox/ee-acme-sh/master/script/ee-acme.sh
  37. chmod +x $HOME/.ee-acme/ee-acme.sh
  38. if [ -z "$BASHRC_EE_ACME_FIRST_RELEASE" ] && [ -z "$BASHRC_EE_ACME_LAST_RELEASE" ]; then
  39. echo 'alias ee-acme="/root/.ee-acme/ee-acme.sh"' >> $HOME/.bashrc
  40. fi
  41. fi
  42. # We're done !
  43. echo ""
  44. echo -e " ${CGREEN}ee-acme-sh was installed successfully !${CEND}"
  45. echo ""
  46. echo "You need to run the following command to enable ee-acme-sh"
  47. echo ""
  48. echo -e " ${CGREEN}source .bashrc${CEND}"
  49. echo ""
  50. echo "Usage: ee-acme [type] <domain> [mode]"
  51. echo " Types:"
  52. echo " -d, --domain <domain_name> ..... for domain.tld + www.domain.tld"
  53. echo " -s, --subdomain <subdomain_name> ....... for sub.domain.tld"
  54. echo " -w, --wildcard <domain_name> ..... for domain.tld + *.domain.tld"
  55. echo " Modes:"
  56. echo " --standalone ..... acme challenge in standalone mode"
  57. echo " --cf ..... acme challenge in dns mode with Cloudflare"
  58. echo " Options:"
  59. echo " --cert-only ... do not change nginx configuration, only display it"
  60. echo " --admin ... secure easyengine backend with the certificate"
  61. echo " -h, --help, help ... displays this help information"
  62. echo "Examples:"
  63. echo ""
  64. echo "domain.tld + www.domain.tld in standalone mode :"
  65. echo " ee-acme -d domain.tld --standalone"
  66. echo ""
  67. echo "sub.domain.tld in dns mode with Cloudflare :"
  68. echo " ee-acme -s sub.domain.tld --cf"
  69. echo ""
  70. echo "wildcard certificate for domain.tld in dns mode with Cloudflare :"
  71. echo " ee-acme -w domain.tld --cf"
  72. echo ""
  73. echo "domain.tld + www.domain.tld in standalone mode without editing Nginx configuration :"
  74. echo " ee-acme -d domain.tld --standalone --cert-only"
  75. echo ""
  76. echo "sub.domain.tld in standalone mode to secure easyengine backend on port 22222 :"
  77. echo " ee-acme -s sub.domain.tld --standalone --admin"
  78. echo ""