1######################################################################### 2# 3# scheduling.cf - Command Execution Scheduling 4# 5# NOTE: Commands can be executed based on any class expression. 6# Examples include execution of other commands (sequencing), 7# time, OS, hostname or the outcome of another promise. 8# If a shell wrapper is not needed, removing it will increase 9# security and performance. 10# 11######################################################################### 12 13body common control 14{ 15 bundlesequence => { "system_scheduling" }; 16 inputs => { "$(sys.libdir)/stdlib.cf" }; 17} 18 19bundle agent system_scheduling 20{ 21 vars: 22 23 # Command definitions are given in cmd[index]. 24 # The dependencies of the commands are dep_cmd[index], as boolean class expressions. 25 # Comments are given as comment_cmd[index] 26 27 "cmd[1]" string => "$(sys.cf_key)"; 28 "dep_cmd[1]" string => "cmd2_success"; 29 "comment_cmd[1]" string => "Check that a Cfengine key is generated if command 2 has run (dummy)"; 30 31 32 windows:: 33 "cmd[2]" string => "\"$(sys.winsysdir)\shutdown.exe\" /r /c \"Cfengine automatic restart\" /t 120"; 34 "dep_cmd[2]" string => "Monday.Hr05.Min00_05"; 35 "comment_cmd[2]" string => "Restart windows every week"; 36 37 "cmd[3]" string => "$(sys.winsysdir)\cscript.exe \"$(sys.workdir)\script1.vbs\" //Nologo > \"$(sys.workdir)\script1_out.txt\""; 38 "dep_cmd[3]" string => "Hr05.Min05_10"; 39 "comment_cmd[3]" string => "Run a script and save its output for later reference (needs to be run in shell)"; 40 41 42 !windows:: 43 44 "cmd[2]" string => "/bin/echo Hello World!"; 45 "dep_cmd[2]" string => "Hr12.Min00_05"; 46 "comment_cmd[2]" string => "Print a message (dummy)"; 47 48 49 any:: 50 51 "cmd_index" slist => getindices("cmd"); 52 53 54 commands: 55 56 # Runs a command if its dependencies are satisfied 57 58 "$(cmd[$(cmd_index)])" 59 classes => if_repaired("cmd$(cmd_index)_success"), 60 if => "$(dep_cmd[$(cmd_index)])", 61 contain => in_shell, 62 comment => "$(comment_cmd[$(cmd_index)])"; 63 64} 65 66