int main (int argc, char **argv) { bool opt_nodaemon = false; setprogname (argv[0]); int ch; while ((ch = getopt (argc, argv, "df:S:")) != -1) switch (ch) { case 'd': opt_nodaemon = true; break; case 'f': if (configfile) usage (); configfile = optarg; break; case 'S': { str sfsconf (strbuf ("SFS_CONFIG=%s", optarg)); xputenv (const_cast<char*>(sfsconf.cstr())); } case '?': default: usage (); } argc -= optind; argv += optind; if (argc > 1) usage (); sfsconst_init (); if (!configfile) configfile = sfsconst_etcfile_required ("sfssd_config"); parseconfig (); if (!revocationdir) revocationdir = sfsdir << "srvrevoke"; if (!opt_nodaemon && !builddir) { daemonize (); sigcb (SIGINT, wrap (termsig, SIGINT)); sigcb (SIGTERM, wrap (termsig, SIGTERM)); } warn ("version %s, pid %d\n", VERSION, int (getpid ())); sigcb (SIGHUP, wrap (restart)); launchservers (); amain (); }
str okws_etcfile_required (const char *f, const char *env_var, bool d, const char **cfg_path) { vec<str> v1; vec<const char *> v2; if (cfg_path == NULL) cfg_path = ok_cfg_path; get_cfg_path (&v1, env_var, cfg_path); vec2vec (&v2, v1); return sfsconst_etcfile_required (f, v2.base (), d); }
str sfsconst_etcfile_required (const char *name) { const char *path[] = { etc1dir, etc2dir, etc3dir, NULL }; return sfsconst_etcfile_required (name, path); }
str flume_etcfile_required (const char *f) { return sfsconst_etcfile_required (f, flume_cfg_path); }