Skip to content

Commit

Permalink
cloudflare selected and streamline propagation seconds (home-assistan…
Browse files Browse the repository at this point in the history
…t#1099)

* cloudflare-selected

* Update config.json

* Update README.md

* Update CHANGELOG.md

* Update README.md

* Update run.sh

* Fix lint

* Update run.sh

* address comments
  • Loading branch information
pvizeli authored Feb 18, 2020
1 parent b645b7a commit c0d92d3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 46 deletions.
5 changes: 5 additions & 0 deletions letsencrypt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.6

- Streamline propagation seconds
- Add propagation seconds to CloudFlare / option selection

## 4.5

- Update cerbot to 1.2.0
Expand Down
6 changes: 3 additions & 3 deletions letsencrypt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ In addition add the fields according to the credentials required by your dns pro
```yaml
propagation_seconds: 60
cloudflare_email: ''
cloudflare_api_key: ''
cloudflare_api_token: ''
Expand Down Expand Up @@ -88,7 +89,6 @@ sakuracloud_api_secret: ''
netcup_customer_id: ''
netcup_api_key: ''
netcup_api_password: ''
netcup_propagation_seconds: 60
```
## Example Configurations
Expand Down Expand Up @@ -154,14 +154,14 @@ However, due to some shortcomings in Cloudflare’s implementation of Tokens, To
Example credentials file using restricted API Token (recommended):
```yaml
dns:
provider: dns-clooudflare
provider: dns-cloudflare
dns_cloudflare_api_token: 0123456789abcdef0123456789abcdef01234
```

Example credentials file using Global API Key (not recommended):
```yaml
dns:
provider: dns-clooudflare
provider: dns-cloudflare
dns_cloudflare_email: cloudflare@example.com
dns_cloudflare_api_key: 0123456789abcdef0123456789abcdef01234
```
Expand Down
6 changes: 3 additions & 3 deletions letsencrypt/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Let's Encrypt",
"version": "4.5",
"version": "4.6",
"slug": "letsencrypt",
"description": "Manage certificate from Let's Encrypt",
"url": "https://github.com/home-assistant/hassio-addons/tree/master/letsencrypt",
Expand Down Expand Up @@ -30,6 +30,7 @@
"challenge": "list(dns|http)",
"dns": {
"provider": "list(dns-cloudflare|dns-cloudxns|dns-digitalocean|dns-dnsimple|dns-dnsmadeeasy|dns-gehirn|dns-google|dns-linode|dns-luadns|dns-nsone|dns-ovh|dns-rfc2136|dns-route53|dns-sakuracloud|dns-netcup)?",
"propagation_seconds": "int(60,3600)?",
"cloudflare_email": "email?",
"cloudflare_api_key": "str?",
"cloudflare_api_token": "str?",
Expand Down Expand Up @@ -62,8 +63,7 @@
"sakuracloud_api_secret": "str?",
"netcup_customer_id": "str?",
"netcup_api_key": "str?",
"netcup_api_password": "str?",
"netcup_propagation_seconds": "int(60,3600)?"
"netcup_api_password": "str?"
}
},
"image": "homeassistant/{arch}-addon-letsencrypt"
Expand Down
89 changes: 49 additions & 40 deletions letsencrypt/data/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ DOMAINS=$(bashio::config 'domains')
KEYFILE=$(bashio::config 'keyfile')
CERTFILE=$(bashio::config 'certfile')
CHALLENGE=$(bashio::config 'challenge')
DNS_PROVIDER=$(bashio::config 'dns.provider')

if [[ "$CHALLENGE" == "dns" ]]; then
bashio::log.info "Selected DNS Provider: $(bashio::config 'dns.provider')"
bashio::log.info "Selected DNS Provider: $(bashio::config 'dns.provider')"

PROPAGATION_SECONDS=60
if bashio::config.exists 'dns.propagation_seconds'; then
PROPAGATION_SECONDS="$(bashio::config 'dns.propagation_seconds')"
fi
bashio::log.info "Use propagation seconds: ${PROPAGATION_SECONDS}"
else
bashio::log.info "Selected http verification"
bashio::log.info "Selected http verification"
fi

CERT_DIR=/data/letsencrypt
Expand All @@ -23,38 +28,35 @@ chmod +x /run.sh
touch /data/dnsapikey
PROVIDER_ARGUMENTS=()

echo -e "dns_cloudflare_email = $(bashio::config 'dns.cloudflare_email')\n" \
"dns_cloudflare_api_key = $(bashio::config 'dns.cloudflare_api_key')\n" \
"dns_cloudflare_api_token = $(bashio::config 'dns.cloudflare_api_token')\n" \
"dns_cloudxns_api_key = $(bashio::config 'dns.cloudxns_api_key')\n" \
"dns_cloudxns_secret_key = $(bashio::config 'dns.cloudxns_secret_key')\n" \
"dns_digitalocean_token = $(bashio::config 'dns.digitalocean_token')\n" \
"dns_dnsimple_token = $(bashio::config 'dns.dnsimple_token')\n" \
"dns_dnsmadeeasy_api_key = $(bashio::config 'dns.dnsmadeeasy_api_key')\n" \
"dns_dnsmadeeasy_secret_key = $(bashio::config 'dns.dnsmadeeasy_secret_key')\n" \
"dns_gehirn_api_token = $(bashio::config 'dns.gehirn_api_token')\n" \
"dns_gehirn_api_secret = $(bashio::config 'dns.gehirn_api_secret')\n" \
"dns_linode_key = $(bashio::config 'dns.linode_key')\n" \
"dns_linode_version = $(bashio::config 'dns.linode_version')\n" \
"dns_luadns_email = $(bashio::config 'dns.luadns_email')\n" \
"dns_luadns_token = $(bashio::config 'dns.luadns_token')\n" \
"certbot_dns_netcup:dns_netcup_customer_id = $(bashio::config 'dns.netcup_customer_id')\n" \
"certbot_dns_netcup:dns_netcup_api_key = $(bashio::config 'dns.netcup_api_key')\n" \
"certbot_dns_netcup:dns_netcup_api_password = $(bashio::config 'dns.netcup_api_password')\n" \
"dns_nsone_api_key = $(bashio::config 'dns.nsone_api_key')\n" \
"dns_ovh_endpoint = $(bashio::config 'dns.ovh_endpoint')\n" \
"dns_ovh_application_key = $(bashio::config 'dns.ovh_application_key')\n" \
"dns_ovh_application_secret = $(bashio::config 'dns.ovh_application_secret')\n" \
"dns_ovh_consumer_key = $(bashio::config 'dns.ovh_consumer_key')\n" \
"dns_rfc2136_server = $(bashio::config 'dns.rfc2136_server')\n" \
"dns_rfc2136_port = $(bashio::config 'dns.rfc2136_port')\n" \
"dns_rfc2136_name = $(bashio::config 'dns.rfc2136_name')\n" \
"dns_rfc2136_secret = $(bashio::config 'dns.rfc2136_secret')\n" \
"dns_rfc2136_algorithm = $(bashio::config 'dns.rfc2136_algorithm')\n" \
"aws_access_key_id = $(bashio::config 'dns.aws_access_key_id')\n" \
"aws_secret_access_key = $(bashio::config 'dns.aws_secret_access_key')\n" \
"dns_sakuracloud_api_token = $(bashio::config 'dns.sakuracloud_api_token')\n" \
"dns_sakuracloud_api_secret = $(bashio::config 'dns.sakuracloud_api_secret')" > /data/dnsapikey
echo -e "dns_cloudxns_api_key = $(bashio::config 'dns.cloudxns_api_key')\n" \
"dns_cloudxns_secret_key = $(bashio::config 'dns.cloudxns_secret_key')\n" \
"dns_digitalocean_token = $(bashio::config 'dns.digitalocean_token')\n" \
"dns_dnsimple_token = $(bashio::config 'dns.dnsimple_token')\n" \
"dns_dnsmadeeasy_api_key = $(bashio::config 'dns.dnsmadeeasy_api_key')\n" \
"dns_dnsmadeeasy_secret_key = $(bashio::config 'dns.dnsmadeeasy_secret_key')\n" \
"dns_gehirn_api_token = $(bashio::config 'dns.gehirn_api_token')\n" \
"dns_gehirn_api_secret = $(bashio::config 'dns.gehirn_api_secret')\n" \
"dns_linode_key = $(bashio::config 'dns.linode_key')\n" \
"dns_linode_version = $(bashio::config 'dns.linode_version')\n" \
"dns_luadns_email = $(bashio::config 'dns.luadns_email')\n" \
"dns_luadns_token = $(bashio::config 'dns.luadns_token')\n" \
"certbot_dns_netcup:dns_netcup_customer_id = $(bashio::config 'dns.netcup_customer_id')\n" \
"certbot_dns_netcup:dns_netcup_api_key = $(bashio::config 'dns.netcup_api_key')\n" \
"certbot_dns_netcup:dns_netcup_api_password = $(bashio::config 'dns.netcup_api_password')\n" \
"dns_nsone_api_key = $(bashio::config 'dns.nsone_api_key')\n" \
"dns_ovh_endpoint = $(bashio::config 'dns.ovh_endpoint')\n" \
"dns_ovh_application_key = $(bashio::config 'dns.ovh_application_key')\n" \
"dns_ovh_application_secret = $(bashio::config 'dns.ovh_application_secret')\n" \
"dns_ovh_consumer_key = $(bashio::config 'dns.ovh_consumer_key')\n" \
"dns_rfc2136_server = $(bashio::config 'dns.rfc2136_server')\n" \
"dns_rfc2136_port = $(bashio::config 'dns.rfc2136_port')\n" \
"dns_rfc2136_name = $(bashio::config 'dns.rfc2136_name')\n" \
"dns_rfc2136_secret = $(bashio::config 'dns.rfc2136_secret')\n" \
"dns_rfc2136_algorithm = $(bashio::config 'dns.rfc2136_algorithm')\n" \
"aws_access_key_id = $(bashio::config 'dns.aws_access_key_id')\n" \
"aws_secret_access_key = $(bashio::config 'dns.aws_secret_access_key')\n" \
"dns_sakuracloud_api_token = $(bashio::config 'dns.sakuracloud_api_token')\n" \
"dns_sakuracloud_api_secret = $(bashio::config 'dns.sakuracloud_api_secret')" > /data/dnsapikey
chmod 600 /data/dnsapikey

# AWS
Expand All @@ -77,16 +79,23 @@ elif bashio::config.exists 'dns.google_creds'; then
bashio::log.info "Google Credentials File doesnt exists in folder share."
fi
PROVIDER_ARGUMENTS+=("--${DNS_PROVIDER}" "--${DNS_PROVIDER}-credentials" "/data/${GOOGLE_CREDS}")

#Netcup
elif bashio::config.exists 'dns.netcup_customer_id' && bashio::config.exists 'dns.netcup_api_key' && bashio::config.exists 'dns.netcup_api_password'; then
if bashio::config.exists 'dns.netcup_propagation_seconds'; then
NETCUP_DNS_PROPAGATION_SECONDS="$(bashio::config 'dns.netcup_propagation_seconds')"
PROVIDER_ARGUMENTS+=("--authenticator" "certbot-dns-netcup:dns-netcup" "--certbot-dns-netcup:dns-netcup-credentials" /data/dnsapikey "--certbot-dns-netcup:dns-netcup-propagation-seconds" "${PROPAGATION_SECONDS}")

# CloudFlare
elif [[ "${DNS_PROVIDER}" == "dns-cloudflare" ]]; then
if bashio::config.exists 'dns.cloudflare_api_token'; then
bashio::log.info "Use CloudFlare token"
echo "dns_cloudflare_api_token = $(bashio::config 'dns.cloudflare_api_token')" >> /data/dnsapikey
else
NETCUP_DNS_PROPAGATION_SECONDS=600
bashio::log.info "no propagation time found for netcup, using default value"
bashio::log.warning "Use CloudFlare global key (not recommended!)"
echo -e "dns_cloudflare_email = $(bashio::config 'dns.cloudflare_email')\n" \
"dns_cloudflare_api_key = $(bashio::config 'dns.cloudflare_api_key')\n" >> /data/dnsapikey
fi

PROVIDER_ARGUMENTS+=("--authenticator" "certbot-dns-netcup:dns-netcup" "--certbot-dns-netcup:dns-netcup-credentials" /data/dnsapikey "--certbot-dns-netcup:dns-netcup-propagation-seconds" "${NETCUP_DNS_PROPAGATION_SECONDS}")
PROVIDER_ARGUMENTS+=("--${DNS_PROVIDER}" "--${DNS_PROVIDER}-credentials" /data/dnsapikey "--dns-cloudflare-propagation-seconds" "${PROPAGATION_SECONDS}")

#All others
else
Expand Down

0 comments on commit c0d92d3

Please sign in to comment.