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 MRAFS_OFFSET 10
45 #define ADDPARMOFFSET 27
47 /* dummy routine for the audit work. It should do nothing since audits */
48 /* occur at the server level and bos is not a server. */
54 /* keep those lines small */
59 return "communications failure (-1)";
61 return "communications timeout (-3)";
63 return (char *)afs_error_message(acode);
66 /* make ctime easier to use */
70 static char tbuffer[30];
74 strlcpy(tbuffer, tp, sizeof(tbuffer));
75 tbuffer[24] = 0; /* get rid of new line */
77 strcpy(tbuffer, "BAD TIME");
82 /* use the syntax descr to get a connection, authenticated appropriately.
83 * aencrypt is set if we want to encrypt the data on the wire.
85 static struct rx_connection *
86 GetConn(struct cmd_syndesc *as, int aencrypt)
90 char *cellname = NULL;
93 struct rx_connection *tconn;
95 struct afsconf_dir *tdir = NULL;
96 afsconf_secflags secFlags;
97 struct rx_securityClass *sc;
100 hostname = as->parms[0].items->data;
101 th = hostutil_GetHostByName(hostname);
103 printf("bos: can't find address for host '%s'\n", hostname);
106 memcpy(&addr, th->h_addr, sizeof(afs_int32));
109 secFlags = AFSCONF_SECOPTS_ALWAYSENCRYPT;
111 secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
114 if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
115 secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
116 confdir = AFSDIR_SERVER_ETC_DIRPATH;
118 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
121 if (as->parms[ADDPARMOFFSET + 1].items) { /* -noauth */
122 secFlags |= AFSCONF_SECOPTS_NOAUTH;
124 /* If we're running with -noauth, we don't need a configuration
126 tdir = afsconf_Open(confdir);
128 printf("bos: can't open cell database (%s)\n", confdir);
133 if (as->parms[ADDPARMOFFSET].items) /* -cell */
134 cellname = as->parms[ADDPARMOFFSET].items->data;
136 code = afsconf_PickClientSecObj(tdir, secFlags, NULL, cellname,
137 &sc, &scIndex, NULL);
139 afs_com_err("bos", code, "(configuring connection security)");
143 if (scIndex == RX_SECIDX_NULL)
144 fprintf(stderr, "bos: running unauthenticated\n");
147 rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc, scIndex);
149 fprintf(stderr, "bos: could not create rx connection\n");
158 SetAuth(struct cmd_syndesc *as, void *arock)
161 struct rx_connection *tconn;
165 tconn = GetConn(as, 0);
166 tp = as->parms[1].items->data;
167 if (strcmp(tp, "on") == 0)
168 flag = 0; /* auth req.: noauthflag is false */
169 else if (strcmp(tp, "off") == 0)
173 ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n",
177 code = BOZO_SetNoAuthFlag(tconn, flag);
179 afs_com_err("bos", code, "(failed to set authentication flag)");
183 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
184 * /usr/afs/bin/bar */
186 ComputeDestDir(char *aname, char *adir, char *aresult, afs_int32 alen)
190 strcpy(aresult, adir);
191 tp = strrchr(aname, '/');
194 strcat(aresult, "/");
195 strcat(aresult, aname);
197 /* tp points at the / character */
203 /* copy data from fd afd to rx call acall */
205 CopyBytes(int afd, struct rx_call *acall)
212 len = read(afd, tbuffer, sizeof(tbuffer));
216 return 0; /* all done */
217 code = rx_Write(acall, tbuffer, len);
224 Prune(struct cmd_syndesc *as, void *arock)
227 struct rx_connection *tconn;
230 tconn = GetConn(as, 0);
232 if (as->parms[1].items)
233 flags |= BOZO_PRUNEBAK;
234 if (as->parms[2].items)
235 flags |= BOZO_PRUNEOLD;
236 if (as->parms[3].items)
237 flags |= BOZO_PRUNECORE;
238 if (as->parms[4].items)
240 code = BOZO_Prune(tconn, flags);
242 afs_com_err("bos", code, "(failed to prune server files)");
247 Exec(struct cmd_syndesc *as, void *arock)
249 struct rx_connection *tconn;
252 tconn = GetConn(as, 0);
253 code = BOZO_Exec(tconn, as->parms[1].items->data);
255 printf("bos: failed to execute command (%s)\n", em(code));
260 GetDate(struct cmd_syndesc *as, void *arock)
265 afs_int32 time, bakTime, oldTime;
266 struct rx_connection *tconn;
269 tconn = GetConn(as, 0);
270 if (!as->parms[1].items) {
271 printf("bos: no files to check\n");
275 /* compute dest dir or file; default MUST be canonical form of dir path */
276 if (as->parms[2].items)
277 strcpy(destDir, as->parms[2].items->data);
279 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
281 for (ti = as->parms[1].items; ti; ti = ti->next) {
282 /* check date for each file */
283 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
284 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
286 printf("bos: failed to check date on %s (%s)\n", ti->data,
290 printf("File %s ", tbuffer);
292 printf("does not exist, ");
294 printf("dated %s, ", DateOf(time));
296 printf("no .BAK file, ");
298 printf(".BAK file dated %s, ", DateOf(bakTime));
300 printf("no .OLD file.");
302 printf(".OLD file dated %s.", DateOf(oldTime));
310 UnInstall(struct cmd_syndesc *as, void *arock)
316 struct rx_connection *tconn;
318 tconn = GetConn(as, 0);
319 if (!as->parms[1].items) {
320 printf("bos: no files to uninstall\n");
324 /* compute dest dir or file; default MUST be canonical form of dir path */
325 if (as->parms[2].items)
326 strcpy(destDir, as->parms[2].items->data);
328 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
330 for (ti = as->parms[1].items; ti; ti = ti->next) {
331 /* uninstall each file */
332 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
333 code = BOZO_UnInstall(tconn, tbuffer);
335 printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code));
338 printf("bos: uninstalled file %s\n", ti->data);
344 GetServerGoal(struct rx_connection *aconn, char *aname)
349 struct bozo_status istatus;
352 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
354 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
356 /* if we can't get the answer, assume its running */
359 if (istatus.goal == 0)
360 return BSTAT_SHUTDOWN;
366 Install(struct cmd_syndesc *as, void *arock)
368 struct rx_connection *tconn;
374 struct rx_call *tcall;
377 tconn = GetConn(as, 0);
378 if (!as->parms[1].items) {
379 printf("bos: no files to install\n");
383 /* compute dest dir or file; default MUST be canonical form of dir path */
384 if (as->parms[2].items)
385 strcpy(destDir, as->parms[2].items->data);
387 strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
389 for (ti = as->parms[1].items; ti; ti = ti->next) {
390 /* install each file */
391 fd = open(ti->data, O_RDONLY);
393 /* better to quit on error than continue for install command */
394 printf("bos: can't find file '%s', quitting\n", ti->data);
397 code = fstat(fd, &tstat);
399 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
403 /* compute destination dir */
404 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
405 tcall = rx_NewCall(tconn);
407 StartBOZO_Install(tcall, tbuffer, tstat.st_size,
408 (afs_int32) tstat.st_mode, tstat.st_mtime);
410 code = CopyBytes(fd, tcall);
412 code = rx_EndCall(tcall, code);
414 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
417 printf("bos: installed file %s\n", ti->data);
423 Shutdown(struct cmd_syndesc *as, void *arock)
425 struct rx_connection *tconn;
429 tconn = GetConn(as, 0);
430 if (as->parms[1].items == 0) {
431 code = BOZO_ShutdownAll(tconn);
433 printf("bos: failed to shutdown servers (%s)\n", em(code));
435 for (ti = as->parms[1].items; ti; ti = ti->next) {
436 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
438 printf("bos: failed to shutdown instance %s (%s)\n", ti->data,
442 if (as->parms[8].items) {
443 code = BOZO_WaitAll(tconn);
445 printf("bos: can't wait for processes to shutdown (%s)\n",
452 GetRestartCmd(struct cmd_syndesc *as, void *arock)
455 struct ktime generalTime, newBinaryTime;
456 char messageBuffer[256];
457 struct rx_connection *tconn;
460 hostp = as->parms[0].items->data; /* host name for messages */
461 tconn = GetConn(as, 0);
463 code = BOZO_GetRestartTime(tconn, 1, (struct bozo_netKTime *) &generalTime);
465 printf("bos: failed to retrieve restart information (%s)\n",
469 code = BOZO_GetRestartTime(tconn, 2, (struct bozo_netKTime *) &newBinaryTime);
471 printf("bos: failed to retrieve restart information (%s)\n",
476 code = ktime_DisplayString(&generalTime, messageBuffer);
478 printf("bos: failed to decode restart time (%s)\n", em(code));
481 printf("Server %s restarts %s\n", hostp, messageBuffer);
483 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
485 printf("bos: failed to decode restart time (%s)\n", em(code));
488 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
495 SetRestartCmd(struct cmd_syndesc *as, void *arock)
499 struct ktime restartTime;
501 struct rx_connection *tconn;
504 tconn = GetConn(as, 0);
505 if (as->parms[2].items) {
509 if (as->parms[3].items) {
514 printf("bos: can't specify more than one restart time at a time\n");
518 type = 1; /* by default set general restart time */
520 if ((code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime))) {
521 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
522 as->parms[1].items->data, em(code));
526 code = BOZO_SetRestartTime(tconn, type, (struct bozo_netKTime *) &restartTime);
528 printf("bos: failed to set restart time at server (%s)\n", em(code));
535 Startup(struct cmd_syndesc *as, void *arock)
537 struct rx_connection *tconn;
541 tconn = GetConn(as, 0);
542 if (as->parms[1].items == 0) {
543 code = BOZO_StartupAll(tconn);
545 printf("bos: failed to startup servers (%s)\n", em(code));
547 for (ti = as->parms[1].items; ti; ti = ti->next) {
548 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
550 printf("bos: failed to start instance %s (%s)\n", ti->data,
558 Restart(struct cmd_syndesc *as, void *arock)
560 struct rx_connection *tconn;
564 tconn = GetConn(as, 0);
565 if (as->parms[2].items) {
566 /* this is really a rebozo command */
567 if (as->parms[1].items) {
568 /* specified specific things to restart, can't do this at the same
571 ("bos: can't specify both '-bos' and specific servers to restart.\n");
574 /* otherwise do a rebozo */
575 code = BOZO_ReBozo(tconn);
577 printf("bos: failed to restart bosserver (%s)\n", em(code));
580 if (as->parms[1].items == 0) {
581 if (as->parms[3].items) { /* '-all' */
582 code = BOZO_RestartAll(tconn);
584 printf("bos: failed to restart servers (%s)\n", em(code));
586 printf("bos: To restart all processes please specify '-all'\n");
588 if (as->parms[3].items) {
589 printf("bos: Can't use '-all' along with individual instances\n");
591 for (ti = as->parms[1].items; ti; ti = ti->next) {
592 code = BOZO_Restart(tconn, ti->data);
594 printf("bos: failed to restart instance %s (%s)\n",
603 SetCellName(struct cmd_syndesc *as, void *arock)
605 struct rx_connection *tconn;
608 tconn = GetConn(as, 0);
609 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
611 printf("bos: failed to set cell (%s)\n", em(code));
616 AddHost(struct cmd_syndesc *as, void *arock)
618 struct rx_connection *tconn;
621 char name[MAXHOSTCHARS];
623 tconn = GetConn(as, 0);
624 for (ti = as->parms[1].items; ti; ti = ti->next) {
625 if (as->parms[2].items) {
626 if (strlen(ti->data) > MAXHOSTCHARS - 3) {
627 fprintf(stderr, "bos: host name too long\n");
631 strcpy(&name[1], ti->data);
632 strcat((char *)&name, "]");
633 code = BOZO_AddCellHost(tconn, name);
635 code = BOZO_AddCellHost(tconn, ti->data);
637 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
643 RemoveHost(struct cmd_syndesc *as, void *arock)
645 struct rx_connection *tconn;
649 tconn = GetConn(as, 0);
650 for (ti = as->parms[1].items; ti; ti = ti->next) {
651 code = BOZO_DeleteCellHost(tconn, ti->data);
653 printf("bos: failed to delete host %s (%s)\n", ti->data,
660 ListHosts(struct cmd_syndesc *as, void *arock)
662 struct rx_connection *tconn;
669 tconn = GetConn(as, 0);
670 code = BOZO_GetCellName(tconn, &tp);
672 printf("bos: failed to get cell name (%s)\n", em(code));
675 printf("Cell name is %s\n", tbuffer);
677 code = BOZO_GetCellHost(tconn, i, &tp);
681 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
684 printf(" Host %d is %s\n", i + 1, tbuffer);
690 AddKey(struct cmd_syndesc *as, void *arock)
692 struct rx_connection *tconn;
694 struct ktc_encryptionKey tkey;
696 char buf[BUFSIZ], ver[BUFSIZ];
698 tconn = GetConn(as, 1);
699 memset(&tkey, 0, sizeof(struct ktc_encryptionKey));
701 if (as->parms[1].items) {
702 if (strlcpy(buf, as->parms[1].items->data, sizeof(buf)) >= sizeof(buf)) {
703 fprintf(stderr, "Key data too long for buffer\n");
708 code = UI_UTIL_read_pw_string(buf, sizeof(buf), "input key: ", 0);
709 if (code || strlen(buf) == 0) {
710 fprintf(stderr, "Bad key: \n");
713 code = UI_UTIL_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0);
714 if (code || strlen(ver) == 0) {
715 fprintf(stderr, "Bad key: \n");
718 if (strcmp(ver, buf) != 0) {
719 fprintf(stderr, "\nInput key mismatch\n");
725 temp = atoi(as->parms[2].items->data);
729 strcpy((char *)&tkey, as->parms[1].items->data);
731 strcpy((char *)&tkey, buf);
732 } else { /* kerberos key */
734 if (as->parms[ADDPARMOFFSET].items) {
735 tcell = strdup(as->parms[ADDPARMOFFSET].items->data);
737 fprintf(stderr, "bos: Unable to allocate memory for cellname\n");
741 /* string to key needs upper-case cell names */
743 /* I don't believe this is true. The string to key function
744 * actually expands the cell name, then LOWER-CASES it. Perhaps it
745 * didn't use to??? */
746 ucstring(tcell, tcell, strlen(tcell));
748 tcell = NULL; /* no cell specified, use current */
750 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
752 ka_StringToKey(buf, tcell, &tkey);
757 code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey));
759 printf("bos: failed to set key %d (%s)\n", temp, em(code));
766 RemoveKey(struct cmd_syndesc *as, void *arock)
768 struct rx_connection *tconn;
773 tconn = GetConn(as, 0);
774 for (ti = as->parms[1].items; ti; ti = ti->next) {
775 temp = atoi(ti->data);
776 code = BOZO_DeleteKey(tconn, temp);
778 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
786 ListKeys(struct cmd_syndesc *as, void *arock)
788 struct rx_connection *tconn;
790 struct ktc_encryptionKey tkey;
792 struct bozo_keyInfo keyInfo;
796 tconn = GetConn(as, 1);
799 code = BOZO_ListKeys(tconn, i, &kvno, ktc_to_bozoptr(&tkey), &keyInfo);
803 /* first check if key is returned */
804 if ((!ka_KeyIsZero((char *)&tkey, sizeof(tkey)))
805 && (as->parms[1].items)) {
806 printf("key %d is '", kvno);
807 ka_PrintBytes((char *)&tkey, sizeof(tkey));
810 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
811 printf("key version is %d\n", kvno);
813 printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
817 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
820 printf("bos: %s error encountered while listing keys\n", em(code));
822 printf("All done.\n");
827 AddSUser(struct cmd_syndesc *as, void *arock)
829 struct rx_connection *tconn;
835 tconn = GetConn(as, 0);
836 for (ti = as->parms[1].items; ti; ti = ti->next) {
837 code = BOZO_AddSUser(tconn, ti->data);
839 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
847 RemoveSUser(struct cmd_syndesc *as, void *arock)
849 struct rx_connection *tconn;
855 tconn = GetConn(as, 0);
856 for (ti = as->parms[1].items; ti; ti = ti->next) {
857 code = BOZO_DeleteSUser(tconn, ti->data);
859 printf("bos: failed to delete user '%s', ", ti->data);
861 printf("(no such user)\n");
863 printf("(%s)\n", em(code));
870 #define NPERLINE 10 /* dudes to print per line */
872 ListSUsers(struct cmd_syndesc *as, void *arock)
874 struct rx_connection *tconn;
879 int lastNL, printGreeting;
881 tconn = GetConn(as, 0);
886 code = BOZO_ListSUsers(tconn, i, &tp);
890 printGreeting = 0; /* delay until after first call succeeds */
891 printf("SUsers are: ");
893 printf("%s ", tbuffer);
894 if ((i % NPERLINE) == NPERLINE - 1) {
901 /* a real error code, instead of scanned past end */
902 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
911 StatServer(struct cmd_syndesc *as, void *arock)
913 struct rx_connection *tconn;
916 char ibuffer[BOZO_BSSIZE];
920 /* int32p==1 is obsolete, smaller, printout */
921 int32p = (as->parms[2].items != 0 ? 2 : 0);
923 /* no parms does something pretty different */
924 if (as->parms[1].items)
925 return IStatServer(as, int32p);
927 tconn = GetConn(as, 0);
929 /* for each instance */
931 code = BOZO_EnumerateInstance(tconn, i, &tp);
935 printf("bos: failed to contact host's bosserver (%s).\n",
939 DoStat(ibuffer, tconn, int32p, (i == 0)); /* print status line */
945 CreateServer(struct cmd_syndesc *as, void *arock)
947 struct rx_connection *tconn;
952 char *type, *name, *notifier = NONOTIFIER;
954 tconn = GetConn(as, 0);
955 for (i = 0; i < 6; i++)
957 for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) {
960 name = as->parms[1].items->data;
961 type = as->parms[2].items->data;
962 if ((ti = as->parms[4].items)) {
966 BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
967 parms[3], parms[4], notifier);
970 ("bos: failed to create new server instance %s of type '%s' (%s)\n",
971 name, type, em(code));
977 DeleteServer(struct cmd_syndesc *as, void *arock)
979 struct rx_connection *tconn;
984 tconn = GetConn(as, 0);
985 for (ti = as->parms[1].items; ti; ti = ti->next) {
986 code = BOZO_DeleteBnode(tconn, ti->data);
989 printf("bos: can't delete running instance '%s'\n", ti->data);
991 printf("bos: failed to delete instance '%s' (%s)\n", ti->data,
999 StartServer(struct cmd_syndesc *as, void *arock)
1001 struct rx_connection *tconn;
1003 struct cmd_item *ti;
1006 tconn = GetConn(as, 0);
1007 for (ti = as->parms[1].items; ti; ti = ti->next) {
1008 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1010 printf("bos: failed to start instance '%s' (%s)\n", ti->data,
1017 StopServer(struct cmd_syndesc *as, void *arock)
1019 struct rx_connection *tconn;
1021 struct cmd_item *ti;
1024 tconn = GetConn(as, 0);
1025 for (ti = as->parms[1].items; ti; ti = ti->next) {
1026 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1028 printf("bos: failed to change stop instance '%s' (%s)\n",
1029 ti->data, em(code));
1031 if (as->parms[8].items) {
1032 code = BOZO_WaitAll(tconn);
1034 printf("bos: can't wait for processes to shutdown (%s)\n",
1040 #define PARMBUFFERSSIZE 32
1043 DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2,
1044 char * aoutName, afs_int32 showlog, char * parallel,
1045 char * atmpDir, char * orphans, int dafs)
1050 char tbuffer[BOZO_BSSIZE];
1051 struct bozo_status istatus;
1052 struct rx_call *tcall;
1056 char partName[20]; /* canonical name for partition */
1057 afs_int32 partNumber;
1058 char *notifier = NONOTIFIER;
1061 /* if a partition was specified, canonicalize the name, since
1062 * the salvager has a stupid partition ID parser */
1064 partNumber = volutil_GetPartitionID(aparm1);
1065 if (partNumber < 0) {
1066 printf("bos: could not parse partition ID '%s'\n", aparm1);
1069 tp = volutil_PartitionName(partNumber);
1071 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1074 strcpy(partName, tp);
1078 /* open the file name */
1080 outFile = fopen(aoutName, "w");
1082 printf("bos: can't open specified SalvageLog file '%s'\n",
1086 closeIt = 1; /* close this file later */
1089 closeIt = 0; /* don't close this file later */
1092 for (code = 2; code < 6; code++)
1097 /* MUST pass canonical (wire-format) salvager path to bosserver */
1099 /* single volume salvage */
1101 /* for DAFS, we call the salvagserver binary with special options.
1102 * in this mode, it simply uses SALVSYNC to tell the currently
1103 * running salvageserver to offline and salvage the volume in question */
1104 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALSRV_FILEPATH, BOZO_BSSIZE);
1106 if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) +
1108 printf("bos: command line too big\n");
1112 strcat(tbuffer, " -client ");
1113 strcat(tbuffer, partName);
1114 strcat(tbuffer, " ");
1115 strcat(tbuffer, aparm2);
1117 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1119 if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) +
1121 printf("bos: command line too big\n");
1125 strcat(tbuffer, " ");
1126 strcat(tbuffer, partName);
1127 strcat(tbuffer, " ");
1128 strcat(tbuffer, aparm2);
1131 /* partition salvage */
1132 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1133 if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) {
1134 printf("bos: command line too big\n");
1137 strcat(tbuffer, " -force ");
1138 strcat(tbuffer, partName);
1141 /* For DAFS, specifying a single volume does not result in a standard
1142 * salvager call. Instead, it simply results in a SALVSYNC call to the
1143 * online salvager daemon. This interface does not give us the same rich
1144 * set of call flags. Thus, we skip these steps for DAFS single-volume
1146 if (!dafs || (*aparm2 == 0)) {
1147 /* add the parallel option if given */
1148 if (parallel != NULL) {
1149 if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) {
1150 printf("bos: command line too big\n");
1153 strcat(tbuffer, " -parallel ");
1154 strcat(tbuffer, parallel);
1157 /* add the tmpdir option if given */
1158 if (atmpDir != NULL) {
1159 if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) {
1160 printf("bos: command line too big\n");
1163 strcat(tbuffer, " -tmpdir ");
1164 strcat(tbuffer, atmpDir);
1167 /* add the orphans option if given */
1168 if (orphans != NULL) {
1169 if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) {
1170 printf("bos: command line too big\n");
1173 strcat(tbuffer, " -orphans ");
1174 strcat(tbuffer, orphans);
1179 parms[1] = "now"; /* when to do it */
1181 BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1182 parms[2], parms[3], parms[4], notifier);
1184 printf("bos: failed to start 'salvager' (%s)\n", em(code));
1187 /* now wait for bnode to disappear */
1192 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1195 if ((++count % 5) == 0)
1196 printf("bos: waiting for salvage to complete.\n");
1198 if (code != BZNOENT) {
1199 printf("bos: salvage failed (%s)\n", em(code));
1204 /* now print the log file to the output file */
1205 printf("bos: salvage completed\n");
1206 if (aoutName || showlog) {
1207 fprintf(outFile, "SalvageLog:\n");
1208 tcall = rx_NewCall(aconn);
1209 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1211 StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1213 rx_EndCall(tcall, code);
1218 code = rx_Read(tcall, &buffer, 1);
1221 putc(buffer, outFile);
1223 break; /* the end delimeter */
1225 code = rx_EndCall(tcall, 0);
1226 /* fall through into cleanup code */
1230 if (closeIt && outFile)
1236 GetLogCmd(struct cmd_syndesc *as, void *arock)
1238 struct rx_connection *tconn;
1239 struct rx_call *tcall;
1244 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1245 tconn = GetConn(as, 0);
1246 tcall = rx_NewCall(tconn);
1247 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1249 rx_EndCall(tcall, code);
1255 code = rx_Read(tcall, &buffer, 1);
1261 break; /* the end delimeter */
1264 code = rx_EndCall(tcall, error);
1265 /* fall through into cleanup code */
1269 afs_com_err("bos", code, "(while reading log)");
1274 IsDAFS(struct rx_connection *aconn)
1276 char buffer[BOZO_BSSIZE];
1278 struct bozo_status istatus;
1283 code = BOZO_GetInstanceInfo(aconn, "dafs", &tp, &istatus);
1285 /* no dafs bnode; cannot be dafs */
1289 /* dafs bnode is running; we must be dafs */
1293 /* At this point, either we have neither a dafs nor fs bnode running, or
1294 * we have an fs bnode running but the dafs bnode is stopped.
1296 * If an fs bnode is running, we are obviously not DAFS. If an fs bnode
1297 * is not running and a dafs bnode is not running... it's not certain if
1298 * we are DAFS or not DAFS. Just return 0 in that case; it shouldn't much
1299 * matter what we return, anyway */
1304 SalvageCmd(struct cmd_syndesc *as, void *arock)
1306 struct rx_connection *tconn;
1309 char tname[BOZO_BSSIZE];
1311 extern struct ubik_client *cstruct;
1312 afs_int32 curGoal, showlog = 0, dafs = 0;
1318 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1319 tconn = GetConn(as, 0);
1321 /* find out whether fileserver is running demand attach fs */
1322 if (IsDAFS(tconn)) {
1324 serviceName = "dafs";
1329 /* we can do a volume, a partition or the whole thing, but not mixtures
1331 if (!as->parms[1].items && as->parms[2].items) {
1332 printf("bos: must specify partition to salvage individual volume.\n");
1335 if (as->parms[5].items && as->parms[3].items) {
1336 printf("bos: can not specify both -file and -showlog.\n");
1339 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1340 printf("bos: can not specify -all with other flags.\n");
1344 /* get the output file name, if any */
1345 if (as->parms[3].items)
1346 outName = as->parms[3].items->data;
1350 if (as->parms[5].items)
1353 /* parallel option */
1355 if (as->parms[6].items)
1356 parallel = as->parms[6].items->data;
1358 /* get the tmpdir filename if any */
1360 if (as->parms[7].items)
1361 tmpDir = as->parms[7].items->data;
1363 /* -orphans option */
1365 if (as->parms[8].items) {
1366 orphans = as->parms[8].items->data;
1370 if (!as->parms[9].items) { /* -forceDAFS flag */
1371 printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n");
1372 printf("must specify -forceDAFS flag in order to proceed.\n");
1377 if (as->parms[4].items) {
1378 /* salvage whole enchilada */
1379 curGoal = GetServerGoal(tconn, serviceName);
1380 if (curGoal == BSTAT_NORMAL) {
1381 printf("bos: shutting down '%s'.\n", serviceName);
1382 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1384 printf("bos: failed to stop '%s' (%s)\n", serviceName, em(code));
1387 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1390 ("bos: failed to wait for file server shutdown, continuing.\n");
1392 /* now do the salvage operation */
1393 printf("Starting salvage.\n");
1394 rc = DoSalvage(tconn, NULL, NULL, outName, showlog, parallel, tmpDir,
1396 if (curGoal == BSTAT_NORMAL) {
1397 printf("bos: restarting %s.\n", serviceName);
1398 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1400 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1406 } else if (!as->parms[2].items) {
1407 if (!as->parms[1].items) {
1409 ("bos: must specify -all switch to salvage all partitions.\n");
1412 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1413 /* can't parse volume ID, so complain before shutting down
1416 printf("bos: can't interpret %s as partition ID.\n",
1417 as->parms[1].items->data);
1420 curGoal = GetServerGoal(tconn, serviceName);
1421 /* salvage a whole partition (specified by parms[1]) */
1422 if (curGoal == BSTAT_NORMAL) {
1423 printf("bos: shutting down '%s'.\n", serviceName);
1424 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN);
1426 printf("bos: can't stop '%s' (%s)\n", serviceName, em(code));
1429 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1432 ("bos: failed to wait for file server shutdown, continuing.\n");
1434 /* now do the salvage operation */
1435 printf("Starting salvage.\n");
1436 rc = DoSalvage(tconn, as->parms[1].items->data, NULL, outName,
1437 showlog, parallel, tmpDir, orphans, dafs);
1438 if (curGoal == BSTAT_NORMAL) {
1439 printf("bos: restarting '%s'.\n", serviceName);
1440 code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL);
1442 printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code));
1449 /* salvage individual volume (don't shutdown fs first), just use
1450 * single-shot cron bnode. Must leave server running when using this
1451 * option, since salvager will ask file server for the volume */
1454 const char *confdir;
1457 if (as->parms[ADDPARMOFFSET].items)
1458 tmpname = as->parms[ADDPARMOFFSET].items->data;
1462 localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
1464 (localauth ? AFSDIR_SERVER_ETC_DIRPATH :
1465 AFSDIR_CLIENT_ETC_DIRPATH);
1467 code = vsu_ClientInit(confdir, tmpname,
1468 AFSCONF_SECOPTS_FALLBACK_NULL |
1469 AFSCONF_SECOPTS_NOAUTH,
1473 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1475 printf("bos: can't interpret %s as volume name or ID\n",
1476 as->parms[2].items->data);
1479 sprintf(tname, "%u", newID);
1482 ("bos: can't initialize volume system client (code %d), trying anyway.\n",
1484 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1486 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1487 /* can't parse volume ID, so complain before shutting down
1490 printf("bos: can't interpret %s as partition ID.\n",
1491 as->parms[1].items->data);
1494 printf("Starting salvage.\n");
1495 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1496 showlog, parallel, tmpDir, orphans, dafs);
1504 IStatServer(struct cmd_syndesc *as, int int32p)
1506 struct rx_connection *tconn;
1507 struct cmd_item *ti;
1510 tconn = GetConn(as, 0);
1511 for (ti = as->parms[1].items; ti; ti = ti->next) {
1512 DoStat(ti->data, tconn, int32p, firstTime);
1519 DoStat(IN char *aname,
1520 IN struct rx_connection *aconn,
1522 IN int firstTime) /* true iff first instance in cmd */
1528 struct bozo_status istatus;
1530 char *is1, *is2, *is3, *is4; /* instance strings */
1533 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1535 printf("bos: failed to get instance info for '%s' (%s)\n", aname,
1539 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1541 ("Bosserver reports inappropriate access on server directories\n");
1542 printf("Instance %s, ", aname);
1544 printf("(type is %s) ", buffer);
1545 if (istatus.fileGoal == istatus.goal) {
1547 printf("disabled, ");
1549 if (istatus.fileGoal)
1550 printf("temporarily disabled, ");
1552 printf("temporarily enabled, ");
1555 if (istatus.flags & BOZO_ERRORSTOP)
1556 printf("stopped for too many errors, ");
1557 if (istatus.flags & BOZO_HASCORE)
1558 printf("has core file, ");
1561 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1563 printf("bos: failed to get status for instance '%s' (%s)\n", aname,
1566 printf("currently ");
1567 if (temp == BSTAT_NORMAL)
1568 printf("running normally.\n");
1569 else if (temp == BSTAT_SHUTDOWN)
1570 printf("shutdown.\n");
1571 else if (temp == BSTAT_STARTINGUP)
1572 printf("starting up.\n");
1573 else if (temp == BSTAT_SHUTTINGDOWN)
1574 printf("shutting down.\n");
1575 if (buffer[0] != 0) {
1576 printf(" Auxiliary status is: %s.\n", buffer);
1580 /* are we done yet? */
1584 if (istatus.procStartTime)
1585 printf(" Process last started at %s (%d proc starts)\n",
1586 DateOf(istatus.procStartTime), istatus.procStarts);
1587 if (istatus.lastAnyExit) {
1588 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1590 if (istatus.lastErrorExit) {
1591 is1 = is2 = is3 = is4 = NULL;
1592 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1593 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1594 /* don't complain about failing call, since could simply mean
1595 * interface mismatch.
1599 /* non-null instance string */
1600 printf("by %s, ", is1);
1607 if (istatus.errorSignal) {
1608 if (istatus.errorSignal == SIGTERM)
1609 printf("due to shutdown request\n");
1611 printf("due to signal %d\n", istatus.errorSignal);
1613 printf("by exiting with code %d\n", istatus.errorCode);
1617 /* try to display all the parms */
1620 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1623 printf(" Command %d is '%s'\n", i + 1, buffer);
1626 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1628 /* Any type of failure is treated as not having a notifier program */
1629 printf(" Notifier is '%s'\n", buffer);
1637 GetRestrict(struct cmd_syndesc *as, void *arock)
1639 struct rx_connection *tconn;
1640 afs_int32 code, val;
1642 tconn = GetConn(as, 0);
1643 code = BOZO_GetRestrictedMode(tconn, &val);
1645 printf("bos: failed to get restricted mode (%s)\n", em(code));
1647 printf("Restricted mode is %s\n", val ? "on" : "off");
1653 SetRestrict(struct cmd_syndesc *as, void *arock)
1655 struct rx_connection *tconn;
1656 afs_int32 code, val;
1658 tconn = GetConn(as, 0);
1659 util_GetInt32(as->parms[1].items->data, &val);
1660 code = BOZO_SetRestrictedMode(tconn, val);
1662 printf("bos: failed to set restricted mode (%s)\n", em(code));
1667 add_std_args(struct cmd_syndesc *ts)
1669 cmd_Seek(ts, ADDPARMOFFSET);
1670 /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1671 /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1672 "don't authenticate");
1673 /* + 2 */ cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1674 "create tickets from KeyFile");
1677 #include "AFS_component_version_number.c"
1680 main(int argc, char **argv)
1683 struct cmd_syndesc *ts;
1685 __declspec(dllimport)
1687 extern int afsconf_SawCell;
1689 #ifdef AFS_AIX32_ENV
1691 * The following signal action for AIX is necessary so that in case of a
1692 * crash (i.e. core is generated) we can include the user's data section
1693 * in the core dump. Unfortunately, by default, only a partial core is
1694 * generated which, in many cases, isn't too useful.
1696 struct sigaction nsa;
1698 sigemptyset(&nsa.sa_mask);
1699 nsa.sa_handler = SIG_DFL;
1700 nsa.sa_flags = SA_FULLDUMP;
1701 sigaction(SIGSEGV, &nsa, NULL);
1702 sigaction(SIGABRT, &nsa, NULL);
1708 printf("bos: could not initialize rx (%s)\n", em(code));
1712 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1713 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1714 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1715 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1716 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1718 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1720 afsconf_SawCell = 0; /* Reset it */
1721 /* don't check error code, since fails sometimes when we're setting up a
1723 initialize_CMD_error_table();
1724 initialize_BZ_error_table();
1726 ts = cmd_CreateSyntax("start", StartServer, NULL, "start running a server");
1727 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1728 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1731 ts = cmd_CreateSyntax("stop", StopServer, NULL, "halt a server instance");
1732 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1733 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1735 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1736 "wait for process to stop");
1739 ts = cmd_CreateSyntax("status", StatServer, NULL,
1740 "show server instance status");
1741 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1742 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1743 "server process name");
1744 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1747 ts = cmd_CreateSyntax("shutdown", Shutdown, NULL, "shutdown all processes");
1748 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1749 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1751 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1752 "wait for process to stop");
1755 ts = cmd_CreateSyntax("startup", Startup, NULL, "start all processes");
1756 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1757 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1760 ts = cmd_CreateSyntax("restart", Restart, NULL, "restart processes");
1761 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1762 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1763 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL,
1764 "restart bosserver");
1765 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
1770 ts = cmd_CreateSyntax("create", CreateServer, NULL,
1771 "create a new server instance");
1772 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1773 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
1774 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
1775 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
1776 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL,
1777 "Notifier program");
1780 ts = cmd_CreateSyntax("delete", DeleteServer, NULL,
1781 "delete a server instance");
1782 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1783 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1786 ts = cmd_CreateSyntax("adduser", AddSUser, NULL,
1787 "add users to super-user list");
1788 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1789 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
1792 ts = cmd_CreateSyntax("removeuser", RemoveSUser, NULL,
1793 "remove users from super-user list");
1794 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1795 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
1798 ts = cmd_CreateSyntax("listusers", ListSUsers, NULL, "list super-users");
1799 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1802 ts = cmd_CreateSyntax("addkey", AddKey, NULL,
1803 "add keys to key dbase (kvno 999 is bcrypt)");
1804 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1805 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
1806 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
1809 ts = cmd_CreateSyntax("removekey", RemoveKey, NULL,
1810 "remove keys from key dbase");
1811 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1812 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
1815 ts = cmd_CreateSyntax("listkeys", ListKeys, NULL, "list keys");
1816 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1817 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
1818 "show the actual key rather than the checksum");
1821 ts = cmd_CreateSyntax("listhosts", ListHosts, NULL, "get cell host list");
1822 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1824 cmd_CreateAlias(ts, "getcell");
1826 ts = cmd_CreateSyntax("setcellname", SetCellName, NULL, "set cell name");
1827 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1828 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
1831 ts = cmd_CreateSyntax("addhost", AddHost, NULL, "add host to cell dbase");
1832 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1833 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
1834 cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
1837 ts = cmd_CreateSyntax("removehost", RemoveHost, NULL,
1838 "remove host from cell dbase");
1839 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1840 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
1843 ts = cmd_CreateSyntax("setauth", SetAuth, NULL,
1844 "set authentication required flag");
1845 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1846 cmd_AddParm(ts, "-authrequired", CMD_SINGLE, 0,
1847 "on or off: authentication required for admin requests");
1850 ts = cmd_CreateSyntax("install", Install, NULL, "install program");
1851 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1852 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
1853 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
1856 ts = cmd_CreateSyntax("uninstall", UnInstall, NULL, "uninstall program");
1857 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1858 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
1859 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
1862 ts = cmd_CreateSyntax("getlog", GetLogCmd, NULL, "examine log file");
1863 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1864 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
1867 ts = cmd_CreateSyntax("getdate", GetDate, NULL, "get dates for programs");
1868 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1869 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
1870 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
1873 ts = cmd_CreateSyntax("exec", Exec, NULL, "execute shell command on server");
1874 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1875 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
1878 ts = cmd_CreateSyntax("prune", Prune, NULL, "prune server files");
1879 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1880 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
1881 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
1882 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
1883 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
1886 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, NULL,
1887 "set restart times");
1888 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
1889 cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_REQUIRED,
1890 "time to restart server");
1891 cmd_AddParm(ts, "-general", CMD_FLAG, CMD_OPTIONAL,
1892 "set general restart time");
1893 cmd_AddParm(ts, "-newbinary", CMD_FLAG, CMD_OPTIONAL,
1894 "set new binary restart time");
1896 cmd_CreateAlias(ts, "setr");
1898 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, NULL,
1899 "get restart times");
1900 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
1902 cmd_CreateAlias(ts, "getr");
1904 ts = cmd_CreateSyntax("salvage", SalvageCmd, NULL,
1905 "salvage partition or volumes");
1906 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1907 cmd_AddParm(ts, "-partition", CMD_SINGLE, CMD_OPTIONAL,
1908 "salvage partition");
1909 cmd_AddParm(ts, "-volume", CMD_SINGLE, CMD_OPTIONAL,
1910 "salvage volume number or volume name");
1911 cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL,
1912 "salvage log output file");
1913 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
1914 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL,
1915 "display salvage log");
1916 cmd_AddParm(ts, "-parallel", CMD_SINGLE, CMD_OPTIONAL,
1917 "# of max parallel partition salvaging");
1918 cmd_AddParm(ts, "-tmpdir", CMD_SINGLE, CMD_OPTIONAL,
1919 "directory to place tmp files");
1920 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
1921 "ignore | remove | attach");
1922 cmd_AddParm(ts, "-forceDAFS", CMD_FLAG, CMD_OPTIONAL,
1923 "(DAFS) force salvage of demand attach fileserver");
1926 ts = cmd_CreateSyntax("getrestricted", GetRestrict, NULL,
1927 "get restrict mode");
1928 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1931 ts = cmd_CreateSyntax("setrestricted", SetRestrict, NULL,
1932 "set restrict mode");
1933 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1934 cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
1938 code = cmd_Dispatch(argc, argv);