You could make the command set an at job instead of calling shutdown 
directly, but that's a bit hackish.  There must be a way to make the 
command run in the background, but I don't know the trick offhand.


Paul Krizak                         7171 Southwest Pkwy MS B200.3A
MTS Systems Engineer                Austin, TX  78735
Advanced Micro Devices              Desk:  (512) 602-8775
Linux/Unix Systems Engineering      Cell:  (512) 791-0686
Global IT Infrastructure            Fax:   (512) 602-0468

On 08/11/2011 11:24 AM, no-re...@cfengine.com wrote:
> 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
>

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to