-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from hngprojects/main
Update staging with changes from main
- Loading branch information
Showing
5 changed files
with
81 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# Variables | ||
DOMAINS=( | ||
"api-golang.boilerplate.hng.tech" # prod | ||
"deployment.api-golang.boilerplate.hng.tech" # dev | ||
"staging.api-golang.boilerplate.hng.tech" # staging | ||
) | ||
EMAIL="[email protected]" # Used for certbot notifications and recovery | ||
|
||
# Update package lists | ||
sudo apt update | ||
|
||
# Install Snapd if not already installed | ||
sudo apt install -y snapd | ||
|
||
# Install the core snap & Ensure Snapd is up to date | ||
sudo snap install core | ||
sudo snap refresh core | ||
|
||
# Remove any existing Certbot installations | ||
sudo apt-get remove certbot | ||
|
||
# Install Certbot using Snap | ||
sudo snap install --classic certbot | ||
|
||
# Create a symbolic link to make Certbot command globally available | ||
sudo ln -s /snap/bin/certbot /usr/bin/certbot | ||
|
||
# Obtain SSL certificates for each domain | ||
for DOMAIN in "${DOMAINS[@]}"; do | ||
echo "Configuring SSL for domain: $DOMAIN" | ||
sudo certbot --nginx -d "$DOMAIN" --non-interactive --agree-tos --email "$EMAIL" | ||
done | ||
|
||
# Set up automatic renewal of the certificates | ||
sudo crontab -l | { cat; echo "0 0,12 * * * root certbot renew --quiet"; } | sudo crontab - | ||
|
||
# Display the configured domains | ||
for DOMAIN in "${DOMAINS[@]}"; do | ||
echo "SSL certificate configured for: https://$DOMAIN" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters