From e08928d2b7d9ca1fd93bad8975189bba2abf55c3 Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Wed, 31 Mar 2021 10:48:50 +0200
Subject: [PATCH] - enable acme.sh upgrade / set default server to letsencrypt

---
 install/lib/installer_base.lib.php | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index 42a3b1792a..8d9ee9bf7e 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -51,6 +51,21 @@ class installer_base {
 		return ($val == 0 ? true : false);
 	}
 
+	private function update_acme() {
+		$acme = explode("\n", shell_exec('which /usr/local/ispconfig/server/scripts/acme.sh /root/.acme.sh/acme.sh'));
+		$acme = reset($acme);
+		$val = 0;
+
+		if($acme) {
+			$cmd = $acme . ' --upgrade --auto-upgrade ; ' . $acme . ' --set-default-ca --server letsencrypt';
+			$ret = null;
+			$val = 0;
+			exec($cmd. ' 2>&1', $ret, $val);
+		}
+
+		return ($val == 0 ? true : false);
+	}
+
 	//: TODO  Implement the translation function and language files for the installer.
 	public function lng($text) {
 		return $text;
@@ -2923,6 +2938,11 @@ class installer_base {
 				}
 			}
 
+			if($acme && is_executable($acme)) {
+				// we do this even on install to enable automatic updates
+				$this->update_acme();
+			}
+
 			$restore_conf_symlink = false;
 
 			// we only need this for apache, so use fixed conf index
-- 
GitLab