init-certificate.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. if ! [ -x "$(command -v docker-compose)" ]; then
  3. echo 'Error: docker-compose is not installed.' >&2
  4. exit 1
  5. fi
  6. data_path="./data/certbot"
  7. read -p "Enter domain name (eg. www.example.com): " domains
  8. if [ -d "$data_path" ]; then
  9. read -p "Existing data found. Continue and replace existing certificate? (y/N) " decision
  10. if [ "$decision" != "Y" ] && [ "$decision" != "y" ]; then
  11. exit
  12. fi
  13. fi
  14. if [ ! -e "$data_path/conf/options-ssl-nginx.conf" ] || [ ! -e "$data_path/conf/ssl-dhparams.pem" ]; then
  15. echo "### Downloading recommended TLS parameters ..."
  16. mkdir -p "$data_path/conf"
  17. curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf > "$data_path/conf/options-ssl-nginx.conf"
  18. curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "$data_path/conf/ssl-dhparams.pem"
  19. echo
  20. fi
  21. echo "### Requesting Let's Encrypt certificate for $domains ..."
  22. #Join $domains to -d args
  23. domain_args=""
  24. for domain in "${domains[@]}"; do
  25. domain_args="$domain_args -d $domain"
  26. done
  27. docker-compose run -p 80:80 --rm --entrypoint "\
  28. sh -c \"certbot certonly --standalone \
  29. --register-unsafely-without-email \
  30. $domain_args \
  31. --agree-tos \
  32. --force-renewal && \
  33. ln -fs /etc/letsencrypt/live/$domains/ /etc/letsencrypt/active\"" certbot
  34. echo
  35. echo "After running 'docker-compose up --detach' you can share your proxy as: https://signal.tube/#$domains"