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 <afs/param.h>
14 #include <sys/types.h>
21 #include <netinet/in.h>
23 #include <sys/socket.h>
25 #endif /* AFS_NT40_ENV */
27 #include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
31 #include <afs/afsutil.h>
32 #include <afs/cellconfig.h>
38 #include <afs/cellconfig.h>
41 #include <afs/com_err.h>
43 #include <afs/ktime.h>
47 extern char *volutil_PartitionName();
48 extern struct rx_call *rx_NewCall();
49 extern char *volutil_PartitionName();
50 extern struct hostent *hostutil_GetHostByName();
56 #include "../permit_xprt.h"
58 /* dummy routine for the audit work. It should do nothing since audits */
59 /* occur at the server level and bos is not a server. */
60 osi_audit() {return 0;}
62 /* keep those lines small */
63 static char *em(acode)
66 return "communications failure (-1)";
68 return "communications timeout (-3)";
69 else return (char *) error_message(acode);
72 /* get partition id from a name */
73 static afs_int32 GetPartitionID(aname)
79 if (tc == 0) return -1; /* unknown */
80 /* numbers go straight through */
81 if (tc >= '0' && tc <= '9') {
84 /* otherwise check for vicepa or /vicepa, or just plain "a" */
86 if (strlen(aname) <= 2) {
89 else if (!strncmp(aname, "/vicep", 6)) {
90 strncpy(ascii, aname+6, 2);
92 else if (!strncmp(aname, "vicep", 5)) {
93 strncpy(ascii, aname+5, 2);
95 else return -1; /* bad partition name */
96 /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab,
97 * .../vicepzz, and are numbered from 0. Do the appropriate conversion */
99 /* one char name, 0..25 */
100 if (ascii[0] < 'a' || ascii[0] > 'z') return -1; /* wrongo */
101 return ascii[0] - 'a';
104 /* two char name, 26 .. <whatever> */
105 if (ascii[0] < 'a' || ascii[0] > 'z') return -1; /* wrongo */
106 if (ascii[1] < 'a' || ascii[1] > 'z') return -1; /* just as bad */
107 return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
111 /* make ctime easier to use */
112 static char *DateOf(atime)
114 static char tbuffer[30];
116 tp=ctime((time_t *)&atime);
119 tbuffer[24] = 0; /* get rid of new line */
122 strcpy(tbuffer, "BAD TIME");
126 /* global stuff from main for communicating with GetConn */
127 static struct rx_securityClass *sc[3];
130 /* use the syntax descr to get a connection, authenticated appropriately.
131 * aencrypt is set if we want to encrypt the data on the wire.
133 static struct rx_connection *GetConn(as, aencrypt)
135 struct cmd_syndesc *as; {
138 register afs_int32 code;
139 register struct rx_connection *tconn;
141 register struct afsconf_dir *tdir;
143 struct ktc_principal sname;
144 struct ktc_token ttoken;
148 hostname = as->parms[0].items->data;
149 th = hostutil_GetHostByName(hostname);
151 printf("bos: can't find address for host '%s'\n", hostname);
154 bcopy(th->h_addr, &addr, sizeof(afs_int32));
156 /* get tokens for making authenticated connections */
157 localauth = (as->parms[14].items != 0);
158 confdir = (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
159 tdir = afsconf_Open (confdir);
161 struct afsconf_cell info;
164 if (as->parms[12].items) tname = as->parms[12].items->data;
165 else tname = (char *) 0;
166 /* next call expands cell name abbrevs for us and handles looking up
168 code = afsconf_GetCellInfo(tdir, tname, (char *) 0, &info);
170 com_err ("bos", code, "(can't find cell '%s' in cell database)",
171 (tname? tname : "<default>"));
174 else strcpy(sname.cell, info.name);
177 printf("bos: can't open cell database (%s)\n", confdir);
180 sname.instance[0] = 0;
181 strcpy(sname.name, "afs");
182 sc[0] = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
187 if (!as->parms[13].items) { /* not -noauth */
188 if (as->parms[14].items) { /* -localauth */
189 code = afsconf_GetLatestKey (tdir, 0,0);
190 if (code) com_err ("bos", code, "(getting key from local KeyFile)");
193 code = afsconf_ClientAuthSecure (tdir, &sc[2], &scIndex);
195 code = afsconf_ClientAuth (tdir, &sc[2], &scIndex);
196 if (code) com_err ("bos", code, "(calling ClientAuth)");
197 else if (scIndex != 2) /* this shouldn't happen */
200 } else { /* not -localauth, check for tickets */
201 code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), (char *)0);
203 /* have tickets, will travel */
204 if (ttoken.kvno >= 0 && ttoken.kvno <= 255) ;
207 "bos: funny kvno (%d) in ticket, proceeding\n",
211 if (aencrypt) encryptLevel = rxkad_crypt;
212 else encryptLevel = rxkad_clear;
213 sc[2] = (struct rx_securityClass *)
214 rxkad_NewClientSecurityObject
215 (encryptLevel, &ttoken.sessionKey,
216 ttoken.kvno, ttoken.ticketLen, ttoken.ticket);
218 } else com_err ("bos", code, "(getting tickets)");
220 if ((scIndex == 0) || (sc[scIndex] == 0)) {
221 fprintf (stderr, "bos: running unauthenticated\n");
225 tconn = rx_NewConnection (addr, htons(AFSCONF_NANNYPORT), 1,
226 sc[scIndex], scIndex);
228 fprintf (stderr, "bos: could not create rx connection\n");
231 rxs_Release (sc[scIndex]);
237 struct cmd_syndesc *as; {
238 register afs_int32 code;
239 register struct rx_connection *tconn;
243 tconn = GetConn(as, 0);
244 tp = as->parms[1].items->data;
245 if (strcmp(tp, "on")==0) flag = 0; /* auth req.: noauthflag is false */
246 else if (strcmp(tp, "off") == 0) flag = 1;
248 printf("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n", tp);
251 code = BOZO_SetNoAuthFlag(tconn, flag);
252 if (code) com_err ("bos", code, "(failed to set authentication flag)");
256 /* take a name (e.g. foo/bar, and a dir e.g. /usr/afs/bin, and construct
257 * /usr/afs/bin/bar */
258 static ComputeDestDir(aname, adir, aresult, alen)
259 char *aname, *adir, *aresult;
263 strcpy(aresult, adir);
264 tp = rindex(aname, '/');
267 strcat(aresult, "/");
268 strcat(aresult, aname);
271 /* tp points at the / character */
277 /* copy data from fd afd to rx call acall */
278 static CopyBytes(afd, acall)
280 register struct rx_call *acall; {
281 register afs_int32 code;
282 register afs_int32 len;
286 len = read(afd, tbuffer, sizeof(tbuffer));
287 if (len < 0) return errno;
288 if (len == 0) return 0; /* all done */
289 code = rx_Write(acall, tbuffer, len);
290 if (code != len) return -1;
295 register struct cmd_syndesc *as; {
296 register afs_int32 code;
297 register struct rx_connection *tconn;
298 register afs_int32 flags;
300 tconn = GetConn(as, 0);
302 if (as->parms[1].items) flags |= BOZO_PRUNEBAK;
303 if (as->parms[2].items) flags |= BOZO_PRUNEOLD;
304 if (as->parms[3].items) flags |= BOZO_PRUNECORE;
305 if (as->parms[4].items) flags |= 0xff;
306 code = BOZO_Prune(tconn, flags);
307 if (code) com_err ("bos", code, "(failed to prune server files)");
312 register struct cmd_syndesc *as; {
313 register struct rx_connection *tconn;
314 register afs_int32 code;
316 tconn = GetConn(as, 0);
317 code = BOZO_Exec(tconn, as->parms[1].items->data);
318 if (code) printf("bos: failed to execute command (%s)\n",
324 register struct cmd_syndesc *as; {
325 register afs_int32 code;
328 afs_int32 time, bakTime, oldTime;
329 register struct rx_connection *tconn;
330 register struct cmd_item *ti;
332 tconn = GetConn(as, 0);
333 if (!as->parms[1].items) {
334 printf("bos: no files to check\n");
338 /* compute dest dir or file; default MUST be canonical form of dir path */
339 if (as->parms[2].items) strcpy(destDir, as->parms[2].items->data);
340 else strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
342 for(ti=as->parms[1].items; ti; ti=ti->next) {
343 /* check date for each file */
344 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
345 code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime);
347 printf("bos: failed to check date on %s (%s)\n", ti->data,
352 printf("File %s ", tbuffer);
353 if (time == 0) printf("does not exist, ");
354 else printf("dated %s, ", DateOf(time));
355 if (bakTime == 0) printf("no .BAK file, ");
356 else printf(".BAK file dated %s, ", DateOf(bakTime));
357 if (oldTime == 0) printf("no .OLD file.");
358 else printf(".OLD file dated %s.", DateOf(oldTime));
365 register struct cmd_syndesc *as; {
366 register afs_int32 code;
369 register struct cmd_item *ti;
370 register struct rx_connection *tconn;
372 tconn = GetConn(as, 0);
373 if (!as->parms[1].items) {
374 printf("bos: no files to uninstall\n");
378 /* compute dest dir or file; default MUST be canonical form of dir path */
379 if (as->parms[2].items) strcpy(destDir, as->parms[2].items->data);
380 else strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
382 for(ti=as->parms[1].items; ti; ti=ti->next) {
383 /* uninstall each file */
384 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
385 code = BOZO_UnInstall(tconn, tbuffer);
387 printf("bos: failed to uninstall %s (%s)\n", ti->data,
391 else printf("bos: uninstalled file %s\n", ti->data);
396 static afs_int32 GetServerGoal(aconn, aname)
398 struct rx_connection *aconn; {
401 register afs_int32 code;
402 struct bozo_status istatus;
405 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
407 printf("bos: failed to get instance info for '%s' (%s)\n",
409 /* if we can't get the answer, assume its running */
412 if (istatus.goal == 0)
413 return BSTAT_SHUTDOWN;
419 struct cmd_syndesc *as; {
420 struct rx_connection *tconn;
421 register afs_int32 code;
422 register struct cmd_item *ti;
426 struct rx_call *tcall;
429 tconn = GetConn(as, 0);
430 if (!as->parms[1].items) {
431 printf("bos: no files to install\n");
435 /* compute dest dir or file; default MUST be canonical form of dir path */
436 if (as->parms[2].items) strcpy(destDir, as->parms[2].items->data);
437 else strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH);
439 for(ti=as->parms[1].items; ti; ti=ti->next) {
440 /* install each file */
441 fd = open(ti->data, O_RDONLY);
443 /* better to quit on error than continue for install command */
444 printf("bos: can't find file '%s', quitting\n", ti->data);
447 code = fstat(fd, &tstat);
449 printf("bos: failed to stat file %s, errno is %d\n", ti->data,
453 /* compute destination dir */
454 ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer));
455 tcall = rx_NewCall(tconn);
456 code = StartBOZO_Install(tcall, tbuffer, tstat.st_size, (afs_int32)tstat.st_mode,
459 code = CopyBytes(fd, tcall);
461 code = rx_EndCall(tcall, code);
463 printf("bos: failed to install %s (%s)\n", ti->data, em(code));
466 else printf("bos: installed file %s\n", ti->data);
472 struct cmd_syndesc *as; {
473 register struct rx_connection *tconn;
474 register afs_int32 code;
475 register struct cmd_item *ti;
477 tconn = GetConn(as, 0);
478 if (as->parms[1].items == 0) {
479 code = BOZO_ShutdownAll(tconn);
480 if (code) printf("bos: failed to shutdown servers (%s)\n", em(code));
483 for(ti = as->parms[1].items; ti; ti=ti->next) {
484 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN);
486 printf("bos: failed to shutdown instance %s (%s)\n",
490 if (as->parms[8].items) {
491 code = BOZO_WaitAll(tconn);
493 printf("bos: can't wait for processes to shutdown (%s)\n",
499 static GetRestartCmd(as, arock)
500 struct cmd_syndesc *as;
502 register afs_int32 code;
503 struct ktime generalTime, newBinaryTime;
504 char messageBuffer[256];
505 struct rx_connection *tconn;
508 hostp = as->parms[0].items->data; /* host name for messages */
509 tconn = GetConn(as, 0);
511 code = BOZO_GetRestartTime(tconn, 1, &generalTime);
513 printf("bos: failed to retrieve restart information (%s)\n", em(code));
516 code = BOZO_GetRestartTime(tconn, 2, &newBinaryTime);
518 printf("bos: failed to retrieve restart information (%s)\n", em(code));
522 code = ktime_DisplayString(&generalTime, messageBuffer);
524 printf("bos: failed to decode restart time (%s)\n", em(code));
527 printf("Server %s restarts %s\n", hostp, messageBuffer);
529 code = ktime_DisplayString(&newBinaryTime, messageBuffer);
531 printf("bos: failed to decode restart time (%s)\n", em(code));
534 printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer);
540 static SetRestartCmd(as, arock)
541 struct cmd_syndesc *as;
544 register afs_int32 code;
545 struct ktime restartTime;
547 struct rx_connection *tconn;
550 tconn = GetConn(as, 0);
551 if (as->parms[2].items) {count++; type = 1;}
552 if (as->parms[3].items) {count++; type = 2;}
554 printf("bos: can't specify more than one restart time at a time\n");
557 if (count == 0) type = 1; /* by default set general restart time */
559 if (code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime)) {
560 printf("bos: failed to parse '%s' as periodic restart time(%s)\n",
561 as->parms[1].items->data, em(code));
565 code = BOZO_SetRestartTime(tconn, type, &restartTime);
567 printf("bos: failed to set restart time at server (%s)\n", em(code));
574 struct cmd_syndesc *as; {
575 register struct rx_connection *tconn;
576 register afs_int32 code;
577 register struct cmd_item *ti;
579 tconn = GetConn(as, 0);
580 if (as->parms[1].items == 0) {
581 code = BOZO_StartupAll(tconn);
583 printf("bos: failed to startup servers (%s)\n", em(code));
586 for(ti = as->parms[1].items; ti; ti=ti->next) {
587 code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL);
589 printf("bos: failed to start instance %s (%s)\n",
597 struct cmd_syndesc *as; {
598 register struct rx_connection *tconn;
599 register afs_int32 code;
600 register struct cmd_item *ti;
602 tconn = GetConn(as, 0);
603 if (as->parms[2].items) {
604 /* this is really a rebozo command */
605 if (as->parms[1].items) {
606 /* specified specific things to restart, can't do this at the same
608 printf("bos: can't specify both '-bos' and specific servers to restart.\n");
611 /* otherwise do a rebozo */
612 code = BOZO_ReBozo(tconn);
614 printf("bos: failed to restart bosserver (%s)\n", em(code));
617 if (as->parms[1].items == 0) {
618 if (as->parms[3].items) { /* '-all' */
619 code = BOZO_RestartAll(tconn);
620 if (code) printf("bos: failed to restart servers (%s)\n", em(code));
622 printf("bos: To restart all processes please specify '-all'\n");
625 if (as->parms[3].items) {
626 printf("bos: Can't use '-all' along with individual instances\n");
628 for(ti = as->parms[1].items; ti; ti=ti->next) {
629 code = BOZO_Restart(tconn, ti->data);
631 printf("bos: failed to restart instance %s (%s)\n", ti->data,
639 static SetCellName(as)
640 struct cmd_syndesc *as; {
641 register struct rx_connection *tconn;
642 register afs_int32 code;
644 tconn = GetConn(as, 0);
645 code = BOZO_SetCellName(tconn, as->parms[1].items->data);
646 if (code) printf("bos: failed to set cell (%s)\n", em(code));
651 register struct cmd_syndesc *as; {
652 register struct rx_connection *tconn;
653 register afs_int32 code;
654 register struct cmd_item *ti;
656 tconn = GetConn(as, 0);
657 for(ti = as->parms[1].items; ti; ti=ti->next) {
658 code = BOZO_AddCellHost(tconn, ti->data);
660 printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
665 static RemoveHost(as)
666 register struct cmd_syndesc *as; {
667 register struct rx_connection *tconn;
668 register afs_int32 code;
669 register struct cmd_item *ti;
671 tconn = GetConn(as, 0);
672 for(ti=as->parms[1].items; ti; ti=ti->next) {
673 code = BOZO_DeleteCellHost(tconn, ti->data);
675 printf("bos: failed to delete host %s (%s)\n", ti->data, em(code));
681 register struct cmd_syndesc *as; {
682 register struct rx_connection *tconn;
683 register afs_int32 code;
686 register afs_int32 i;
689 tconn = GetConn(as, 0);
690 code = BOZO_GetCellName(tconn, &tp);
692 printf("bos: failed to get cell name (%s)\n", em(code));
695 printf("Cell name is %s\n", tbuffer);
697 code = BOZO_GetCellHost(tconn, i, &tp);
698 if (code == BZDOM) break;
700 printf("bos: failed to get cell host %d (%s)\n", i, em(code));
703 printf(" Host %d is %s\n", i+1, tbuffer);
709 register struct cmd_syndesc *as; {
710 register struct rx_connection *tconn;
711 register afs_int32 code;
712 struct ktc_encryptionKey tkey;
715 char cellBuffer[256];
716 char buf[BUFSIZ], ver[BUFSIZ];
718 tconn = GetConn(as, 1);
719 bzero(&tkey, sizeof(struct ktc_encryptionKey));
721 if(as->parms[1].items)
722 strcpy(buf,as->parms[1].items->data);
726 code=des_read_pw_string(buf,sizeof(buf),"input key: ",0);
727 if(code || strlen(buf)==0)
729 fprintf(stderr,"Bad key: \n");
732 code=des_read_pw_string(ver,sizeof(ver),"Retype input key: ",0);
733 if(code || strlen(ver)==0)
735 fprintf(stderr,"Bad key: \n");
738 if (strcmp (ver, buf) != 0) {
739 fprintf (stderr, "\nInput key mismatch\n");
745 temp = atoi(as->parms[2].items->data);
749 strcpy((char *)&tkey, as->parms[1].items->data);
751 strcpy((char *)&tkey, buf);
753 else { /* kerberos key */
754 if (as->parms[12].items) {
755 strcpy(cellBuffer, as->parms[12].items->data);
757 /* string to key needs upper-case cell names */
759 /* I don't believe this is true. The string to key function
760 * actually expands the cell name, then LOWER-CASES it. Perhaps it
761 * didn't use to??? */
762 ucstring(cellBuffer, cellBuffer, strlen(cellBuffer));
765 else tcell = (char *) 0; /* no cell specified, use current */
767 ka_StringToKey(as->parms[1].items->data, tcell, &tkey);
769 ka_StringToKey(buf,tcell,&tkey);
771 tconn = GetConn(as, 1);
772 code = BOZO_AddKey(tconn, temp, &tkey);
774 printf("bos: failed to set key %d (%s)\n", temp, em(code));
781 register struct cmd_syndesc *as; {
782 register struct rx_connection *tconn;
783 register afs_int32 code;
785 register struct cmd_item *ti;
787 tconn = GetConn(as, 0);
788 for(ti=as->parms[1].items; ti; ti=ti->next) {
789 temp = atoi(ti->data);
790 code = BOZO_DeleteKey(tconn, temp);
792 printf("bos: failed to delete key %d (%s)\n", temp, em(code));
800 IN register struct cmd_syndesc *as;
802 register struct rx_connection *tconn;
803 register afs_int32 code;
804 struct ktc_encryptionKey tkey;
806 struct bozo_keyInfo keyInfo;
808 register afs_int32 i;
810 tconn = GetConn(as, 1);
813 code = BOZO_ListKeys(tconn, i, &kvno, &tkey, &keyInfo);
816 /* first check if key is returned */
817 if ((!ka_KeyIsZero (&tkey, sizeof(tkey))) && (as->parms[1].items)) {
818 printf ("key %d is '", kvno);
819 ka_PrintBytes (&tkey, sizeof(tkey));
822 if (keyInfo.keyCheckSum == 0) /* shouldn't happen */
823 printf ("key version is %d\n", kvno);
825 printf ("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum);
829 printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec));
832 printf("bos: %s error encountered while listing keys\n", em(code));
834 printf("All done.\n");
839 register struct cmd_syndesc *as; {
840 register struct rx_connection *tconn;
841 register afs_int32 code;
843 register struct cmd_item *ti;
846 tconn = GetConn(as, 0);
847 for(ti=as->parms[1].items; ti; ti=ti->next) {
848 code = BOZO_AddSUser(tconn, ti->data);
850 printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code));
857 static RemoveSUser(as)
858 register struct cmd_syndesc *as; {
859 register struct rx_connection *tconn;
860 register struct cmd_item *ti;
861 register afs_int32 code;
865 tconn = GetConn(as, 0);
866 for(ti=as->parms[1].items; ti; ti=ti->next) {
867 code = BOZO_DeleteSUser(tconn, ti->data);
869 printf("bos: failed to delete user '%s', ", ti->data);
871 printf("(no such user)\n");
873 printf("(%s)\n", em(code));
880 #define NPERLINE 10 /* dudes to print per line */
881 static ListSUsers(as)
882 register struct cmd_syndesc *as; {
883 register struct rx_connection *tconn;
885 register afs_int32 code;
888 int lastNL, printGreeting;
890 tconn = GetConn(as, 0);
895 code = BOZO_ListSUsers(tconn, i, &tp);
898 printGreeting = 0; /* delay until after first call succeeds */
899 printf("SUsers are: ");
901 printf("%s ", tbuffer);
902 if ((i % NPERLINE) == NPERLINE-1) {
909 /* a real error code, instead of scanned past end */
910 printf("bos: failed to retrieve super-user list (%s)\n", em(code));
913 if (lastNL == 0) printf("\n");
917 static StatServer(as)
918 register struct cmd_syndesc *as; {
919 register struct rx_connection *tconn;
920 register afs_int32 code;
922 char ibuffer[BOZO_BSSIZE];
926 /* int32p==1 is obsolete, smaller, printout */
927 int32p = (as->parms[2].items != 0? 2 : 0);
929 /* no parms does something pretty different */
930 if (as->parms[1].items) return IStatServer(as, int32p);
932 tconn = GetConn(as, 0);
934 /* for each instance */
936 code = BOZO_EnumerateInstance(tconn, i, &tp);
937 if (code == BZDOM) break;
939 printf("bos: failed to contact host's bosserver (%s).\n",
943 DoStat(ibuffer, tconn, int32p, (i==0)); /* print status line */
948 static CreateServer(as)
949 register struct cmd_syndesc *as; {
950 register struct rx_connection *tconn;
951 register afs_int32 code;
953 register struct cmd_item *ti;
955 char *type, *name, *notifier=NONOTIFIER;
957 tconn = GetConn(as, 0);
958 for(i=0;i<6;i++) parms[i] = "";
959 for(i=0,ti=as->parms[3].items; (ti && i<6); ti=ti->next,i++) {
962 name = as->parms[1].items->data;
963 type = as->parms[2].items->data;
964 if (ti = as->parms[4].items) {
967 code = BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2],
968 parms[3], parms[4], notifier);
970 printf("bos: failed to create new server instance %s of type '%s' (%s)\n",
971 name, type, em(code));
976 static DeleteServer(as)
977 register struct cmd_syndesc *as; {
978 register struct rx_connection *tconn;
979 register afs_int32 code;
980 register struct cmd_item *ti;
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",
997 static StartServer(as)
998 register struct cmd_syndesc *as; {
999 register struct rx_connection *tconn;
1000 register afs_int32 code;
1001 register struct cmd_item *ti;
1004 tconn = GetConn(as, 0);
1005 for(ti=as->parms[1].items; ti; ti=ti->next) {
1006 code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL);
1008 printf("bos: failed to start instance '%s' (%s)\n",
1009 ti->data, em(code));
1014 static StopServer(as)
1015 register struct cmd_syndesc *as; {
1016 register struct rx_connection *tconn;
1017 register afs_int32 code;
1018 register struct cmd_item *ti;
1021 tconn = GetConn(as, 0);
1022 for(ti=as->parms[1].items; ti; ti=ti->next) {
1023 code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN);
1025 printf("bos: failed to change stop instance '%s' (%s)\n",
1026 ti->data, em(code));
1028 if (as->parms[8].items) {
1029 code = BOZO_WaitAll(tconn);
1031 printf("bos: can't wait for processes to shutdown (%s)\n",
1037 static DoSalvage(aconn, aparm1, aparm2, aoutName, showlog,parallel,atmpDir,orphans)
1038 struct rx_connection *aconn;
1047 register afs_int32 code;
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;
1060 /* if a partition was specified, canonicalize the name, since
1061 the salvager has a stupid partition ID parser */
1063 partNumber = volutil_GetPartitionID(aparm1);
1064 if (partNumber < 0) {
1065 printf("bos: could not parse partition ID '%s'\n", aparm1);
1068 tp = volutil_PartitionName(partNumber);
1070 printf("bos: internal error parsing partition ID '%s'\n", aparm1);
1073 strcpy(partName, tp);
1075 else partName[0] = 0;
1077 /* open the file name */
1079 outFile = fopen(aoutName, "w");
1081 printf("bos: can't open specified SalvageLog file '%s'\n",
1085 closeIt = 1; /* close this file later */
1089 closeIt = 0; /* don't close this file later */
1092 for(code=2;code<6;code++) parms[code] = "";
1093 if (!aparm2) aparm2 = "";
1094 /* MUST pass canonical (wire-format) salvager path to bosserver */
1095 strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE);
1097 if ( (strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) + 1) > BOZO_BSSIZE ) {
1098 printf("bos: command line too big\n");
1101 strcat(tbuffer, " ");
1102 strcat(tbuffer, partName);
1103 strcat(tbuffer, " ");
1104 strcat(tbuffer, aparm2);
1106 if ( (strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE ) {
1107 printf("bos: command line too big\n");
1110 strcat (tbuffer, " -f ");
1111 strcat (tbuffer, partName);
1114 /* add the parallel option if given */
1115 if (parallel != (char *)0) {
1116 if ( (strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE ) {
1117 printf("bos: command line too big\n");
1120 strcat(tbuffer, " -parallel ");
1121 strcat(tbuffer, parallel);
1124 /* add the tmpdir option if given */
1125 if (atmpDir != (char *)0) {
1126 if ( (strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE ) {
1127 printf("bos: command line too big\n");
1130 strcat(tbuffer, " -tmpdir ");
1131 strcat(tbuffer, atmpDir);
1134 /* add the orphans option if given */
1135 if (orphans != (char *)0) {
1136 if ( (strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE ) {
1137 printf("bos: command line too big\n");
1140 strcat(tbuffer, " -orphans ");
1141 strcat(tbuffer, orphans);
1145 parms[1] = "now"; /* when to do it */
1146 code = BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
1147 parms[2], parms[3], parms[4], notifier);
1148 if (code) goto done;
1149 /* now wait for bnode to disappear */
1153 code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
1155 printf("bos: waiting for salvage to complete.\n");
1157 if (code != BZNOENT) {
1158 printf("bos: salvage failed (%s)\n", em(code));
1162 /* now print the log file to the output file */
1163 printf("bos: salvage completed\n");
1164 if (aoutName || showlog) {
1165 fprintf(outFile, "SalvageLog:\n");
1166 tcall = rx_NewCall(aconn);
1167 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1168 code = StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
1170 rx_EndCall(tcall, code);
1175 code = rx_Read(tcall, &buffer, 1);
1176 if (code != 1) break;
1177 putc(buffer, outFile);
1178 if (buffer == 0) break; /* the end delimeter */
1180 code = rx_EndCall(tcall, 0);
1181 /* fall through into cleanup code */
1185 if (closeIt && outFile) fclose(outFile);
1189 static GetLogCmd(as)
1190 register struct cmd_syndesc *as; {
1191 struct rx_connection *tconn;
1192 register struct rx_call *tcall;
1193 register afs_int32 code;
1197 printf("Fetching log file '%s'...\n", as->parms[1].items->data);
1198 tconn = GetConn(as, 0);
1199 tcall = rx_NewCall(tconn);
1200 code = StartBOZO_GetLog(tcall, as->parms[1].items->data);
1202 rx_EndCall(tcall, code);
1208 code = rx_Read(tcall, &buffer, 1);
1213 if (buffer == 0) break; /* the end delimeter */
1216 code = rx_EndCall(tcall, error);
1217 /* fall through into cleanup code */
1221 com_err("bos", code, "(while reading log)");
1225 static SalvageCmd(as)
1226 struct cmd_syndesc *as; {
1227 register struct rx_connection *tconn;
1228 register afs_int32 code, rc;
1232 extern struct ubik_client *cstruct;
1233 afs_int32 curGoal, showlog = 0;
1238 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1239 tconn = GetConn(as, 0);
1241 /* we can do a volume, a partition or the whole thing, but not mixtures
1243 if (!as->parms[1].items && as->parms[2].items) {
1244 printf("bos: must specify partition to salvage individual volume.\n");
1247 if (as->parms[5].items && as->parms[3].items) {
1248 printf("bos: can not specify both -file and -showlog.\n");
1251 if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) {
1252 printf("bos: can not specify -all with other flags.\n");
1256 /* get the output file name, if any */
1257 if (as->parms[3].items)
1258 outName = as->parms[3].items->data;
1260 outName = (char *) 0;
1262 if (as->parms[5].items)
1265 /* parallel option */
1266 parallel = (char *) 0;
1267 if (as->parms[6].items)
1268 parallel = as->parms[6].items->data;
1270 /* get the tmpdir filename if any */
1272 if (as->parms[7].items)
1273 tmpDir = as->parms[7].items->data;
1275 /* -orphans option */
1276 orphans = (char *)0;
1277 if (as->parms[8].items)
1278 orphans = as->parms[8].items->data;
1280 if (as->parms[4].items) {
1281 /* salvage whole enchilada */
1282 curGoal = GetServerGoal(tconn, "fs");
1283 if (curGoal == BSTAT_NORMAL) {
1284 printf("bos: shutting down fs.\n");
1285 code = BOZO_SetTStatus(tconn, "fs", BSTAT_SHUTDOWN);
1287 printf("bos: failed to stop 'fs' (%s)\n", em(code));
1290 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1292 printf("bos: failed to wait for file server shutdown, continuing.\n");
1294 /* now do the salvage operation */
1295 printf("Starting salvage.\n");
1296 rc = DoSalvage(tconn, (char *) 0, (char *) 0, outName, showlog,parallel,tmpDir,orphans);
1297 if (rc) printf("bos: failed to start 'salvager' (%s)\n", em(rc));
1298 if (curGoal == BSTAT_NORMAL) {
1299 printf("bos: restarting fs.\n");
1300 code = BOZO_SetTStatus(tconn, "fs", BSTAT_NORMAL);
1302 printf("bos: failed to restart 'fs' (%s)\n", em(code));
1308 else if (!as->parms[2].items) {
1309 if (!as->parms[1].items) {
1310 printf("bos: must specify -all switch to salvage all partitions.\n");
1313 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1314 /* can't parse volume ID, so complain before shutting down
1317 printf("bos: can't interpret %s as partition ID.\n",
1318 as->parms[1].items->data);
1321 curGoal = GetServerGoal(tconn, "fs");
1322 /* salvage a whole partition (specified by parms[1]) */
1323 if (curGoal == BSTAT_NORMAL) {
1324 printf("bos: shutting down fs.\n");
1325 code = BOZO_SetTStatus(tconn, "fs", BSTAT_SHUTDOWN);
1327 printf("bos: can't stop 'fs' (%s)\n", em(code));
1330 code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */
1332 printf("bos: failed to wait for file server shutdown, continuing.\n");
1334 /* now do the salvage operation */
1335 printf("Starting salvage.\n");
1336 rc = DoSalvage(tconn, as->parms[1].items->data, (char *) 0,
1337 outName, showlog,parallel,tmpDir,orphans);
1338 if (rc) printf("bos: failed to start 'salvager' (%s)\n", em(rc));
1339 if (curGoal == BSTAT_NORMAL) {
1340 printf("bos: restarting fs.\n");
1341 code = BOZO_SetTStatus(tconn, "fs", BSTAT_NORMAL);
1343 printf("bos: failed to restart 'fs' (%s)\n", em(code));
1350 /* salvage individual volume (don't shutdown fs first), just use
1351 * single-shot cron bnode. Must leave server running when using this
1352 * option, since salvager will ask file server for the volume */
1355 const char *confdir;
1358 if (as->parms[12].items) tmpname = as->parms[12].items->data;
1359 else tmpname = (char *) 0;
1361 localauth = (as->parms[14].items != 0);
1362 confdir = (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
1363 code = vsu_ClientInit(/* noauth */ 1, confdir, tmpname,
1364 /* server auth */ 0, &cstruct, (int (*)()) 0);
1366 newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err);
1368 printf("bos: can't interpret %s as volume name or ID\n", as->parms[2].items->data);
1371 sprintf(tname, "%u", newID);
1374 printf("bos: can't initialize volume system client (code %d), trying anyway.\n",
1375 as->parms[2].items->data, code);
1376 strncpy(tname, as->parms[2].items->data, sizeof(tname));
1378 if (volutil_GetPartitionID(as->parms[1].items->data) < 0) {
1379 /* can't parse volume ID, so complain before shutting down
1382 printf("bos: can't interpret %s as partition ID.\n",
1383 as->parms[1].items->data);
1386 printf("Starting salvage.\n");
1387 rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName,
1388 showlog,parallel,tmpDir,orphans);
1390 printf("bos: failed to start 'salvager' (%s)\n", em(rc));
1397 static IStatServer(as, int32p)
1399 register struct cmd_syndesc *as; {
1400 register struct rx_connection *tconn;
1401 register struct cmd_item *ti;
1404 tconn = GetConn(as, 0);
1405 for (ti=as->parms[1].items; ti; ti=ti->next) {
1406 DoStat(ti->data, tconn, int32p, firstTime);
1412 static DoStat (aname, aconn, aint32p, firstTime)
1414 IN register struct rx_connection *aconn;
1416 IN int firstTime; /* true iff first instance in cmd */
1420 register afs_int32 code;
1421 register afs_int32 i;
1422 struct bozo_status istatus;
1424 char *is1, *is2, *is3, *is4; /* instance strings */
1427 code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus);
1429 printf("bos: failed to get instance info for '%s' (%s)\n",
1433 if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS))
1434 printf ("Bosserver reports inappropriate access on server directories\n");
1435 printf("Instance %s, ", aname);
1436 if (aint32p) printf("(type is %s) ", buffer);
1437 if (istatus.fileGoal == istatus.goal) {
1438 if (!istatus.goal) printf("disabled, ");
1441 if (istatus.fileGoal) printf("temporarily disabled, ");
1442 else printf("temporarily enabled, ");
1445 if (istatus.flags & BOZO_ERRORSTOP)
1446 printf("stopped for too many errors, ");
1447 if (istatus.flags & BOZO_HASCORE)
1448 printf("has core file, ");
1451 code = BOZO_GetStatus(aconn, aname, &temp, &tp);
1453 printf("bos: failed to get status for instance '%s' (%s)\n",
1456 printf("currently ", aname);
1457 if (temp == BSTAT_NORMAL) printf("running normally.\n");
1458 else if (temp == BSTAT_SHUTDOWN) printf("shutdown.\n");
1459 else if (temp == BSTAT_STARTINGUP) printf("starting up.\n");
1460 else if (temp == BSTAT_SHUTTINGDOWN) printf("shutting down.\n");
1461 if (buffer[0] != 0) {
1462 printf(" Auxiliary status is: %s.\n", buffer);
1466 /* are we done yet? */
1467 if (!aint32p) return 0;
1469 if (istatus.procStartTime)
1470 printf(" Process last started at %s (%d proc starts)\n",
1471 DateOf(istatus.procStartTime), istatus.procStarts);
1472 if (istatus.lastAnyExit) {
1473 printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit));
1475 if (istatus.lastErrorExit) {
1476 is1 = is2 = is3 = is4 = (char *) 0;
1477 printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit));
1478 code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
1479 /* don't complain about failing call, since could simply mean
1480 * interface mismatch.
1484 /* non-null instance string */
1485 printf("by %s, ", is1);
1492 if (istatus.errorSignal) {
1493 if (istatus.errorSignal == SIGTERM)
1494 printf("due to shutdown request\n");
1496 printf("due to signal %d\n", istatus.errorSignal);
1499 printf("by exiting with code %d\n", istatus.errorCode);
1503 /* try to display all the parms */
1506 code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
1508 printf(" Command %d is '%s'\n", i+1, buffer);
1511 code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
1513 /* Any type of failure is treated as not having a notifier program */
1514 printf(" Notifier is '%s'\n", buffer);
1521 static void add_std_args (ts)
1522 register struct cmd_syndesc *ts;
1525 /* 12 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
1526 /* 13 */cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
1527 "don't authenticate");
1528 /* 14 */ cmd_AddParm (ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
1529 "create tickets from KeyFile");
1532 #include "AFS_component_version_number.c"
1538 register afs_int32 code;
1539 register struct cmd_syndesc *ts;
1540 extern int afsconf_SawCell;
1542 #ifdef AFS_AIX32_ENV
1544 * The following signal action for AIX is necessary so that in case of a
1545 * crash (i.e. core is generated) we can include the user's data section
1546 * in the core dump. Unfortunately, by default, only a partial core is
1547 * generated which, in many cases, isn't too useful.
1549 struct sigaction nsa;
1551 sigemptyset(&nsa.sa_mask);
1552 nsa.sa_handler = SIG_DFL;
1553 nsa.sa_flags = SA_FULLDUMP;
1554 sigaction(SIGSEGV, &nsa, NULL);
1555 sigaction(SIGABRT, &nsa, NULL);
1561 printf("bos: could not initialize rx (%s)\n", em(code));
1565 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1566 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1567 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1568 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1569 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1571 afsconf_SawCell = 1; /* Means don't print warning if AFSCELL is set */
1573 afsconf_SawCell = 0; /* Reset it */
1574 /* don't check error code, since fails sometimes when we're setting up a
1576 initialize_cmd_error_table();
1577 initialize_bz_error_table();
1579 ts = cmd_CreateSyntax("start", StartServer, 0, "start running a server");
1580 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1581 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1584 ts = cmd_CreateSyntax("stop", StopServer, 0, "halt a server instance");
1585 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1586 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1588 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1589 "wait for process to stop");
1592 ts = cmd_CreateSyntax("status", StatServer, 0,
1593 "show server instance status");
1594 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1595 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL,
1596 "server process name");
1597 cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL, "long status");
1600 ts = cmd_CreateSyntax("shutdown", Shutdown, 0, "shutdown all processes");
1601 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1602 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1604 cmd_AddParm(ts, "-wait", CMD_FLAG, CMD_OPTIONAL,
1605 "wait for process to stop");
1608 ts = cmd_CreateSyntax("startup", Startup, 0, "start all processes");
1609 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1610 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1613 ts = cmd_CreateSyntax("restart", Restart, 0, "restart all processes");
1614 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1615 cmd_AddParm(ts, "-instance", CMD_LIST, CMD_OPTIONAL, "instances");
1616 cmd_AddParm(ts, "-bosserver", CMD_FLAG, CMD_OPTIONAL, "restart bosserver");
1617 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "restart all processes");
1622 ts = cmd_CreateSyntax("create", CreateServer, 0,
1623 "create a new server instance");
1624 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1625 cmd_AddParm(ts, "-instance", CMD_SINGLE, 0, "server process name");
1626 cmd_AddParm(ts, "-type", CMD_SINGLE, 0, "server type");
1627 cmd_AddParm(ts, "-cmd", CMD_LIST, 0, "command lines");
1628 cmd_AddParm(ts, "-notifier", CMD_SINGLE, CMD_OPTIONAL, "Notifier program");
1631 ts = cmd_CreateSyntax("delete", DeleteServer, 0,
1632 "delete a server instance");
1633 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1634 cmd_AddParm(ts, "-instance", CMD_LIST, 0, "server process name");
1637 ts = cmd_CreateSyntax("adduser", AddSUser, 0,
1638 "add users to super-user list");
1639 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1640 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
1643 ts = cmd_CreateSyntax("removeuser", RemoveSUser, 0,
1644 "remove users from super-user list");
1645 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1646 cmd_AddParm(ts, "-user", CMD_LIST, 0, "user names");
1649 ts = cmd_CreateSyntax("listusers", ListSUsers, 0, "list super-users");
1650 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1653 ts = cmd_CreateSyntax("addkey", AddKey, 0,
1654 "add keys to key dbase (kvno 999 is bcrypt)");
1655 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1656 cmd_AddParm(ts, "-key", CMD_SINGLE, CMD_OPTIONAL, "key");
1657 cmd_AddParm(ts, "-kvno", CMD_SINGLE, 0, "key version number");
1660 ts = cmd_CreateSyntax("removekey", RemoveKey, 0,
1661 "remove keys from key dbase");
1662 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1663 cmd_AddParm(ts, "-kvno", CMD_LIST, 0, "key version number");
1666 ts = cmd_CreateSyntax("listkeys", ListKeys, 0, "list keys");
1667 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1668 cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL, "show the actual key rather than the checksum");
1671 ts = cmd_CreateSyntax("listhosts", ListHosts, 0, "get cell host list");
1672 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1674 cmd_CreateAlias(ts, "getcell");
1676 ts = cmd_CreateSyntax("setcellname", SetCellName, 0, "set cell name");
1677 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1678 cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
1681 ts = cmd_CreateSyntax("addhost", AddHost, 0, "add host to cell dbase");
1682 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1683 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
1686 ts = cmd_CreateSyntax("removehost", RemoveHost, 0,
1687 "remove host from cell dbase");
1688 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1689 cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
1692 ts = cmd_CreateSyntax("setauth", SetAuth, 0,
1693 "set authentication required flag");
1694 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1695 cmd_AddParm(ts, "-authrequired", CMD_SINGLE,
1696 0, "on or off: authentication required for admin requests");
1699 ts = cmd_CreateSyntax("install", Install, 0, "install program");
1700 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1701 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to install");
1702 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
1705 ts = cmd_CreateSyntax("uninstall", UnInstall, 0, "uninstall program");
1706 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1707 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to uninstall");
1708 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
1711 ts = cmd_CreateSyntax("getlog", GetLogCmd, 0, "examine log file");
1712 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1713 cmd_AddParm(ts, "-file", CMD_SINGLE, 0, "log file to examine");
1716 ts = cmd_CreateSyntax("getdate", GetDate, 0, "get dates for programs");
1717 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1718 cmd_AddParm(ts, "-file", CMD_LIST, 0, "files to check");
1719 cmd_AddParm(ts, "-dir", CMD_SINGLE, CMD_OPTIONAL, "destination dir");
1722 ts = cmd_CreateSyntax("exec", Exec, 0, "execute shell command on server");
1723 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1724 cmd_AddParm(ts, "-cmd", CMD_SINGLE, 0, "command to execute");
1727 ts = cmd_CreateSyntax("prune", Prune, 0, "prune server files");
1728 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1729 cmd_AddParm(ts, "-bak", CMD_FLAG, CMD_OPTIONAL, "delete .BAK files");
1730 cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "delete .OLD files");
1731 cmd_AddParm(ts, "-core", CMD_FLAG, CMD_OPTIONAL, "delete core files");
1732 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all junk files");
1735 ts = cmd_CreateSyntax("setrestart", SetRestartCmd, 0, "set restart times");
1736 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
1737 cmd_AddParm(ts, "-time", CMD_SINGLE,
1738 CMD_REQUIRED, "time to restart server");
1739 cmd_AddParm(ts, "-general", CMD_FLAG,
1740 CMD_OPTIONAL, "set general restart time");
1741 cmd_AddParm(ts, "-newbinary", CMD_FLAG,
1742 CMD_OPTIONAL, "set new binary restart time");
1745 ts = cmd_CreateSyntax("getrestart", GetRestartCmd, 0, "get restart times");
1746 cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
1749 ts = cmd_CreateSyntax("salvage", SalvageCmd, 0,
1750 "salvage partition or volumes");
1751 cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
1752 cmd_AddParm(ts, "-partition", CMD_SINGLE,
1753 CMD_OPTIONAL, "salvage partition");
1754 cmd_AddParm(ts, "-volume", CMD_SINGLE,
1755 CMD_OPTIONAL, "salvage volume number or volume name");
1756 cmd_AddParm(ts, "-file", CMD_SINGLE,
1757 CMD_OPTIONAL, "salvage log output file");
1758 cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "salvage whole server");
1759 cmd_AddParm(ts, "-showlog", CMD_FLAG, CMD_OPTIONAL, "display salvage log");
1760 cmd_AddParm(ts, "-parallel",CMD_SINGLE, CMD_OPTIONAL,
1761 "# of max parallel partition salvaging");
1762 cmd_AddParm(ts, "-tmpdir",CMD_SINGLE, CMD_OPTIONAL,
1763 "directory to place tmp files");
1764 cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
1765 "ignore | remove | attach");
1770 code = cmd_Dispatch(argc, argv);