acme.sh icon indicating copy to clipboard operation
acme.sh copied to clipboard

How do you get variable values within the reloadcmd script file? Followup

Open kevdogg opened this issue 8 months ago • 3 comments

https://github.com/acmesh-official/acme.sh/issues/6275

Sorry to keep laboring the point, however I think I'm running into the same issue as mentioned: https://github.com/acmesh-official/acme.sh/issues/558

My reloadscript is the following:

testreload.sh (755 permissions)

var=$(_readdomainconf "Le_RealFullChainPath")
echo "Var: ${var}"

mydomain=$(_readdomainconf Le_domain)
echo "Domain: ${mydomain}"

It's being invoked by the following command line:

./acme.sh --install-cert -d test3.domain.com --ecc --key-file /etc/ssl/letsencrypt/test3.domain.com/key.pem --fullchain-file /etc/ssl/letsencrypt/test3.domain.com/fullchain.pem --cert-file /etc/ssl/letsencrypt/test3.domain.com/cert.pem --ca-file /etc/ssl/letsencrypt/test3.domain.com/ca.pem --reloadcmd "/root/.acme.sh/test3.domain.com_ecc/testreload.sh"

Output:

/root/.acme.sh/test3.domain.com_ecc/testreload.sh: line 1: _readdomainconf: command not found

Clearly I'm running into same issue with this external script referencing a function within the main acme.sh script that the external script doesn't know exists. Could you provide some further guidance as this issue was originally raised in 2017 and I haven't found any appropriate workaround combing through the issues here.

kevdogg avatar Mar 22 '25 13:03 kevdogg

Please upgrade to the latest code and try again first. Maybe it's already fixed. acme.sh --upgrade If it's still not working, please provide the log with --debug 2, otherwise, nobody can help you.

github-actions[bot] avatar Mar 22 '25 13:03 github-actions[bot]

Here is debug output:


# /acme.sh --install-cert -d test3.domain.com --ecc --key-file /etc/ssl/letsencrypt/test3.domain.com/key.pem --fullchain-file /etc/ssl/letsencrypt/test3.domain.com/fullchain.pem --cert-file /etc/ssl/letsencrypt/test3.domain.com/cert.pem --ca-file /etc/ssl/letsencrypt/test3.domain.com/ca.pem --reloadcmd "/root/.acme.sh/test3.domain.com_ecc/testreload.sh" --debug 2

[Sat Mar 22 08:19:58 AM CDT 2025] Let's find the script directory.
[Sat Mar 22 08:19:58 AM CDT 2025] _SCRIPT_='./acme.sh'
[Sat Mar 22 08:19:58 AM CDT 2025] _script='/root/.acme.sh/acme.sh'
[Sat Mar 22 08:19:58 AM CDT 2025] _script_home='/root/.acme.sh'
[Sat Mar 22 08:19:58 AM CDT 2025] Using default home: /root/.acme.sh
[Sat Mar 22 08:19:58 AM CDT 2025] Using config home: /root/.acme.sh
[Sat Mar 22 08:19:58 AM CDT 2025] LE_WORKING_DIR='/root/.acme.sh'
https://github.com/acmesh-official/acme.sh
v3.1.0
[Sat Mar 22 08:19:58 AM CDT 2025] Running cmd: installcert
[Sat Mar 22 08:19:58 AM CDT 2025] Using config home: /root/.acme.sh
[Sat Mar 22 08:19:58 AM CDT 2025] default_acme_server='https://acme-v02.api.letsencrypt.org/directory'
[Sat Mar 22 08:19:58 AM CDT 2025] ACME_DIRECTORY='https://acme-v02.api.letsencrypt.org/directory'
[Sat Mar 22 08:19:58 AM CDT 2025] _ACME_SERVER_HOST='acme-v02.api.letsencrypt.org'
[Sat Mar 22 08:19:58 AM CDT 2025] _ACME_SERVER_PATH='directory'
[Sat Mar 22 08:19:58 AM CDT 2025] DOMAIN_PATH='/root/.acme.sh/test3.domain.com_ecc'
[Sat Mar 22 08:19:59 AM CDT 2025] Installing cert to: /etc/ssl/letsencrypt/test3.domain.com/cert.pem
[Sat Mar 22 08:19:59 AM CDT 2025] Installing CA to: /etc/ssl/letsencrypt/test3.domain.com/ca.pem
[Sat Mar 22 08:19:59 AM CDT 2025] Installing key to: /etc/ssl/letsencrypt/test3.domain.com/key.pem
[Sat Mar 22 08:19:59 AM CDT 2025] Installing full chain to: /etc/ssl/letsencrypt/test3.domain.com/fullchain.pem
[Sat Mar 22 08:19:59 AM CDT 2025] Running reload cmd: /root/.acme.sh/test3.domain.com_ecc/testreload.sh
/root/.acme.sh/test3.domain.com_ecc/testreload.sh: line 3: _readdomainconf: command not found
Var:
/root/.acme.sh/test3.domain.com_ecc/testreload.sh: line 6: _readdomainconf: command not found
Domain:
[Sat Mar 22 08:19:59 AM CDT 2025] Reload successful

kevdogg avatar Mar 22 '25 13:03 kevdogg

Sorry, it's my mistake. please use a deploy-hook script, so that you can use _readdomainconf in it. https://github.com/acmesh-official/acme.sh/wiki/deployhooks

It's almost the same as a reloadcmd script. just see any of the example: https://github.com/acmesh-official/acme.sh/blob/master/deploy/myapi.sh

Anyway, if you just need another envariable for your reloadcmd, I can add it for you. give me a list.

Neilpang avatar Mar 23 '25 08:03 Neilpang