A cvsup file that pulls the "checked out" version of source. I'm referencing
[dragonfly.git] / sbin / rconfig / rconfig.c
blobb9188cc6fc3009311c5bea27c83b65c3c380ecd4
1 /*
2 * rconfig - Remote configurator
4 * rconfig [-W workingdir] [server_ip[:tag]]
5 * rconfig [-f configfile] -s
7 * $DragonFly: src/sbin/rconfig/rconfig.c,v 1.2 2004/06/18 04:26:53 dillon Exp $
8 */
10 #include "defs.h"
12 const char *WorkDir = "/tmp";
13 const char *ConfigFiles = "/etc/defaults/rconfig.conf:/etc/rconfig.conf";
14 const char *TagDir = "/usr/local/etc/rconfig";
15 tag_t AddrBase;
16 tag_t VarBase;
17 int VerboseOpt;
19 static void usage(int code);
20 static void addTag(tag_t *basep, const char *tag, int flags);
22 int
23 main(int ac, char **av)
25 int ch;
26 int i;
27 int serverMode = 0;
29 while ((ch = getopt(ac, av, "aD:W:irt:f:sv")) != -1) {
30 switch(ch) {
31 case 'a': /* auto tag / standard broadcast */
32 addTag(&AddrBase, NULL, 0);
33 break;
34 case 'W': /* specify working directory */
35 WorkDir = optarg;
36 break;
37 case 'T':
38 TagDir = optarg;
39 break;
40 case 'C': /* specify server config file(s) (colon delimited) */
41 ConfigFiles = optarg;
42 break;
43 case 's': /* run as server using config file */
44 serverMode = 1;
45 break;
46 case 'v':
47 VerboseOpt = 1;
48 break;
49 default:
50 usage(1);
51 /* not reached */
54 for (i = optind; i < ac; ++i) {
55 if (strchr(av[i], '='))
56 addTag(&VarBase, av[i], 0);
57 else
58 addTag(&AddrBase, av[i], 0);
60 if (AddrBase == NULL)
61 usage(1);
62 if (AddrBase && AddrBase->name == NULL && AddrBase->next) {
63 fprintf(stderr,
64 "You cannot specify both -a AND a list of hosts. If you want\n"
65 "to use auto-broadcast mode with a tag other then 'auto',\n"
66 "just specify the tag without a host, e.g. ':<tag>'\n");
67 exit(1);
69 if (serverMode)
70 doServer();
71 else
72 doClient();
73 return(0);
76 static
77 void
78 addTag(tag_t *basep, const char *name, int flags)
80 tag_t tag = calloc(sizeof(struct tag), 1);
82 while ((*basep) != NULL)
83 basep = &(*basep)->next;
85 tag->name = name;
86 tag->flags = flags;
87 *basep = tag;
90 static void
91 usage(int code)
93 fprintf(stderr, "rconfig [-W workdir] [-f servconfig] "
94 "[-s] [var=data]* [server_ip[:tag]]* \n");
95 exit(code);