Skip to content

Commit 4248bda

Browse files
committed
Optimized hook
1 parent b775546 commit 4248bda

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

hooks/pluginable.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -758,22 +758,6 @@ function str_starts_with($haystack, $needle) {
758758
return $args;
759759
});
760760

761-
// Throw hcpp_rebooted when the system has been started
762-
$hcpp->add_action( 'priv_update_sys_queue', function( $args ) {
763-
764-
// Check last reboot time
765-
if ( ! isset( $args[0] ) ) return $args;
766-
if ( $args[0] != 'restart' ) return $args;
767-
$file = '/usr/local/hestia/data/hcpp/last_reboot.txt';
768-
$last = shell_exec("who -b");
769-
if ( !file_exists( $file ) || file_get_contents( $file ) !== $last ) {
770-
file_put_contents( $file, $last );
771-
global $hcpp;
772-
$hcpp->do_action( 'hcpp_rebooted' );
773-
}
774-
return $args;
775-
});
776-
777761
// Delete the ports file when the domain is deleted
778762
$hcpp->add_action( 'pre_delete_web_domain_backend', function( $args ) {
779763
global $hcpp;
@@ -795,10 +779,19 @@ function str_starts_with($haystack, $needle) {
795779
return $args;
796780
});
797781

782+
// Throw hcpp_rebooted when the system has been started
783+
$hcpp->add_action( 'hcpp_invoke_plugin', function( $args ) {
784+
if ( $args[0] == 'hcpp_rebooted' ) {
785+
global $hcpp;
786+
$hcpp->do_action( 'hcpp_rebooted' );
787+
}
788+
return $args;
789+
});
790+
798791
// Throw hcpp_new_domain_ready via v-invoke-plugin hook
799792
$hcpp->add_action( 'hcpp_invoke_plugin', function( $args ) {
800-
global $hcpp;
801793
if ( $args[0] == 'hcpp_new_domain_ready' ) {
794+
global $hcpp;
802795
array_shift( $args );
803796
$hcpp->do_action( 'hcpp_new_domain_ready', $args );
804797
}

0 commit comments

Comments
 (0)