diff --git a/README.md b/README.md index 5cac8a7..9c8b79a 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ HCPP-NodeApp requires an Ubuntu or Debian based installation of [Hestia Control ``` cd /usr/local/hestia/plugins -sudo git clone --branch v2.0.3 https://github.com/virtuosoft-dev/hcpp-nodeapp nodeapp +sudo git clone https://github.com/sharklatan/hcpp-nodeapp nodeapp ``` Note: It is important that the destination plugin folder name is `nodeapp`. diff --git a/nodeapp.php b/nodeapp.php index 54dfafb..543d71f 100644 --- a/nodeapp.php +++ b/nodeapp.php @@ -24,6 +24,14 @@ public function allocate_ports( $nodeapp_folder ) { $user = $parse[2]; $domain = $parse[4]; + // Ensure ports directory exists for this user + $ports_dir = "/usr/local/hestia/data/hcpp/ports/$user"; + if ( ! is_dir( $ports_dir ) ) { + $hcpp->log( "allocate_ports: creating ports dir $ports_dir" ); + // Attempt to create directory and set ownership; ignore failures + $hcpp->run( "mkdir -p $ports_dir && chown -R admin:admin /usr/local/hestia/data/hcpp/ports || true" ); + } + // Wipe the existing ports for this domain if ( file_exists( "/usr/local/hestia/data/hcpp/ports/$user/$domain.ports" ) ) { unlink( "/usr/local/hestia/data/hcpp/ports/$user/$domain.ports" ); @@ -846,7 +854,11 @@ public function update_nginx_files( $args ) { $domain = $args[1]; $nodeapp_folder = "/home/$user/web/$domain/nodeapp"; if ( is_dir( $nodeapp_folder) ) { - $this->generate_nginx_files( $nodeapp_folder, true ); + $proxy = $hcpp->run("v-list-web-domain $user $domain json"); + if ( $proxy != NULL ) { + $proxy = $proxy[$domain]["PROXY"]; + $this->generate_nginx_files( $nodeapp_folder, ( $proxy == "NodeApp" ) ); + } } } @@ -978,4 +990,4 @@ public function v_update_sys_queue( $args ) { } global $hcpp; $hcpp->register_plugin( NodeApp::class ); -} \ No newline at end of file +}