From 190275a3c3814094edaa6c5ea40e74031123608f Mon Sep 17 00:00:00 2001 From: Jesse Norell <jesse@kci.net> Date: Tue, 24 May 2016 15:43:32 -0600 Subject: [PATCH] support letsencrypt from OS package Closes: #3908 --- server/lib/classes/cron.d/900-letsencrypt.inc.php | 5 +++-- server/plugins-available/apache2_plugin.inc.php | 5 +++-- server/plugins-available/nginx_plugin.inc.php | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/server/lib/classes/cron.d/900-letsencrypt.inc.php b/server/lib/classes/cron.d/900-letsencrypt.inc.php index 55be1b197c..7e1655e773 100644 --- a/server/lib/classes/cron.d/900-letsencrypt.inc.php +++ b/server/lib/classes/cron.d/900-letsencrypt.inc.php @@ -36,8 +36,9 @@ class cronjob_letsencrypt extends cronjob { public function onRunJob() { global $app, $conf; - if(file_exists("/root/.local/share/letsencrypt/bin/letsencrypt")) { - exec('/root/.local/share/letsencrypt/bin/letsencrypt -n renew'); + $letsencrypt = array_shift( split("\n", `which letsencrypt /root/.local/share/letsencrypt/bin/letsencrypt`) ); + if(is_executable($letsencrypt)) { + exec($letsencrypt . ' -n renew'); $app->services->restartServiceDelayed('httpd', 'reload'); } diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index 34623c6acf..8c1da78814 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -1234,8 +1234,9 @@ class apache2_plugin { $app->log("Create Let's Encrypt SSL Cert for: $domain", LOGLEVEL_DEBUG); $success = false; - if(file_exists("/root/.local/share/letsencrypt/bin/letsencrypt")) { - $success = $this->_exec("/root/.local/share/letsencrypt/bin/letsencrypt auth --text --agree-tos --authenticator webroot --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --email postmaster@$domain --domains $lddomain --webroot-path /usr/local/ispconfig/interface/acme"); + $letsencrypt = array_shift( split("\n", `which letsencrypt /root/.local/share/letsencrypt/bin/letsencrypt`) ); + if(is_executable($letsencrypt)) { + $success = $this->_exec($letsencrypt . " auth --text --agree-tos --authenticator webroot --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --email postmaster@$domain --domains $lddomain --webroot-path /usr/local/ispconfig/interface/acme"); } if(!$success) { // error issuing cert diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 1c5247d65f..9393a9b66b 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -1312,8 +1312,9 @@ class nginx_plugin { $app->log("Create Let's Encrypt SSL Cert for: $domain", LOGLEVEL_DEBUG); $success = false; - if(file_exists("/root/.local/share/letsencrypt/bin/letsencrypt")) { - $success = $this->_exec("/root/.local/share/letsencrypt/bin/letsencrypt auth --text --agree-tos --authenticator webroot --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --email postmaster@$domain --domains $lddomain --webroot-path /usr/local/ispconfig/interface/acme"); + $letsencrypt = array_shift( split("\n", `which letsencrypt /root/.local/share/letsencrypt/bin/letsencrypt`) ); + if(is_executable($letsencrypt)) { + $success = $this->_exec($letsencrypt . " auth --text --agree-tos --authenticator webroot --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --email postmaster@$domain --domains $lddomain --webroot-path /usr/local/ispconfig/interface/acme"); } if(!$success) { // error issuing cert -- GitLab