forked from diverso-lab/uvlhub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssl_setup.sh
executable file
·38 lines (30 loc) · 1.38 KB
/
ssl_setup.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
#!/bin/bash
while true; do
# Prompt for domain and email
echo "Enter your domain (including 'www' and '.com' or '.org' or whatever the extension). Example: www.exampledomain.com"
read domain
echo "Enter your email: "
read email
# Display a summary of the entered data and ask for confirmation
echo "Configured with the domain $domain"
echo "Configured with the email $email"
echo ""
echo "Are you sure the entered information is correct? [y/n]"
read confirm
# If the user confirms, break the loop and continue with the script. Otherwise, repeat the loop.
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
break
else
echo "Please re-enter the information."
echo ""
fi
done
# Replace the placeholder domain in the configuration file
sed -i "s/www.domain.com/$domain/g" ./nginx/nginx.dev.conf
sed -i "s/www.domain.com/$domain/g" ./nginx/nginx.prod.conf
# Run Nginx container in dev mode (only for generate SSL)
docker compose -f docker-compose.dev.yml up -d nginx
# Generate the certificate with Certbot
docker compose -f docker-compose.prod.yml run certbot certonly --webroot --webroot-path=/var/www -d $domain --email $email --agree-tos --no-eff-email --force-renewal
# Configure Nginx to use the new certificate
docker compose -f docker-compose.dev.yml down && docker compose -f docker-compose.prod.yml up -d --build