2024-05-03 19:40:44 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# @file EasyEngine
|
|
|
|
# @brief Configures EasyEngine to use the CloudFlare API for configuring Let's Encrypt
|
|
|
|
|
2024-05-27 20:45:14 -07:00
|
|
|
set -Eeuo pipefail
|
2024-05-27 20:50:11 -07:00
|
|
|
trap "gum log -sl error 'Script encountered an error!'" ERR
|
2024-05-27 04:15:03 -07:00
|
|
|
|
2024-05-03 19:40:44 -07:00
|
|
|
if command -v ee > /dev/null; then
|
2024-05-27 04:15:03 -07:00
|
|
|
### Ensure secrets
|
2024-05-27 20:45:14 -07:00
|
|
|
if get-secret --exists CLOUDFLARE_EMAIL CLOUDFLARE_API_KEY; then
|
|
|
|
### Configure EasyEngine
|
2024-05-27 20:50:11 -07:00
|
|
|
gum log -sl info 'Configuring EasyEngine with CloudFlare automatic SSL insuance'
|
2024-05-27 20:45:14 -07:00
|
|
|
ee config set le-mail "$(get-secret CLOUDFLARE_EMAIL)"
|
|
|
|
ee config set cloudflare-api-key "$(get-secret CLOUDFLARE_API_KEY)"
|
|
|
|
else
|
2024-05-27 20:50:11 -07:00
|
|
|
gum log -sl info 'Skipping automated setup of LetsEncrypt with EasyEngine because either CLOUDFLARE_EMAIL or CLOUDFLARE_API_KEY are not defined'
|
2024-05-27 20:45:14 -07:00
|
|
|
fi
|
2024-05-03 19:40:44 -07:00
|
|
|
fi
|