2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
14 #include <afs/procmgmt.h>
18 #include <hcrypto/ui.h>
21 #include <afs/afsutil.h>
22 #include <afs/cellconfig.h>
26 #include <afs/cellconfig.h>
28 #include <afs/com_err.h>
30 #include <afs/ktime.h>
31 #include <afs/kautils.h>
32 #include <afs/afsint.h>
33 #include <afs/volser.h>
35 static int IStatServer(struct cmd_syndesc *as, int int32p);
36 static int DoStat(char *aname, struct rx_connection *aconn,
37 int aint32p, int firstTime);
40 #include "bnode_internal.h"
41 #include "bosprototypes.h"
43 /* command offsets for bos salvage command */
44 #define ADDPARMOFFSET 10
46 /* dummy routine for the audit work. It should do nothing since audits */
47 /* occur at the server level and bos is not a server. */
53 /* keep those lines small */
58 return "communications failure (-1)";
60 return "communications timeout (-3)";
62 return (char *)afs_error_message(acode);
65 /* make ctime easier to use */
69 static char tbuffer[30];
73 strlcpy(tbuffer, tp, sizeof(tbuffer));
74 tbuffer[24] = 0; /* get rid of new line */
76 strcpy(tbuffer, "BAD TIME");
81 /* use the syntax descr to get a connection, authenticated appropriately.
82 * aencrypt is set if we want to encrypt the data on the wire.
84 static struct rx_connection *
85 GetConn(struct cmd_syndesc *as, int aencrypt)
89 char *cellname = NULL;
92 struct rx_connection *tconn;
94 struct afsconf_dir *tdir = NULL;
95 afsconf_secflags secFlags;
96 struct rx_securityClass *sc;
99 hostname = as->parms[0].items->data;
100 th = hostutil_GetHostByName(hostname);
102 printf("bos: can't find address for host '%s'\n", hostname);
105 memcpy(&addr, th->h_addr, sizeof(afs_int32));
108 secFlags = AFSCONF_SECOPTS_ALWAYSENCRYPT;
110 secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
113 if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
114 secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
115 confdir = AFSDIR_SERVER_ETC_DIRPATH;
117 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
120 if (as->parms[ADDPARMOFFSET + 1].items) { /* -noauth */
121 secFlags |= AFSCONF_SECOPTS_NOAUTH;
123 /* If we're running with -noauth, we don't need a configuration
125 tdir = afsconf_Open(confdir);
127 printf("bos: can't open cell database (%s)\n", confdir);
132 if (as->parms[ADDPARMOFFSET].items) /* -cell */
133 cellname = as->parms[ADDPARMOFFSET].items->data;
135 code = afsconf_PickClientSecObj(tdir, secFlags, NULL, cellname,
136 &sc, &scIndex, NULL);
138 afs_com_err("bos", code, "(configuring connection security)");
142 if (scIndex == RX_SECIDX_NULL)
143 fprintf(stderr, "bos: running unauthenticated\n");
146 rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc, scIndex);
148 fprintf(stderr, "bos: could not create rx connection\n");
157 SetAuth(struct cmd_syndesc *as, void *arock)
160 struct rx_connection *tconn;
164 tconn = GetConn(as, 0);
165 tp = as->parms[1].items->data;
166 if (strcmp(tp, "on") == 0)
167 flag = 0; /* auth req.: noauthflag is false */
168 else if (strcmp(tp, "off") == 0)
172 ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
176 code = BOZO_SetNoAuthFlag(tconn, flag);
178 afs_com_err("bos", code, "(failed to set authentication flag)");
182 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
183 * /usr/afs/bin/bar */
185 ComputeDestDir(char *aname, char *adir, char *aresult, afs_int32 alen)
189 strcpy(aresult, adir);
190 tp = strrchr(aname, '/');
193 strcat(aresult, "/");
194 strcat(aresult, aname);
196 /* tp points at the / character */
202 /* copy data from fd afd to rx call acall */
204 CopyBytes(int afd, struct rx_call *acall)
211 len = read(afd, tbuffer, sizeof(tbuffer));
215 return 0; /* all done */
216 code = rx_Write(acall, tbuffer, len);
223 Prune(struct cmd_syndesc *as, void *arock)
226 struct rx_connection *tconn;
229 tconn = GetConn(as, 0);
231 if (as->parms[1].items)
232 flags |= BOZO_PRUNEBAK;
233 if (as->parms[2].items)
234 flags |= BOZO_PRUNEOLD;
235 if (as->parms[3].items)
236 flags |= BOZO_PRUNECORE;
237 if (as->parms[4].items)
239 code = BOZO_Prune(tconn, flags);
241 afs_com_err("bos", code, "(failed to prune server files)");
246 Exec(struct cmd_syndesc *as, void *arock)
248 struct rx_connection *tconn;
251 tconn = GetConn(as, 0);
252 code = BOZO_Exec(tconn, as->parms[1].items->data);
254 printf("bos: failed to execute command (%s)\n", em(code));
259 GetDate(struct cmd_syndesc *as, void *arock)
264 afs_int32 time, bakTime, oldTime;
265 struct rx_connection *tconn;
268 tconn = GetConn(as, 0);
269 if (!as->parms[1].items) {
270 printf("bos: no files to check\n");
274 /* compute dest dir or file; default MUST be canonical form of dir path */
275 if (as->parms[2].items)
276 strcpy(destDir, as->parms[2].items->data);
278 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
280 for (ti = as->parms[1].items; ti; ti = ti->next) {
281 /* check date for each file */
282 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
283 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
285 printf("bos: failed to check date on %s (%s)\n", ti->data,
289 printf("File %s ", tbuffer);
291 printf("does not exist, ");
293 printf("dated %s, ", DateOf(time));
295 printf("no .BAK file, ");
297 printf(".BAK file dated %s, ", DateOf(bakTime));
299 printf("no .OLD file.");
301 printf(".OLD file dated %s.", DateOf(oldTime));
309 UnInstall(struct cmd_syndesc *as, void *arock)
315 struct rx_connection *tconn;
317 tconn = GetConn(as, 0);
318 if (!as->parms[1].items) {
319 printf("bos: no files to uninstall\n");
323 /* compute dest dir or file; default MUST be canonical form of dir path */
324 if (as->parms[2].items)
325 strcpy(destDir, as->parms[2].items->data);
327 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
329 for (ti = as->parms[1].items; ti; ti = ti->next) {
330 /* uninstall each file */
331 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
332 code = BOZO_UnInstall(tconn, tbuffer);
334 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
337 printf("bos: uninstalled file %s\n", ti->data);
343 GetServerGoal(struct rx_connection *aconn, char *aname)
348 struct bozo_status istatus;
351 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
353 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
355 /* if we can't get the answer, assume its running */
358 if (istatus.goal == 0)
359 return BSTAT_SHUTDOWN;
365 Install(struct cmd_syndesc *as, void *arock)
367 struct rx_connection *tconn;
373 struct rx_call *tcall;
376 tconn = GetConn(as, 0);
377 if (!as->parms[1].items) {
378 printf("bos: no files to install\n");
382 /* compute dest dir or file; default MUST be canonical form of dir path */
383 if (as->parms[2].items)
384 strcpy(destDir, as->parms[2].items->data);
386 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
388 for (ti = as->parms[1].items; ti; ti = ti->next) {
389 /* install each file */
390 fd = open(ti->data, O_RDONLY);
392 /* better to quit on error than continue for install command */
393 printf("bos: can't find file '%s', quitting\n", ti->data);
396 code = fstat(fd, &tstat);
398 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
402 /* compute destination dir */
403 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
404 tcall = rx_NewCall(tconn);
406 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
407 (afs_int32) tstat.st_mode, tstat.st_mtime);
409 code = CopyBytes(fd, tcall);
411 code = rx_EndCall(tcall, code);
413 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
416 printf("bos: installed file %s\n", ti->data);
422 Shutdown(struct cmd_syndesc *as, void *arock)
424 struct rx_connection *tconn;
428 tconn = GetConn(as, 0);
429 if (as->parms[1].items == 0) {
430 code = BOZO_ShutdownAll(tconn);
432 printf("bos: failed to shutdown servers (%s)\n", em(code));
434 for (ti = as->parms[1].items; ti; ti = ti->next) {
435 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
437 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
441 if (as->parms[8].items) {
442 code = BOZO_WaitAll(tconn);
444 printf("bos: can't wait for processes to shutdown (%s)\n",
451 GetRestartCmd(struct cmd_syndesc *as, void *arock)
454 struct ktime generalTime, newBinaryTime;
455 char messageBuffer[256];
456 struct rx_connection *tconn;
459 hostp = as->parms[0].items->data; /* host name for messages */
460 tconn = GetConn(as, 0);
462 code = BOZO_GetRestartTime(tconn, 1, (struct bozo_netKTime *) &generalTime);
464 printf("bos: failed to retrieve restart information (%s)\n",
468 code = BOZO_GetRestartTime(tconn, 2, (struct bozo_netKTime *) &newBinaryTime);
470 printf("bos: failed to retrieve restart information (%s)\n",
475 code = ktime_DisplayString(&generalTime, messageBuffer);
477 printf("bos: failed to decode restart time (%s)\n", em(code));
480 printf("Server %s restarts %s\n", hostp, messageBuffer);
482 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
484 printf("bos: failed to decode restart time (%s)\n", em(code));
487 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
494 SetRestartCmd(struct cmd_syndesc *as, void *arock)
498 struct ktime restartTime;
500 struct rx_connection *tconn;
503 tconn = GetConn(as, 0);
504 if (as->parms[2].items) {
508 if (as->parms[3].items) {
513 printf("bos: can't specify more than one restart time at a time\n");
517 type = 1; /* by default set general restart time */
519 if ((code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime))) {
520 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
521 as->parms[1].items->data, em(code));
525 code = BOZO_SetRestartTime(tconn, type, (struct bozo_netKTime *) &restartTime);
527 printf("bos: failed to set restart time at server (%s)\n", em(code));
534 Startup(struct cmd_syndesc *as, void *arock)
536 struct rx_connection *tconn;
540 tconn = GetConn(as, 0);
541 if (as->parms[1].items == 0) {
542 code = BOZO_StartupAll(tconn);
544 printf("bos: failed to startup servers (%s)\n", em(code));
546 for (ti = as->parms[1].items; ti; ti = ti->next) {
547 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
549 printf("bos: failed to start instance %s (%s)\n", ti->data,
557 Restart(struct cmd_syndesc *as, void *arock)
559 struct rx_connection *tconn;
563 tconn = GetConn(as, 0);
564 if (as->parms[2].items) {
565 /* this is really a rebozo command */
566 if (as->parms[1].items) {
567 /* specified specific things to restart, can't do this at the same
570 ("bos: can't specify both '-bos' and specific servers to restart.\n");
573 /* otherwise do a rebozo */
574 code = BOZO_ReBozo(tconn);
576 printf("bos: failed to restart bosserver (%s)\n", em(code));
579 if (as->parms[1].items == 0) {
580 if (as->parms[3].items) { /* '-all' */
581 code = BOZO_RestartAll(tconn);
583 printf("bos: failed to restart servers (%s)\n", em(code));
585 printf("bos: To restart all processes please specify '-all'\n");
587 if (as->parms[3].items) {
588 printf("bos: Can't use '-all' along with individual instances\n");
590 for (ti = as->parms[1].items; ti; ti = ti->next) {
591 code = BOZO_Restart(tconn, ti->data);
593 printf("bos: failed to restart instance %s (%s)\n",
602 SetCellName(struct cmd_syndesc *as, void *arock)
604 struct rx_connection *tconn;
607 tconn = GetConn(as, 0);
608 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
610 printf("bos: failed to set cell (%s)\n", em(code));
615 AddHost(struct cmd_syndesc *as, void *arock)
617 struct rx_connection *tconn;
620 char name[MAXHOSTCHARS];
622 tconn = GetConn(as, 0);
623 for (ti = as->parms[1].items; ti; ti = ti->next) {
624 if (as->parms[2].items) {
625 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
626 fprintf(stderr, "bos: host name too long\n");
630 strcpy(&name[1], ti->data);
631 strcat((char *)&name, "]");
632 code = BOZO_AddCellHost(tconn, name);
634 code = BOZO_AddCellHost(tconn, ti->data);
636 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
642 RemoveHost(struct cmd_syndesc *as, void *arock)
644 struct rx_connection *tconn;
648 tconn = GetConn(as, 0);
649 for (ti = as->parms[1].items; ti; ti = ti->next) {
650 code = BOZO_DeleteCellHost(tconn, ti->data);
652 printf("bos: failed to delete host %s (%s)\n", ti->data,
659 ListHosts(struct cmd_syndesc *as, void *arock)
661 struct rx_connection *tconn;
668 tconn = GetConn(as, 0);
669 code = BOZO_GetCellName(tconn, &tp);
671 printf("bos: failed to get cell name (%s)\n", em(code));
674 printf("Cell name is %s\n", tbuffer);
676 code = BOZO_GetCellHost(tconn, i, &tp);
680 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
683 printf(" Host %d is %s\n", i + 1, tbuffer);
689 AddKey(struct cmd_syndesc *as, void *arock)
691 struct rx_connection *tconn;
693 struct ktc_encryptionKey tkey;
695 char buf[BUFSIZ], ver[BUFSIZ];
697 tconn = GetConn(as, 1);
698 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
700 if (as->parms[1].items) {
701 if (strlcpy(buf, as->parms[1].items->data, sizeof(buf)) >= sizeof(buf)) {
702 fprintf(stderr, "Key data too long for buffer\n");
707 code = UI_UTIL_read_pw_string(buf, sizeof(buf), "input key: ", 0);
708 if (code || strlen(buf) == 0) {
709 fprintf(stderr, "Bad key: \n");
712 code = UI_UTIL_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
713 if (code || strlen(ver) == 0) {
714 fprintf(stderr, "Bad key: \n");
717 if (strcmp(ver, buf) != 0) {
718 fprintf(stderr, "\nInput key mismatch\n");
724 temp = atoi(as->parms[2].items->data);
728 strcpy((char *)&tkey, as->parms[1].items->data);
730 strcpy((char *)&tkey, buf);
731 } else { /* kerberos key */
733 if (as->parms[ADDPARMOFFSET].items) {
734 tcell = strdup(as->parms[ADDPARMOFFSET].items->data);
736 fprintf(stderr, "bos: Unable to allocate memory for cellname\n");
740 /* string to key needs upper-case cell names */
742 /* I don't believe this is true. The string to key function
743 * actually expands the cell name, then LOWER-CASES it. Perhaps it
744 * didn't use to??? */
745 ucstring(tcell, tcell, strlen(tcell));
747 tcell = NULL; /* no cell specified, use current */
749 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
751 ka_StringToKey(buf, tcell, &tkey);
756 code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey));
758 printf("bos: failed to set key %d (%s)\n", temp, em(code));
765 RemoveKey(struct cmd_syndesc *as, void *arock)
767 struct rx_connection *tconn;
772 tconn = GetConn(as, 0);
773 for (ti = as->parms[1].items; ti; ti = ti->next) {
774 temp = atoi(ti->data);
775 code = BOZO_DeleteKey(tconn, temp);
777 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
785 ListKeys(struct cmd_syndesc *as, void *arock)
787 struct rx_connection *tconn;
789 struct ktc_encryptionKey tkey;
791 struct bozo_keyInfo keyInfo;
795 tconn = GetConn(as, 1);
798 code = BOZO_ListKeys(tconn, i, &kvno, ktc_to_bozoptr(&tkey), &keyInfo);
802 /* first check if key is returned */
803 if ((!ka_KeyIsZero((char *)&tkey, sizeof(tkey)))
804 && (as->parms[1].items)) {
805 printf("key %d is '", kvno);
806 ka_PrintBytes((char *)&tkey, sizeof(tkey));
809 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
810 printf("key version is %d\n", kvno);
812 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
816 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
819 printf("bos: %s error encountered while listing keys\n", em(code));
821 printf("All done.\n");
826 AddSUser(struct cmd_syndesc *as, void *arock)
828 struct rx_connection *tconn;
834 tconn = GetConn(as, 0);
835 for (ti = as->parms[1].items; ti; ti = ti->next) {
836 code = BOZO_AddSUser(tconn, ti->data);
838 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
846 RemoveSUser(struct cmd_syndesc *as, void *arock)
848 struct rx_connection *tconn;
854 tconn = GetConn(as, 0);
855 for (ti = as->parms[1].items; ti; ti = ti->next) {
856 code = BOZO_DeleteSUser(tconn, ti->data);
858 printf("bos: failed to delete user '%s', ", ti->data);
860 printf("(no such user)\n");
862 printf("(%s)\n", em(code));
869 #define NPERLINE 10 /* dudes to print per line */
871 ListSUsers(struct cmd_syndesc *as, void *arock)
873 struct rx_connection *tconn;
878 int lastNL, printGreeting;
880 tconn = GetConn(as, 0);
885 code = BOZO_ListSUsers(tconn, i, &tp);
889 printGreeting = 0; /* delay until after first call succeeds */
890 printf("SUsers are: ");
892 printf("%s ", tbuffer);
893 if ((i % NPERLINE) == NPERLINE - 1) {
900 /* a real error code, instead of scanned past end */
901 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
910 StatServer(struct cmd_syndesc *as, void *arock)
912 struct rx_connection *tconn;
915 char ibuffer[BOZO_BSSIZE];
919 /* int32p==1 is obsolete, smaller, printout */
920 int32p = (as->parms[2].items != 0 ? 2 : 0);
922 /* no parms does something pretty different */
923 if (as->parms[1].items)
924 return IStatServer(as, int32p);
926 tconn = GetConn(as, 0);
928 /* for each instance */
930 code = BOZO_EnumerateInstance(tconn, i, &tp);
934 printf("bos: failed to contact host's bosserver (%s).\n",
938 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
944 CreateServer(struct cmd_syndesc *as, void *arock)
946 struct rx_connection *tconn;
951 char *type, *name, *notifier = NONOTIFIER;
953 tconn = GetConn(as, 0);
954 for (i = 0; i < 6; i++)
956 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
959 name = as->parms[1].items->data;
960 type = as->parms[2].items->data;
961 if ((ti = as->parms[4].items)) {
965 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
966 parms[3], parms[4], notifier);
969 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
970 name, type, em(code));
976 DeleteServer(struct cmd_syndesc *as, void *arock)
978 struct rx_connection *tconn;
983 tconn = GetConn(as, 0);
984 for (ti = as->parms[1].items; ti; ti = ti->next) {
985 code = BOZO_DeleteBnode(tconn, ti->data);
988 printf("bos: can't delete running instance '%s'\n", ti->data);
990 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
998 StartServer(struct cmd_syndesc *as, void *arock)
1000 struct rx_connection *tconn;
1002 struct cmd_item *ti;
1005 tconn = GetConn(as, 0);
1006 for (ti = as->parms[1].items; ti; ti = ti->next) {
1007 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1009 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1016 StopServer(struct cmd_syndesc *as, void *arock)
1018 struct rx_connection *tconn;
1020 struct cmd_item *ti;
1023 tconn = GetConn(as, 0);
1024 for (ti = as->parms[1].items; ti; ti = ti->next) {
1025 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1027 printf("bos: failed to change stop instance '%s' (%s)\n",
1028 ti->data, em(code));
1030 if (as->parms[8].items) {
1031 code = BOZO_WaitAll(tconn);
1033 printf("bos: can't wait for processes to shutdown (%s)\n",
1040 DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2,
1041 char * aoutName, afs_int32 showlog, char * parallel,
1042 char * atmpDir, char * orphans, int dafs)
1047 char tbuffer[BOZO_BSSIZE];
1048 struct bozo_status istatus;
1049 struct rx_call *tcall;
1053 char partName[20]; /* canonical name for partition */
1054 afs_int32 partNumber;
1055 char *notifier = NONOTIFIER;
1058 /* if a partition was specified, canonicalize the name, since
1059 * the salvager has a stupid partition ID parser */
1061 partNumber = volutil_GetPartitionID(aparm1);
1062 if (partNumber < 0) {
1063 printf("bos: could not parse partition ID '%s'\n", aparm1);
1066 tp = volutil_PartitionName(partNumber);
1068 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1071 strcpy(partName, tp);
1075 /* open the file name */
1077 outFile = fopen(aoutName, "w");
1079 printf("bos: can't open specified SalvageLog file '%s'\n",
1083 closeIt = 1; /* close this file later */
1086 closeIt = 0; /* don't close this file later */
1089 for (code = 2; code < 6; code++)
1094 /* MUST pass canonical (wire-format) salvager path to bosserver */
1096 /* single volume salvage */
1098 /* for DAFS, we call the salvagserver binary with special options.
1099 * in this mode, it simply uses SALVSYNC to tell the currently
1100 * running salvageserver to offline and salvage the volume in question */
1101 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALSRV_FILEPATH, BOZO_BSSIZE);
1103 if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) +
1105 printf("bos: command line too big\n");
1109 strcat(tbuffer, " -client ");
1110 strcat(tbuffer, partName);
1111 strcat(tbuffer, " ");
1112 strcat(tbuffer, aparm2);
1114 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1116 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1118 printf("bos: command line too big\n");
1122 strcat(tbuffer, " ");
1123 strcat(tbuffer, partName);
1124 strcat(tbuffer, " ");
1125 strcat(tbuffer, aparm2);
1128 /* partition salvage */
1129 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1130 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1131 printf("bos: command line too big\n");
1134 strcat(tbuffer, " -force ");
1135 strcat(tbuffer, partName);
1138 /* For DAFS, specifying a single volume does not result in a standard
1139 * salvager call. Instead, it simply results in a SALVSYNC call to the
1140 * online salvager daemon. This interface does not give us the same rich
1141 * set of call flags. Thus, we skip these steps for DAFS single-volume
1143 if (!dafs || (*aparm2 == 0)) {
1144 /* add the parallel option if given */
1145 if (parallel != NULL) {
1146 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1147 printf("bos: command line too big\n");
1150 strcat(tbuffer, " -parallel ");
1151 strcat(tbuffer, parallel);
1154 /* add the tmpdir option if given */
1155 if (atmpDir != NULL) {
1156 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1157 printf("bos: command line too big\n");
1160 strcat(tbuffer, " -tmpdir ");
1161 strcat(tbuffer, atmpDir);
1164 /* add the orphans option if given */
1165 if (orphans != NULL) {
1166 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1167 printf("bos: command line too big\n");
1170 strcat(tbuffer, " -orphans ");
1171 strcat(tbuffer, orphans);
1176 parms[1] = "now"; /* when to do it */
1178 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1179 parms[2], parms[3], parms[4], notifier);
1181 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1184 /* now wait for bnode to disappear */
1189 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1192 if ((++count % 5) == 0)
1193 printf("bos: waiting for salvage to complete.\n");
1195 if (code != BZNOENT) {
1196 printf("bos: salvage failed (%s)\n", em(code));
1201 /* now print the log file to the output file */
1202 printf("bos: salvage completed\n");
1203 if (aoutName || showlog) {
1204 fprintf(outFile, "SalvageLog:\n");
1205 tcall = rx_NewCall(aconn);
1206 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1208 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1210 rx_EndCall(tcall, code);
1215 code = rx_Read(tcall, &buffer, 1);
1218 putc(buffer, outFile);
1220 break; /* the end delimeter */
1222 code = rx_EndCall(tcall, 0);
1223 /* fall through into cleanup code */
1227 if (closeIt && outFile)
1233 GetLogCmd(struct cmd_syndesc *as, void *arock)
1235 struct rx_connection *tconn;
1236 struct rx_call *tcall;
1241 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1242 tconn = GetConn(as, 0);
1243 tcall = rx_NewCall(tconn);
1244 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1246 rx_EndCall(tcall, code);
1252 code = rx_Read(tcall, &buffer, 1);
1258 break; /* the end delimeter */
1261 code = rx_EndCall(tcall, error);
1262 /* fall through into cleanup code */
1266 afs_com_err("bos", code, "(while reading log)");
1271 IsDAFS(struct rx_connection *aconn)
1273 char buffer[BOZO_BSSIZE];
1275 struct bozo_status istatus;
1280 code = BOZO_GetInstanceInfo(aconn, "dafs", &tp, &istatus);
1282 /* no dafs bnode; cannot be dafs */
1286 /* dafs bnode is running; we must be dafs */
1290 /* At this point, either we have neither a dafs nor fs bnode running, or
1291 * we have an fs bnode running but the dafs bnode is stopped.
1293 * If an fs bnode is running, we are obviously not DAFS. If an fs bnode
1294 * is not running and a dafs bnode is not running... it's not certain if
1295 * we are DAFS or not DAFS. Just return 0 in that case; it shouldn't much
1296 * matter what we return, anyway */
1301 SalvageCmd(struct cmd_syndesc *as, void *arock)
1303 struct rx_connection *tconn;
1306 char tname[BOZO_BSSIZE];
1308 extern struct ubik_client *cstruct;
1309 afs_int32 curGoal, showlog = 0, dafs = 0;
1315 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1316 tconn = GetConn(as, 0);
1318 /* find out whether fileserver is running demand attach fs */
1319 if (IsDAFS(tconn)) {
1321 serviceName = "dafs";
1326 /* we can do a volume, a partition or the whole thing, but not mixtures
1328 if (!as->parms[1].items && as->parms[2].items) {
1329 printf("bos: must specify partition to salvage individual volume.\n");
1332 if (as->parms[5].items && as->parms[3].items) {
1333 printf("bos: can not specify both -file and -showlog.\n");
1336 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1337 printf("bos: can not specify -all with other flags.\n");
1341 /* get the output file name, if any */
1342 if (as->parms[3].items)
1343 outName = as->parms[3].items->data;
1347 if (as->parms[5].items)
1350 /* parallel option */
1352 if (as->parms[6].items)
1353 parallel = as->parms[6].items->data;
1355 /* get the tmpdir filename if any */
1357 if (as->parms[7].items)
1358 tmpDir = as->parms[7].items->data;
1360 /* -orphans option */
1362 if (as->parms[8].items) {
1363 orphans = as->parms[8].items->data;
1367 if (!as->parms[9].items) { /* -forceDAFS flag */
1368 printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n");
1369 printf("must specify -forceDAFS flag in order to proceed.\n");
1374 if (as->parms[4].items) {
1375 /* salvage whole enchilada */
1376 curGoal = GetServerGoal(tconn, serviceName);
1377 if (curGoal == BSTAT_NORMAL) {
1378 printf("bos: shutting down '%s'.\n", serviceName);
1379 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1381 printf("bos: failed to stop '%s' (%s)\n", serviceName, em(code));
1384 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1387 ("bos: failed to wait for file server shutdown, continuing.\n");
1389 /* now do the salvage operation */
1390 printf("Starting salvage.\n");
1391 rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
1393 if (curGoal == BSTAT_NORMAL) {
1394 printf("bos: restarting %s.\n", serviceName);
1395 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1397 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1403 } else if (!as->parms[2].items) {
1404 if (!as->parms[1].items) {
1406 ("bos: must specify -all switch to salvage all partitions.\n");
1409 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1410 /* can't parse volume ID, so complain before shutting down
1413 printf("bos: can't interpret %s as partition ID.\n",
1414 as->parms[1].items->data);
1417 curGoal = GetServerGoal(tconn, serviceName);
1418 /* salvage a whole partition (specified by parms[1]) */
1419 if (curGoal == BSTAT_NORMAL) {
1420 printf("bos: shutting down '%s'.\n", serviceName);
1421 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1423 printf("bos: can't stop '%s' (%s)\n", serviceName, em(code));
1426 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1429 ("bos: failed to wait for file server shutdown, continuing.\n");
1431 /* now do the salvage operation */
1432 printf("Starting salvage.\n");
1433 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1434 showlog, parallel, tmpDir, orphans, dafs);
1435 if (curGoal == BSTAT_NORMAL) {
1436 printf("bos: restarting '%s'.\n", serviceName);
1437 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1439 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1446 /* salvage individual volume (don't shutdown fs first), just use
1447 * single-shot cron bnode. Must leave server running when using this
1448 * option, since salvager will ask file server for the volume */
1451 const char *confdir;
1454 if (as->parms[ADDPARMOFFSET].items)
1455 tmpname = as->parms[ADDPARMOFFSET].items->data;
1459 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1461 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1462 AFSDIR_CLIENT_ETC_DIRPATH);
1464 code = vsu_ClientInit(confdir, tmpname,
1465 AFSCONF_SECOPTS_FALLBACK_NULL |
1466 AFSCONF_SECOPTS_NOAUTH,
1470 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1472 printf("bos: can't interpret %s as volume name or ID\n",
1473 as->parms[2].items->data);
1476 sprintf(tname, "%u", newID);
1479 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1481 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1483 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1484 /* can't parse volume ID, so complain before shutting down
1487 printf("bos: can't interpret %s as partition ID.\n",
1488 as->parms[1].items->data);
1491 printf("Starting salvage.\n");
1492 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1493 showlog, parallel, tmpDir, orphans, dafs);
1501 IStatServer(struct cmd_syndesc *as, int int32p)
1503 struct rx_connection *tconn;
1504 struct cmd_item *ti;
1507 tconn = GetConn(as, 0);
1508 for (ti = as->parms[1].items; ti; ti = ti->next) {
1509 DoStat(ti->data, tconn, int32p, firstTime);
1516 DoStat(IN char *aname,
1517 IN struct rx_connection *aconn,
1519 IN int firstTime) /* true iff first instance in cmd */
1525 struct bozo_status istatus;
1527 char *is1, *is2, *is3, *is4; /* instance strings */
1530 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1532 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1536 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1538 ("Bosserver reports inappropriate access on server directories\n");
1539 printf("Instance %s, ", aname);
1541 printf("(type is %s) ", buffer);
1542 if (istatus.fileGoal == istatus.goal) {
1544 printf("disabled, ");
1546 if (istatus.fileGoal)
1547 printf("temporarily disabled, ");
1549 printf("temporarily enabled, ");
1552 if (istatus.flags & BOZO_ERRORSTOP)
1553 printf("stopped for too many errors, ");
1554 if (istatus.flags & BOZO_HASCORE)
1555 printf("has core file, ");
1558 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1560 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1563 printf("currently ");
1564 if (temp == BSTAT_NORMAL)
1565 printf("running normally.\n");
1566 else if (temp == BSTAT_SHUTDOWN)
1567 printf("shutdown.\n");
1568 else if (temp == BSTAT_STARTINGUP)
1569 printf("starting up.\n");
1570 else if (temp == BSTAT_SHUTTINGDOWN)
1571 printf("shutting down.\n");
1572 if (buffer[0] != 0) {
1573 printf(" Auxiliary status is: %s.\n", buffer);
1577 /* are we done yet? */
1581 if (istatus.procStartTime)
1582 printf(" Process last started at %s (%d proc starts)\n",
1583 DateOf(istatus.procStartTime), istatus.procStarts);
1584 if (istatus.lastAnyExit) {
1585 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1587 if (istatus.lastErrorExit) {
1588 is1 = is2 = is3 = is4 = NULL;
1589 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1590 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1591 /* don't complain about failing call, since could simply mean
1592 * interface mismatch.
1596 /* non-null instance string */
1597 printf("by %s, ", is1);
1604 if (istatus.errorSignal) {
1605 if (istatus.errorSignal == SIGTERM)
1606 printf("due to shutdown request\n");
1608 printf("due to signal %d\n", istatus.errorSignal);
1610 printf("by exiting with code %d\n", istatus.errorCode);
1614 /* try to display all the parms */
1617 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1620 printf(" Command %d is '%s'\n", i + 1, buffer);
1623 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1625 /* Any type of failure is treated as not having a notifier program */
1626 printf(" Notifier is '%s'\n", buffer);
1634 GetRestrict(struct cmd_syndesc *as, void *arock)
1636 struct rx_connection *tconn;
1637 afs_int32 code, val;
1639 tconn = GetConn(as, 0);
1640 code = BOZO_GetRestrictedMode(tconn, &val);
1642 printf("bos: failed to get restricted mode (%s)\n", em(code));
1644 printf("Restricted mode is %s\n", val ? "on" : "off");
1650 SetRestrict(struct cmd_syndesc *as, void *arock)
1652 struct rx_connection *tconn;
1653 afs_int32 code, val;
1655 tconn = GetConn(as, 0);
1656 util_GetInt32(as->parms[1].items->data, &val);
1657 code = BOZO_SetRestrictedMode(tconn, val);
1659 printf("bos: failed to set restricted mode (%s)\n", em(code));
1664 add_std_args(struct cmd_syndesc *ts)
1666 cmd_Seek(ts, ADDPARMOFFSET);
1667 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1668 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1669 "don't authenticate");
1670 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1671 "create tickets from KeyFile");
1674 #include "AFS_component_version_number.c"
1677 main(int argc, char **argv)
1680 struct cmd_syndesc *ts;
1682 __declspec(dllimport)
1684 extern int afsconf_SawCell;
1686 #ifdef AFS_AIX32_ENV
1688 * The following signal action for AIX is necessary so that in case of a
1689 * crash (i.e. core is generated) we can include the user's data section
1690 * in the core dump. Unfortunately, by default, only a partial core is
1691 * generated which, in many cases, isn't too useful.
1693 struct sigaction nsa;
1695 sigemptyset(&nsa.sa_mask);
1696 nsa.sa_handler = SIG_DFL;
1697 nsa.sa_flags = SA_FULLDUMP;
1698 sigaction(SIGSEGV, &nsa, NULL);
1699 sigaction(SIGABRT, &nsa, NULL);
1705 printf("bos: could not initialize rx (%s)\n", em(code));
1709 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1710 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1711 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1712 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1713 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1715 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1717 afsconf_SawCell = 0; /* Reset it */
1718 /* don't check error code, since fails sometimes when we're setting up a
1720 initialize_CMD_error_table();
1721 initialize_BZ_error_table();
1723 ts = cmd_CreateSyntax("start", StartServer, NULL, "start running a server");
1724 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1725 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1728 ts = cmd_CreateSyntax("stop", StopServer, NULL, "halt a server instance");
1729 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1730 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1732 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1733 "wait for process to stop");
1736 ts = cmd_CreateSyntax("status", StatServer, NULL,
1737 "show server instance status");
1738 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1739 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1740 "server process name");
1741 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1744 ts = cmd_CreateSyntax("shutdown", Shutdown, NULL, "shutdown all processes");
1745 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1746 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1748 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1749 "wait for process to stop");
1752 ts = cmd_CreateSyntax("startup", Startup, NULL, "start all processes");
1753 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1754 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1757 ts = cmd_CreateSyntax("restart", Restart, NULL, "restart processes");
1758 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1759 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1760 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
1761 "restart bosserver");
1762 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
1767 ts = cmd_CreateSyntax("create", CreateServer, NULL,
1768 "create a new server instance");
1769 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1770 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
1771 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
1772 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
1773 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
1774 "Notifier program");
1777 ts = cmd_CreateSyntax("delete", DeleteServer, NULL,
1778 "delete a server instance");
1779 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1780 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1783 ts = cmd_CreateSyntax("adduser", AddSUser, NULL,
1784 "add users to super-user list");
1785 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1786 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
1789 ts = cmd_CreateSyntax("removeuser", RemoveSUser, NULL,
1790 "remove users from super-user list");
1791 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1792 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
1795 ts = cmd_CreateSyntax("listusers", ListSUsers, NULL, "list super-users");
1796 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1799 ts = cmd_CreateSyntax("addkey", AddKey, NULL,
1800 "add keys to key dbase (kvno 999 is bcrypt)");
1801 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1802 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
1803 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
1806 ts = cmd_CreateSyntax("removekey", RemoveKey, NULL,
1807 "remove keys from key dbase");
1808 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1809 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
1812 ts = cmd_CreateSyntax("listkeys", ListKeys, NULL, "list keys");
1813 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1814 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
1815 "show the actual key rather than the checksum");
1818 ts = cmd_CreateSyntax("listhosts", ListHosts, NULL, "get cell host list");
1819 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1821 cmd_CreateAlias(ts, "getcell");
1823 ts = cmd_CreateSyntax("setcellname", SetCellName, NULL, "set cell name");
1824 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1825 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
1828 ts = cmd_CreateSyntax("addhost", AddHost, NULL, "add host to cell dbase");
1829 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1830 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
1831 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
1834 ts = cmd_CreateSyntax("removehost", RemoveHost, NULL,
1835 "remove host from cell dbase");
1836 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1837 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
1840 ts = cmd_CreateSyntax("setauth", SetAuth, NULL,
1841 "set authentication required flag");
1842 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1843 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
1844 "on or off: authentication required for admin requests");
1847 ts = cmd_CreateSyntax("install", Install, NULL, "install program");
1848 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1849 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
1850 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
1853 ts = cmd_CreateSyntax("uninstall", UnInstall, NULL, "uninstall program");
1854 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1855 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
1856 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
1859 ts = cmd_CreateSyntax("getlog", GetLogCmd, NULL, "examine log file");
1860 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1861 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
1864 ts = cmd_CreateSyntax("getdate", GetDate, NULL, "get dates for programs");
1865 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1866 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
1867 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
1870 ts = cmd_CreateSyntax("exec", Exec, NULL, "execute shell command on server");
1871 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1872 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
1875 ts = cmd_CreateSyntax("prune", Prune, NULL, "prune server files");
1876 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1877 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
1878 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
1879 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
1880 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
1883 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, NULL,
1884 "set restart times");
1885 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
1886 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
1887 "time to restart server");
1888 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
1889 "set general restart time");
1890 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
1891 "set new binary restart time");
1893 cmd_CreateAlias(ts, "setr");
1895 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, NULL,
1896 "get restart times");
1897 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
1899 cmd_CreateAlias(ts, "getr");
1901 ts = cmd_CreateSyntax("salvage", SalvageCmd, NULL,
1902 "salvage partition or volumes");
1903 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1904 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1905 "salvage partition");
1906 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
1907 "salvage volume number or volume name");
1908 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
1909 "salvage log output file");
1910 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
1911 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
1912 "display salvage log");
1913 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
1914 "# of max parallel partition salvaging");
1915 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
1916 "directory to place tmp files");
1917 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
1918 "ignore | remove | attach");
1919 cmd_AddParm(ts, "-forceDAFS", CMD_FLAG, CMD_OPTIONAL,
1920 "(DAFS) force salvage of demand attach fileserver");
1923 ts = cmd_CreateSyntax("getrestricted", GetRestrict, NULL,
1924 "get restrict mode");
1925 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1928 ts = cmd_CreateSyntax("setrestricted", SetRestrict, NULL,
1929 "set restrict mode");
1930 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1931 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
1935 code = cmd_Dispatch(argc, argv);