int main(int argc, char *argv[]) { GenericAgentConfig config = CheckOpts(argc, argv); GenericInitialize("knowledge", config); ThisAgentInit(); KeepKnowControlPromises(); if (strlen(STORY) > 0) { #ifdef HAVE_CONSTELLATION if (strncmp(STORY, "SHA=", 4) == 0) { char buffer[CF_BUFSIZE]; Constellation_HostStory(STORY, buffer, CF_BUFSIZE); printf("%s\n", buffer); } else { strcpy(TOPIC_CMD, STORY); printf("Let's start with stories about cause-effect:\n\n"); CfGenerateStories(TOPIC_CMD, cfi_cause); printf("Now looking for stories about connections between things:\n\n"); CfGenerateStories(TOPIC_CMD, cfi_connect); printf("Anything about structure:\n\n"); CfGenerateStories(TOPIC_CMD, cfi_part); } #endif exit(0); } if (GENERATE_XML) { GenerateXml(); } else if (strlen(TOPIC_CMD) == 0) { int complete; double percent; KeepPromiseBundles(); WriteKMDB(); GenerateManual(); ShowWords(); ShowSingletons(); complete = (double) CF_TOPICS *(CF_TOPICS - 1); percent = 100.0 * (double) CF_EDGES / (double) complete; CfOut(cf_inform, "", " -> Association density yields %d/%d = %.4lf%%\n", CF_EDGES, complete, percent); percent = 100.0 * (double) CF_OCCUR / (double) CF_TOPICS; CfOut(cf_inform, "", " -> Hit probability (efficiency) yields %d/%d = %.4lf%%\n", CF_OCCUR, CF_TOPICS, percent); } return 0; }
int main(int argc, char *argv[]) { GenericAgentConfig *config = CheckOpts(argc, argv); THIS_AGENT_TYPE = AGENT_TYPE_KEYGEN; ReportContext *report_context = OpenReports("keygenerator"); GenericInitialize("keygenerator", config, report_context); if (SHOWHOSTS) { ShowLastSeenHosts(); return 0; } if (REMOVEKEYS) { return RemoveKeys(remove_keys_host); } if(LICENSE_INSTALL) { bool success = LicenseInstall(LICENSE_SOURCE); return success ? 0 : 1; } KeepKeyPromises(); ReportContextDestroy(report_context); GenericAgentConfigDestroy(config); return 0; }
int main(int argc, char *argv[]) { GenericAgentConfig config = CheckOpts(argc, argv); ReportContext *report_context = OpenReports("monitor"); Policy *policy = GenericInitialize("monitor", config, report_context); ThisAgentInit(); KeepPromises(policy, report_context); MonitorStartServer(policy, report_context); ReportContextDestroy(report_context); return 0; }
int main(int argc, char *argv[]) { GenericAgentConfig config = CheckOpts(argc, argv); ReportContext *report_context = OpenReports("gendoc"); GenericInitialize("gendoc", config, report_context); if (GENERATE_XML) { GenerateXml(); } else { GenerateManual(); } ReportContextDestroy(report_context); return 0; }
int main(int argc, char *argv[]) { GenericAgentConfig config = CheckOpts(argc, argv); GenericInitialize("common", config); ThisAgentInit(); AnalyzePromiseConflicts(); GenericDeInitialize(); if (ERRORCOUNT > 0) { CfOut(cf_verbose, "", " !! Inputs are invalid\n"); exit(1); } else { CfOut(cf_verbose, "", " -> Inputs are valid\n"); exit(0); } }
int main(int argc,char *argv[]) { CheckOpts(argc,argv); THIS_AGENT_TYPE = cf_keygen; GenericInitialize(argc,argv,"keygenerator"); if (SHOWHOSTS) { ShowLastSeenHosts(); return 0; } if (REMOVEKEYS) { return RemoveKeys(remove_keys_host); } KeepKeyPromises(); return 0; }
int main(int argc,char *argv[]) { int ret = 0; CheckOpts(argc,argv); GenericInitialize(argc,argv,"agent"); ThisAgentInit(); KeepPromises(); NoteClassUsage(VHEAP); #ifdef HAVE_NOVA Nova_NoteVarUsageDB(); #endif PurgeLocks(); if(BOOTSTRAP && !VerifyBootstrap()) { ret = 1; } GenericDeInitialize(); return ret; }
int main(int argc, char *argv[]) { Rlist *rp; Promise *pp; #if !defined(__MINGW32__) int count = 0; int status; int pid; #endif GenericAgentConfig *config = CheckOpts(argc, argv); ReportContext *report_context = OpenReports("runagent"); Policy *policy = GenericInitialize("runagent", config, report_context); ThisAgentInit(); KeepControlPromises(policy); // Set RUNATTR using copy if (BACKGROUND && INTERACTIVE) { CfOut(cf_error, "", " !! You cannot specify background mode and interactive mode together"); exit(1); } pp = MakeDefaultRunAgentPromise(); /* HvB */ if (HOSTLIST) { rp = HOSTLIST; while (rp != NULL) { #ifdef __MINGW32__ if (BACKGROUND) { CfOut(cf_verbose, "", "Windows does not support starting processes in the background - starting in foreground"); BACKGROUND = false; } #else if (BACKGROUND) /* parallel */ { if (count <= MAXCHILD) { if (fork() == 0) /* child process */ { HailServer(rp->item, RUNATTR, pp); exit(0); } else /* parent process */ { rp = rp->next; count++; } } else { pid = wait(&status); CfDebug("child = %d, child number = %d\n", pid, count); count--; } } else /* serial */ #endif /* __MINGW32__ */ { HailServer(rp->item, RUNATTR, pp); rp = rp->next; } } /* end while */ } /* end if HOSTLIST */ #ifndef __MINGW32__ if (BACKGROUND) { printf("Waiting for child processes to finish\n"); while (count > 1) { pid = wait(&status); CfOut(cf_verbose, "", "Child = %d ended, number = %d\n", pid, count); count--; } } #endif DeletePromise(pp); GenericAgentConfigDestroy(config); ReportContextDestroy(report_context); return 0; }
int main(int argc, char *argv[]) { GenericAgentConfig config = CheckOpts(argc, argv); ReportContext *report_context = OpenReports("executor"); Policy *policy = GenericInitialize("executor", config, report_context); ThisAgentInit(); ExecConfig exec_config = { .scheduled_run = !ONCE, .exec_command = SafeStringDuplicate(""), .mail_server = SafeStringDuplicate(""), .mail_from_address = SafeStringDuplicate(""), .mail_to_address = SafeStringDuplicate(""), .mail_max_lines = 30, .fq_name = VFQNAME, .ip_address = VIPADDRESS, .agent_expireafter = 10080, }; KeepPromises(policy, &exec_config); #ifdef MINGW if (WINSERVICE) { NovaWin_StartExecService(); } else #endif /* MINGW */ { StartServer(policy, &exec_config, report_context); } ReportContextDestroy(report_context); return 0; } /*****************************************************************************/ /* Level 1 */ /*****************************************************************************/ static GenericAgentConfig CheckOpts(int argc, char **argv) { extern char *optarg; int optindex = 0; int c; char ld_library_path[CF_BUFSIZE]; GenericAgentConfig config = GenericAgentDefaultConfig(AGENT_TYPE_EXECUTOR); while ((c = getopt_long(argc, argv, "dvnKIf:D:N:VxL:hFOV1gMW", OPTIONS, &optindex)) != EOF) { switch ((char) c) { case 'f': if (optarg && strlen(optarg) < 5) { FatalError(" -f used but argument \"%s\" incorrect", optarg); } SetInputFile(optarg); MINUSF = true; break; case 'd': HardClass("opt_debug"); DEBUG = true; break; case 'K': IGNORELOCK = true; break; case 'D': NewClassesFromString(optarg); break; case 'N': NegateClassesFromString(optarg); break; case 'I': INFORM = true; break; case 'v': VERBOSE = true; NO_FORK = true; break; case 'n': DONTDO = true; IGNORELOCK = true; HardClass("opt_dry_run"); break; case 'L': snprintf(ld_library_path, CF_BUFSIZE - 1, "LD_LIBRARY_PATH=%s", optarg); if (putenv(xstrdup(ld_library_path)) != 0) { } break; case 'W': WINSERVICE = false; break; case 'F': NO_FORK = true; break; case 'O': ONCE = true; break; case 'V': PrintVersionBanner("cf-execd"); exit(0); case 'h': Syntax("cf-execd - cfengine's execution agent", OPTIONS, HINTS, ID); exit(0); case 'M': ManPage("cf-execd - cfengine's execution agent", OPTIONS, HINTS, ID); exit(0); case 'x': SelfDiagnostic(); exit(0); default: Syntax("cf-execd - cfengine's execution agent", OPTIONS, HINTS, ID); exit(1); } } if (argv[optind] != NULL) { CfOut(cf_error, "", "Unexpected argument with no preceding option: %s\n", argv[optind]); } return config; } /*****************************************************************************/ static void LoadDefaultSchedule(void) { CfDebug("Loading default schedule...\n"); DeleteItemList(SCHEDULE); SCHEDULE = NULL; AppendItem(&SCHEDULE, "Min00", NULL); AppendItem(&SCHEDULE, "Min05", NULL); AppendItem(&SCHEDULE, "Min10", NULL); AppendItem(&SCHEDULE, "Min15", NULL); AppendItem(&SCHEDULE, "Min20", NULL); AppendItem(&SCHEDULE, "Min25", NULL); AppendItem(&SCHEDULE, "Min30", NULL); AppendItem(&SCHEDULE, "Min35", NULL); AppendItem(&SCHEDULE, "Min40", NULL); AppendItem(&SCHEDULE, "Min45", NULL); AppendItem(&SCHEDULE, "Min50", NULL); AppendItem(&SCHEDULE, "Min55", NULL); }