@@ -2721,9 +2721,15 @@ private function curl_request($url, $use_ipv6 = false) {
27212721 return $ response ;
27222722 }
27232723
2724- private function make_acme_vhost ($ server_name , $ server = 'apache ' , $ restart = true ) {
2724+ private function make_acme_vhost ($ server = 'apache ' ) {
27252725 global $ conf ;
27262726
2727+ if ($ conf ['hostname ' ] !== 'localhost ' && $ conf ['hostname ' ] !== '' ) {
2728+ $ server_name = $ conf ['hostname ' ];
2729+ } else {
2730+ $ server_name = exec ('hostname -f ' );
2731+ }
2732+
27272733 $ use_template = 'apache_acme.conf.master ' ;
27282734 $ use_symlink = '999-acme.conf ' ;
27292735 $ use_name = 'acme.conf ' ;
@@ -2759,15 +2765,6 @@ private function make_acme_vhost($server_name, $server = 'apache', $restart = tr
27592765 if (!@is_link ($ vhost_conf_enabled_dir .'' . $ use_symlink )) {
27602766 symlink ($ vhost_conf_dir .'/ ' . $ use_name , $ vhost_conf_enabled_dir .'/ ' . $ use_symlink );
27612767 }
2762- if ($ restart === true ) {
2763- if ($ conf [$ server ]['installed ' ] == true && $ conf [$ server ]['init_script ' ] != '' ) {
2764- if ($ this ->is_update ) {
2765- system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'force-reload ' ).' &> /dev/null || ' . $ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2766- } else {
2767- system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2768- }
2769- }
2770- }
27712768 }
27722769
27732770 public function make_ispconfig_ssl_cert () {
@@ -2893,15 +2890,22 @@ public function make_ispconfig_ssl_cert() {
28932890 // first of all create the acme vhosts if not existing
28942891 if ($ conf ['nginx ' ]['installed ' ] == true ) {
28952892 swriteln ('Using nginx for certificate validation ' );
2896- $ this -> make_acme_vhost ( $ hostname , 'nginx ' ) ;
2893+ $ server = 'nginx ' ;
28972894 } elseif ($ conf ['apache ' ]['installed ' ] == true ) {
28982895 swriteln ('Using apache for certificate validation ' );
28992896 if ($ this ->is_update == false && @is_link ($ vhost_conf_enabled_dir .'/000-ispconfig.conf ' )) {
29002897 $ restore_conf_symlink = true ;
29012898 unlink ($ vhost_conf_enabled_dir .'/000-ispconfig.conf ' );
29022899 }
2900+ $ server = 'apache ' ;
2901+ }
29032902
2904- $ this ->make_acme_vhost ($ hostname , 'apache ' );
2903+ if ($ conf [$ server ]['installed ' ] == true && $ conf [$ server ]['init_script ' ] != '' ) {
2904+ if ($ this ->is_update ) {
2905+ system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'force-reload ' ).' &> /dev/null || ' . $ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2906+ } else {
2907+ system ($ this ->getinitcommand ($ conf [$ server ]['init_script ' ], 'restart ' ).' &> /dev/null ' );
2908+ }
29052909 }
29062910
29072911 $ issued_successfully = false ;
@@ -2999,9 +3003,6 @@ public function make_ispconfig_ssl_cert() {
29993003 }
30003004 }
30013005 } else {
3002- if ($ conf ['apache ' ]['installed ' ] == true ) {
3003- $ this ->make_acme_vhost ($ hostname , 'apache ' , false ); // we need this config file but we don't want apache to be restarted at this point
3004- }
30053006 if (($ svr_ip4 && in_array ($ svr_ip4 , $ dns_ips )) || ($ svr_ip6 && in_array ($ svr_ip6 , $ dns_ips ))) {
30063007 // the directory already exists so we have to assume that it was created previously
30073008 $ issued_successfully = true ;
0 commit comments