Skip to content

Commit

Permalink
add get-ssl-certs.sh scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
thaiminhpv committed Jul 15, 2023
1 parent be1bbf4 commit eff0b10
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
secret.yaml
tls-cert.yaml
tls-cert.yaml
cloudflare-certbot.ini
*.pem
39 changes: 39 additions & 0 deletions scripts/get-ssl-certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
set -x
set -e

if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi

if [ ! -f ./cloudflare-certbot.ini ]; then
echo "Please create cloudflare-certbot.ini"
exit
fi

# check if certbot is installed
if ! [ -x "$(command -v certbot)" ]; then
echo "Certbot is not installed. Installing..."
sudo apt install snapd -y
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo snap set certbot trust-plugin-with-root=ok
sudo snap install certbot-dns-cloudflare
fi

cat <<EOF > ./cloudflare-certbot.ini
# Cloudflare API credentials used by Certbot
dns_cloudflare_api_token = abcxyz
EOF

sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials \
./cloudflare-certbot.ini -d '*.efiss.tech' -d 'efiss.tech'

mkdir -p certs/
sudo cp -L /etc/letsencrypt/live/efiss.tech/fullchain.pem certs/
sudo cp -L /etc/letsencrypt/live/efiss.tech/privkey.pem certs/

sudo chown -R $USER:$USER certs
sudo chmod -R 755 certs

0 comments on commit eff0b10

Please sign in to comment.