Skip to content

Commit 37c37f7

Browse files
author
Marius Burkard
committed
- added acme.sh installation to installer
- fixed wrong certificate path on acme.sh in installer
1 parent 55451ae commit 37c37f7

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

install/lib/installer_base.lib.php

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ public function __construct() {
4343
global $conf; //TODO: maybe $conf should be passed to constructor
4444
}
4545

46+
private function install_acme() {
47+
$install_cmd = 'wget -O - https://get.acme.sh | sh';
48+
$ret = null;
49+
$val = 0;
50+
exec($install_cmd . ' 2>&1', $ret, $val);
51+
52+
return ($val == 0 ? true : false);
53+
}
54+
4655
//: TODO Implement the translation function and language files for the installer.
4756
public function lng($text) {
4857
return $text;
@@ -2946,6 +2955,21 @@ public function make_ispconfig_ssl_cert() {
29462955
$acme = explode("\n", shell_exec('which /usr/local/ispconfig/server/scripts/acme.sh /root/.acme.sh/acme.sh'));
29472956
$acme = reset($acme);
29482957

2958+
if((!$acme || !is_executable($acme)) && (!$le_client || !is_executable($le_client))) {
2959+
$success = $this->install_acme();
2960+
if(!$success) {
2961+
swriteln('Failed installing acme.sh. Will not be able to issue certificate during install.');
2962+
} else {
2963+
$acme = explode("\n", shell_exec('which /usr/local/ispconfig/server/scripts/acme.sh /root/.acme.sh/acme.sh'));
2964+
$acme = reset($acme);
2965+
if($acme && is_executable($acme)) {
2966+
swriteln('Installed acme.sh and using it for certificate creation during install.');
2967+
} else {
2968+
swriteln('Failed installing acme.sh. Will not be able to issue certificate during install.');
2969+
}
2970+
}
2971+
}
2972+
29492973
$restore_conf_symlink = false;
29502974

29512975
// we only need this for apache, so use fixed conf index
@@ -2976,15 +3000,21 @@ public function make_ispconfig_ssl_cert() {
29763000
$issued_successfully = false;
29773001

29783002
// Backup existing ispserver ssl files
2979-
if(file_exists($ssl_crt_file) || is_link($ssl_crt_file))
2980-
rename($ssl_crt_file, $ssl_crt_file.'-temporary.bak');
2981-
if(file_exists($ssl_key_file) || is_link($ssl_key_file))
2982-
rename($ssl_key_file, $ssl_key_file.'-temporary.bak');
2983-
if(file_exists($ssl_pem_file) || is_link($ssl_pem_file))
2984-
rename($ssl_pem_file, $ssl_pem_file.'-temporary.bak');
3003+
if(file_exists($ssl_crt_file) || is_link($ssl_crt_file)) {
3004+
rename($ssl_crt_file, $ssl_crt_file . '-temporary.bak');
3005+
}
3006+
if(file_exists($ssl_key_file) || is_link($ssl_key_file)) {
3007+
rename($ssl_key_file, $ssl_key_file . '-temporary.bak');
3008+
}
3009+
if(file_exists($ssl_pem_file) || is_link($ssl_pem_file)) {
3010+
rename($ssl_pem_file, $ssl_pem_file . '-temporary.bak');
3011+
}
29853012

29863013
// Attempt to use Neilpang acme.sh first, as it is now the preferred LE client
29873014
if (is_executable($acme)) {
3015+
$acme_cert_dir = dirname($acme) . '/' . $hostname;
3016+
3017+
swriteln('acme.sh is installed, overriding certificate path to use ' . $acme_cert_dir);
29883018

29893019
$out = null;
29903020
$ret = null;
@@ -3082,7 +3112,7 @@ public function make_ispconfig_ssl_cert() {
30823112
rename($ssl_key_file.'-temporary.bak', $ssl_key_file);
30833113
if(file_exists($ssl_pem_file.'-temporary.bak') || is_link($ssl_pem_file.'-temporary.bak'))
30843114
rename($ssl_pem_file.'-temporary.bak', $ssl_pem_file);
3085-
3115+
30863116
}
30873117
} else {
30883118
swriteln('Did not find any valid acme client (acme.sh or certbot)');

0 commit comments

Comments
 (0)