@@ -300,3 +300,83 @@ function set_php_permissions() {
300300 chown -R www-data:www-data /var/log/php
301301 chown -R www-data:www-data /etc/php
302302}
303+
304+ # Check if all required EngineScript installation components are completed
305+ # Returns 0 if all components are installed, exits with error if incomplete
306+ function check_installation_completion() {
307+ local install_log=" /var/log/EngineScript/install-log.txt"
308+ local missing_components=()
309+ local quiet_mode=" ${1:- false} " # Optional parameter for quiet mode
310+
311+ # Source the install log if it exists
312+ if [[ -f " $install_log " ]]; then
313+ source " $install_log " 2> /dev/null || true
314+ else
315+ if [[ " $quiet_mode " != " true" ]]; then
316+ echo " ERROR: Installation log not found at $install_log "
317+ echo " This indicates EngineScript installation was never started or completed."
318+ echo " Please run the full installation script first."
319+ fi
320+ return 1
321+ fi
322+
323+ # Define all required installation components
324+ local required_components=(
325+ " REPOS" " REMOVES" " BLOCK" " UBUNTU_PRO" " DEPENDS" " CRON" " ACME"
326+ " GCC" " OPENSSL" " SWAP" " KERNEL_TWEAKS" " KSM" " SFL" " NTP"
327+ " PCRE" " ZLIB" " LIBURING" " UFW" " MARIADB" " PHP" " REDIS" " NGINX" " TOOLS"
328+ )
329+
330+ # Check each required component
331+ for component in " ${required_components[@]} " ; do
332+ local var_name=" $component "
333+ local var_value=" ${! var_name:- 0} "
334+
335+ if [[ " $var_value " != " 1" ]]; then
336+ missing_components+=(" $component " )
337+ fi
338+ done
339+
340+ # Return results based on mode
341+ if [[ ${# missing_components[@]} -eq 0 ]]; then
342+ if [[ " $quiet_mode " != " true" ]]; then
343+ echo " ✅ SUCCESS: All EngineScript components are installed and completed."
344+ fi
345+ return 0
346+ else
347+ if [[ " $quiet_mode " != " true" ]]; then
348+ echo " ❌ ERROR: EngineScript installation is incomplete."
349+ echo " ❌ The following components are missing or failed to complete:"
350+ echo " "
351+ for component in " ${missing_components[@]} " ; do
352+ echo " - $component "
353+ done
354+ echo " "
355+ echo " RESOLUTION:"
356+ echo " 1. Run the full EngineScript installation script to complete setup"
357+ echo " 2. Check /var/log/EngineScript/install-error-log.txt for specific errors"
358+ echo " 3. Use 'es.debug' command to generate a complete diagnostic report"
359+ echo " "
360+ fi
361+ return 1
362+ fi
363+ }
364+
365+ # Verify installation completion with error handling for scripts that require it
366+ function verify_installation_completion() {
367+ local script_name=" ${1:- Unknown script} "
368+
369+ echo " ============================================================="
370+ echo " Verifying EngineScript Installation Completion..."
371+ echo " ============================================================="
372+
373+ if check_installation_completion; then
374+ echo " ✅ Installation verification passed. Proceeding with $script_name ..."
375+ echo " "
376+ return 0
377+ else
378+ echo " "
379+ echo " $script_name cannot proceed until all components are properly installed."
380+ exit 1
381+ fi
382+ }
0 commit comments