@@ -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 ;
@@ -2953,6 +2962,21 @@ public function make_ispconfig_ssl_cert() {
29532962 $ acme = explode ("\n" , shell_exec ('which /usr/local/ispconfig/server/scripts/acme.sh /root/.acme.sh/acme.sh ' ));
29542963 $ acme = reset ($ acme );
29552964
2965+ if ((!$ acme || !is_executable ($ acme )) && (!$ le_client || !is_executable ($ le_client ))) {
2966+ $ success = $ this ->install_acme ();
2967+ if (!$ success ) {
2968+ swriteln ('Failed installing acme.sh. Will not be able to issue certificate during install. ' );
2969+ } else {
2970+ $ acme = explode ("\n" , shell_exec ('which /usr/local/ispconfig/server/scripts/acme.sh /root/.acme.sh/acme.sh ' ));
2971+ $ acme = reset ($ acme );
2972+ if ($ acme && is_executable ($ acme )) {
2973+ swriteln ('Installed acme.sh and using it for certificate creation during install. ' );
2974+ } else {
2975+ swriteln ('Failed installing acme.sh. Will not be able to issue certificate during install. ' );
2976+ }
2977+ }
2978+ }
2979+
29562980 $ restore_conf_symlink = false ;
29572981
29582982 // we only need this for apache, so use fixed conf index
@@ -2983,15 +3007,21 @@ public function make_ispconfig_ssl_cert() {
29833007 $ issued_successfully = false ;
29843008
29853009 // Backup existing ispserver ssl files
2986- if (file_exists ($ ssl_crt_file ) || is_link ($ ssl_crt_file ))
2987- rename ($ ssl_crt_file , $ ssl_crt_file .'-temporary.bak ' );
2988- if (file_exists ($ ssl_key_file ) || is_link ($ ssl_key_file ))
2989- rename ($ ssl_key_file , $ ssl_key_file .'-temporary.bak ' );
2990- if (file_exists ($ ssl_pem_file ) || is_link ($ ssl_pem_file ))
2991- rename ($ ssl_pem_file , $ ssl_pem_file .'-temporary.bak ' );
3010+ if (file_exists ($ ssl_crt_file ) || is_link ($ ssl_crt_file )) {
3011+ rename ($ ssl_crt_file , $ ssl_crt_file . '-temporary.bak ' );
3012+ }
3013+ if (file_exists ($ ssl_key_file ) || is_link ($ ssl_key_file )) {
3014+ rename ($ ssl_key_file , $ ssl_key_file . '-temporary.bak ' );
3015+ }
3016+ if (file_exists ($ ssl_pem_file ) || is_link ($ ssl_pem_file )) {
3017+ rename ($ ssl_pem_file , $ ssl_pem_file . '-temporary.bak ' );
3018+ }
29923019
29933020 // Attempt to use Neilpang acme.sh first, as it is now the preferred LE client
29943021 if (is_executable ($ acme )) {
3022+ $ acme_cert_dir = dirname ($ acme ) . '/ ' . $ hostname ;
3023+
3024+ swriteln ('acme.sh is installed, overriding certificate path to use ' . $ acme_cert_dir );
29953025
29963026 $ out = null ;
29973027 $ ret = null ;
@@ -3089,7 +3119,7 @@ public function make_ispconfig_ssl_cert() {
30893119 rename ($ ssl_key_file .'-temporary.bak ' , $ ssl_key_file );
30903120 if (file_exists ($ ssl_pem_file .'-temporary.bak ' ) || is_link ($ ssl_pem_file .'-temporary.bak ' ))
30913121 rename ($ ssl_pem_file .'-temporary.bak ' , $ ssl_pem_file );
3092-
3122+
30933123 }
30943124 } else {
30953125 swriteln ('Did not find any valid acme client (acme.sh or certbot) ' );
0 commit comments