fediparty/letsencrypt_authenticator.sh

26 lines
888 B
Bash
Raw Normal View History

2018-10-17 20:27:04 +00:00
#!/bin/bash
# source https://www.harenslak.nl/blog/https-letsencrypt-gitlab-hugo
mkdir -p $CI_PROJECT_DIR/source/_static/.well-known/acme-challenge
echo $CERTBOT_VALIDATION > $CI_PROJECT_DIR/source/_static/.well-known/acme-challenge/$CERTBOT_TOKEN
git add $CI_PROJECT_DIR/source/_static/.well-known/acme-challenge/$CERTBOT_TOKEN
2018-10-17 20:27:04 +00:00
git commit -m "GitLab runner - Added certbot challenge file for certificate renewal"
git push https://$GITLAB_USER_LOGIN:$CERTBOT_RENEWAL_GIT_TOKEN@gitlab.com/fediverse/fediverse.gitlab.io.git HEAD:master
interval_sec=15
2018-11-08 14:44:22 +00:00
max_tries=80 # ~20 minutes
2018-10-17 20:27:04 +00:00
n_tries=0
while [ $n_tries -le $max_tries ]
do
status_code=$(curl -L --write-out "%{http_code}\n" --silent --output /dev/null https://fediverse.party/.well-known/acme-challenge/$CERTBOT_TOKEN)
2018-11-08 14:44:22 +00:00
if [ $status_code -eq 200 ]; then
2018-10-17 20:27:04 +00:00
exit 0
fi
n_tries=$((n_tries+1))
sleep $interval_sec
done
exit 1