Skip to content

Commit

Permalink
Optimized hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveorevo committed Aug 18, 2023
1 parent b775546 commit 4248bda
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions hooks/pluginable.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,22 +758,6 @@ function str_starts_with($haystack, $needle) {
return $args;
});

// Throw hcpp_rebooted when the system has been started
$hcpp->add_action( 'priv_update_sys_queue', function( $args ) {

// Check last reboot time
if ( ! isset( $args[0] ) ) return $args;
if ( $args[0] != 'restart' ) return $args;
$file = '/usr/local/hestia/data/hcpp/last_reboot.txt';
$last = shell_exec("who -b");
if ( !file_exists( $file ) || file_get_contents( $file ) !== $last ) {
file_put_contents( $file, $last );
global $hcpp;
$hcpp->do_action( 'hcpp_rebooted' );
}
return $args;
});

// Delete the ports file when the domain is deleted
$hcpp->add_action( 'pre_delete_web_domain_backend', function( $args ) {
global $hcpp;
Expand All @@ -795,10 +779,19 @@ function str_starts_with($haystack, $needle) {
return $args;
});

// Throw hcpp_rebooted when the system has been started
$hcpp->add_action( 'hcpp_invoke_plugin', function( $args ) {
if ( $args[0] == 'hcpp_rebooted' ) {
global $hcpp;
$hcpp->do_action( 'hcpp_rebooted' );
}
return $args;
});

// Throw hcpp_new_domain_ready via v-invoke-plugin hook
$hcpp->add_action( 'hcpp_invoke_plugin', function( $args ) {
global $hcpp;
if ( $args[0] == 'hcpp_new_domain_ready' ) {
global $hcpp;
array_shift( $args );
$hcpp->do_action( 'hcpp_new_domain_ready', $args );
}
Expand Down

0 comments on commit 4248bda

Please sign in to comment.