initial commit
This commit is contained in:
Executable
+69
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
if ! [ -x "$(command -v docker)" ]; then
|
||||
echo 'Error: docker is not installed.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
certbot_path="./data/certbot"
|
||||
rsa_key_size=4096
|
||||
domains=(dittmar.dev gitlab.dittmar.dev cantropee.dittmar.dev)
|
||||
email="robindittmar@gmail.com" # Adding a valid address is strongly recommended
|
||||
staging=0 # Set to 1 if you're testing your setup to avoid hitting request limits
|
||||
|
||||
echo "> cleaning up data directory"
|
||||
rm -Rf $certbot_path
|
||||
|
||||
echo "> downloading recommended TLS parameters ..."
|
||||
mkdir -p "$certbot_path/conf"
|
||||
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf > "$certbot_path/conf/options-ssl-nginx.conf"
|
||||
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "$certbot_path/conf/ssl-dhparams.pem"
|
||||
|
||||
echo "> creating temporary certificates for domains $domains ..."
|
||||
certs_path="/etc/letsencrypt/live/$domains"
|
||||
mkdir -p "$certbot_path/conf/live/$domains"
|
||||
docker run --rm \
|
||||
-v $certbot_path/conf:/etc/letsencrypt \
|
||||
--entrypoint openssl \
|
||||
certbot/certbot \
|
||||
req -x509 -nodes -newkey rsa:$rsa_key_size -days 1 -keyout "$certs_path/privkey.pem" -out "$certs_path/fullchain.pem" -subj '/CN=localhost'
|
||||
|
||||
echo "> starting nginx with temporary certificates ..."
|
||||
./start-nginx.sh
|
||||
|
||||
echo "> removing temporary certificates ..."
|
||||
docker run --rm \
|
||||
-v $certbot_path/conf:/etc/letsencrypt \
|
||||
--entrypoint /bin/sh \
|
||||
certbot/certbot \
|
||||
-c "rm -Rf /etc/letsencrypt/live/$domains && \
|
||||
rm -Rf /etc/letsencrypt/archive/$domains && \
|
||||
rm -Rf /etc/letsencrypt/renewal/$domains.conf" \
|
||||
|
||||
domain_args=""
|
||||
for domain in "${domains[@]}"; do
|
||||
domain_args="$domain_args -d $domain"
|
||||
done
|
||||
|
||||
case "$email" in
|
||||
"") email_arg="--register-unsafely-without-email" ;;
|
||||
*) email_arg="--email $email" ;;
|
||||
esac
|
||||
|
||||
if [ $staging != "0" ]; then staging_arg="--staging"; fi
|
||||
|
||||
echo "> requesting letsencrypt certificate for $domains ..."
|
||||
docker run --rm \
|
||||
-v $certbot_path/conf:/etc/letsencrypt \
|
||||
-v $certbot_path/www:/var/www/certbot \
|
||||
certbot/certbot \
|
||||
certonly --webroot -w /var/www/certbot \
|
||||
$staging_arg \
|
||||
$email_arg \
|
||||
$domain_args \
|
||||
--rsa-key-size $rsa_key_size \
|
||||
--agree-tos \
|
||||
--force-renewal
|
||||
|
||||
./stop-nginx.sh
|
||||
Reference in New Issue
Block a user