forked from Hypro999/racy-django
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_cert.sh
executable file
·62 lines (48 loc) · 1.31 KB
/
get_cert.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e
read -p "Enter domains (example.com www.example.com): " domains
read -p "Enter an email: " email
domain_args=""
for domain in $domains; do
if [ -z "$domain_args" ]; then
domain_args="$domain"
else
domain_args="$domain_args, $domain"
fi
done
conf_cert() {
mkdir -p /etc/letsencrypt
cat > /etc/letsencrypt/cli.ini <<EOF
# Uncomment to use the staging/testing server - avoids rate limiting.
# server = https://acme-staging.api.letsencrypt.org/directory
# Use a 4096 bit RSA key instead of 2048.
rsa-key-size = 4096
# Set email and domains.
email = $email
domains = $domain_args
# Text interface.
text = True
# Suppress the Terms of Service agreement interaction.
agree-tos = True
EOF
certbot certonly --standalone
for domain in $domains; do
privkey="/etc/letsencrypt/live/$domain/privkey.pem"
cert="/etc/letsencrypt/live/$domain/cert.pem"
if [ -f $privkey ] && [ -f $cert ]; then
echo "Found keys for $domain"
cp $privkey ./project/privkey.pem
cp $cert ./project/cert.pem
else
echo "No Let's Encrypt keys found for $domain"
fi
done
}
if command -v certbot &> /dev/null
then
conf_cert
else
echo "Installing certbot..."
sudo apt install certbot -y
conf_cert
fi