From a627247908bdce5b393a6296b71b5300f5fa6b30 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 1 Sep 2018 10:38:16 +0200 Subject: [PATCH] Check if certbot exists before using it. Fixes #685. --- .../__letsencrypt_cert/explorer/certificate-domains | 8 ++++++-- .../__letsencrypt_cert/explorer/certificate-exists | 10 ++++++++-- .../__letsencrypt_cert/explorer/certificate-is-test | 12 +++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains index 367fda93..db605b63 100755 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains @@ -1,4 +1,8 @@ #!/bin/sh -e -certbot certificates --cert-name "${__object_id:?}" | grep ' Domains: ' | \ - cut -d ' ' -f 6- | tr ' ' '\n' +certbot_path=$("${__type_explorer}/certbot-path") +if [ -n "${certbot_path}" ] +then + certbot certificates --cert-name "${__object_id:?}" | grep ' Domains: ' | \ + cut -d ' ' -f 6- | tr ' ' '\n' +fi diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists index d2ea35cc..4e6f44db 100755 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists @@ -1,7 +1,13 @@ #!/bin/sh -e -if certbot certificates | grep -q " Certificate Name: ${__object_id:?}$"; then - echo yes +certbot_path=$("${__type_explorer}/certbot-path") +if [ -n "${certbot_path}" ] +then + if certbot certificates | grep -q " Certificate Name: ${__object_id:?}$"; then + echo yes + else + echo no + fi else echo no fi diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test index 6d7b0ae9..9b445059 100755 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test @@ -1,8 +1,14 @@ #!/bin/sh -e -if certbot certificates --cert-name "${__object_id:?}" | \ - grep -q 'INVALID: TEST_CERT'; then - echo yes +certbot_path=$("${__type_explorer}/certbot-path") +if [ -n "${certbot_path}" ] +then + if certbot certificates --cert-name "${__object_id:?}" | \ + grep -q 'INVALID: TEST_CERT'; then + echo yes + else + echo no + fi else echo no fi