diff --git a/hooks/install_hcpp_reboot.sh b/hooks/install_hcpp_reboot.sh new file mode 100755 index 0000000..fc7dd28 --- /dev/null +++ b/hooks/install_hcpp_reboot.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Define the path to the target script +target_script="/usr/local/bin/hcpp_rebooted.sh" + +# Check if the target script already exists +if [ ! -f "$target_script" ]; then + cat <> "$target_script" +#!/bin/bash + +# Wait for the mount point to be available +while [ ! -d "/media/appFolder" ]; do + sleep 1 +done + +# Throw a reboot event to trigger the HCPP rebooted hook +/usr/local/hestia/bin/v-invoke-plugin hcpp_rebooted + +EOT + chmod +x "$target_script" + echo "Installed hcpp_rebooted.sh" +else + echo "hcpp_rebooted.sh already exists. Skipping installation." +fi + +# Check if the service file already exists +service_file="/etc/systemd/system/hcpp_rebooted.service" +if [ ! -f "$service_file" ]; then + cat <> "$service_file" +[Unit] +Description=Trigger hcpp_rebooted hook +After=network.target + +[Service] +Type=oneshot +ExecStartPre=/bin/sleep 10 +ExecStart=$target_script + +[Install] +WantedBy=multi-user.target + +EOT + systemctl enable hcpp_rebooted.service + echo "Installed hcpp_rebooted.service" +else + echo "hcpp_rebooted.service already exists. Skipping installation." +fi diff --git a/hooks/post_install.sh b/hooks/post_install.sh index 70ebd28..7ff6f81 100755 --- a/hooks/post_install.sh +++ b/hooks/post_install.sh @@ -12,7 +12,7 @@ // Copy pluginable.php to /usr/local/hestia/web/pluginable.php copy( '/etc/hestiacp/hooks/pluginable.php', '/usr/local/hestia/web/pluginable.php' ); -shell_exec('cd /usr/local/hestia/web/js/dist && wget https://code.jquery.com/jquery-3.7.0.min.js' ); +shell_exec( __DIR__ . '/install_hcpp_reboot.sh' && cd /usr/local/hestia/web/js/dist && wget https://code.jquery.com/jquery-3.7.0.min.js' ); // Ensure log is present and writable when needed if ( ! file_exists( '/tmp/hcpp.log' ) ) {