adding certalias to deploy_cert ? #344

Closed
opened 2025-12-29 01:23:27 +01:00 by adam · 3 comments
Owner

Originally created by @gytisgreitai on GitHub (May 3, 2018).

Right now the deploy_cert receives domain name, key, cert, fullchain path and date but not the alias (e.g. for wildcard certs)

Since alias variable is already exported, the change would be as simple as adding it to the end of command, and would not break any existing implementations:

[[ -n "${HOOK}" ]] && "${HOOK}" "deploy_cert" "${domain}" "${certdir}/privkey.pem" "${certdir}/cert.pem" "${certdir}/fullchain.pem" "${certdir}/chain.pem" "${timestamp}" "${alias}"

Originally created by @gytisgreitai on GitHub (May 3, 2018). Right now the deploy_cert receives domain name, key, cert, fullchain path and date but not the alias (e.g. for wildcard certs) Since `alias` variable is already exported, the change would be as simple as adding it to the end of command, and would not break any existing implementations: ` [[ -n "${HOOK}" ]] && "${HOOK}" "deploy_cert" "${domain}" "${certdir}/privkey.pem" "${certdir}/cert.pem" "${certdir}/fullchain.pem" "${certdir}/chain.pem" "${timestamp}" "${alias}"`
adam closed this issue 2025-12-29 01:23:27 +01:00
Author
Owner

@jobe1986 commented on GitHub (May 3, 2018):

You can also use a combination of the dirname and basename commands to extract the alias name from the key, cert, fullchain or chain paths.

I found this out when I considered making a similar request for the $certdir path to be added to the same hook but found I could work them out myself.

@jobe1986 commented on GitHub (May 3, 2018): You can also use a combination of the dirname and basename commands to extract the alias name from the key, cert, fullchain or chain paths. I found this out when I considered making a similar request for the $certdir path to be added to the same hook but found I could work them out myself.
Author
Owner

@lukas2511 commented on GitHub (May 3, 2018):

Like @jobe1986 said you can already extract that from the path and you could also just use the environment variable as it's exported.

@lukas2511 commented on GitHub (May 3, 2018): Like @jobe1986 said you can already extract that from the path and you could also just use the environment variable as it's exported.
Author
Owner

@lcts commented on GitHub (Jan 18, 2019):

For others who stumble on this issue:
If, like me, you prefer to extract the alias from the parameters passed to the hook, here's one simple way to get it from e.g. the keyfile (parameter $2):

certalias=$(_TMP=${2%/*};echo ${_TMP##*/})

(strip everything up to the first / from end of string (path), then strip everything up to the last / from beginning)
It doesn't matter what name you give _TMP, and if you're using the hook.sh template you can replace ${2%/*} with ${KEYFILE%/*} for better readability.
If your hook is executed in zsh instead of bash, this works:

certalias=${${2%/*}##*/}
@lcts commented on GitHub (Jan 18, 2019): For others who stumble on this issue: If, like me, you prefer to extract the alias from the parameters passed to the hook, here's one simple way to get it from e.g. the keyfile (parameter $2): ``` certalias=$(_TMP=${2%/*};echo ${_TMP##*/}) ``` (strip everything up to the first / from end of string (path), then strip everything up to the last / from beginning) It doesn't matter what name you give `_TMP`, and if you're using the hook.sh template you can replace `${2%/*}` with `${KEYFILE%/*}` for better readability. If your hook is executed in zsh instead of bash, this works: ``` certalias=${${2%/*}##*/} ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/dehydrated#344