Forum: CFEngine Help Subject: Cfengine performing system shutdown/restart Author: ro Link to topic: https://cfengine.com/forum/read.php?3,23082,23082#msg-23082
Hi, for a specific use case I need Cfengine to restart the host when a special global class has been set by another promise. Initially I thought I'd add a last promise 'restartHost' that would call the shutdown command which would restart the system two minutes afterwards (to give cfengine enough time to complete): bundle agent restartHost { vars: any:: "cmd_restart" string => "/sbin/shutdown -r 2"; commands: any:: "$(cmd_restart)", comment => "If this is the first cfengine run on this machine, restart the host in order to reinitialize some services", classes => cmd_if_else("restartHost"); reports: repaired_restartHost:: "Repaired promise restartHost. Host is going to restart in 2 minutes!"; failed_restartHost:: "WARNING: Repair of promise restartHost FAILED! Need to manually restart host!"; } What I did not think of was that the shutdown process always stays in foreground, so cfengine is patiently waiting for this process to finish before proceeding and finishing the cfengine run. However, Cfengine cannot gracefully finish its run because the system is going down before, forcefully stopping the cfengine process. No matter how hard I try to send the shutdown process to the background ('action => bg', '/sbin/shutdown -r 2 &', 'contain => silent'), Cfengine would always wait for the shutdown process to finish before proceeding. Any ideas? Cheers, Robert _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine