diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 956fd6290..4919ef734 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -107,7 +107,7 @@ def create_dir_if_missing(path): def get_certbot_path(): try: - return which("certbot", True) + return which("certbot", raise_err=True) except FileNotFoundError: raise CommandFailedError("Certbot is not installed on your system. Please visit https://certbot.eff.org/instructions for installation instructions, then try again.") diff --git a/bench/config/templates/frappe_sudoers b/bench/config/templates/frappe_sudoers index 98aa1c064..c0857408e 100644 --- a/bench/config/templates/frappe_sudoers +++ b/bench/config/templates/frappe_sudoers @@ -15,6 +15,5 @@ {{ user }} ALL = (root) NOPASSWD: {{ nginx }} {% endif %} -{{ user }} ALL = (root) NOPASSWD: /usr/bin/certbot +{{ user }} ALL = (root) NOPASSWD: {{ certbot }} Defaults:{{ user }} !requiretty - diff --git a/bench/utils/system.py b/bench/utils/system.py index 152759d0f..131db2a99 100644 --- a/bench/utils/system.py +++ b/bench/utils/system.py @@ -108,6 +108,8 @@ def init( def setup_sudoers(user): + from bench.config.lets_encrypt import get_certbot_path + if not os.path.exists("/etc/sudoers.d"): os.makedirs("/etc/sudoers.d") @@ -128,6 +130,7 @@ def setup_sudoers(user): "service": which("service"), "systemctl": which("systemctl"), "nginx": which("nginx"), + "certbot": get_certbot_path(), } )