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 11
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 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
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 (stderr
, "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
, 1);
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
, 1);
252 code
= BOZO_Exec(tconn
, as
->parms
[1].items
->data
);
254 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
318 if (!as
->parms
[1].items
) {
319 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
377 if (!as
->parms
[1].items
) {
378 fprintf(stderr
, "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 fprintf(stderr
, "bos: can't find file '%s', quitting\n", ti
->data
);
396 code
= fstat(fd
, &tstat
);
398 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
429 if (as
->parms
[1].items
== 0) {
430 code
= BOZO_ShutdownAll(tconn
);
432 fprintf(stderr
, "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 fprintf(stderr
, "bos: failed to shutdown instance %s (%s)\n", ti
->data
,
441 if (as
->parms
[8].items
) {
442 code
= BOZO_WaitAll(tconn
);
444 fprintf(stderr
, "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 fprintf(stderr
, "bos: failed to retrieve restart information (%s)\n",
468 code
= BOZO_GetRestartTime(tconn
, 2, (struct bozo_netKTime
*) &newBinaryTime
);
470 fprintf(stderr
, "bos: failed to retrieve restart information (%s)\n",
475 code
= ktime_DisplayString(&generalTime
, messageBuffer
);
477 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
504 if (as
->parms
[2].items
) {
508 if (as
->parms
[3].items
) {
513 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
541 if (as
->parms
[1].items
== 0) {
542 code
= BOZO_StartupAll(tconn
);
544 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
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 (stderr
, "bos: can't specify both '-bos' and specific servers to restart.\n");
573 /* otherwise do a rebozo */
574 code
= BOZO_ReBozo(tconn
);
576 fprintf(stderr
, "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 fprintf(stderr
, "bos: failed to restart servers (%s)\n", em(code
));
585 fprintf(stderr
, "bos: To restart all processes please specify '-all'\n");
587 if (as
->parms
[3].items
) {
588 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
608 code
= BOZO_SetCellName(tconn
, as
->parms
[1].items
->data
);
610 fprintf(stderr
, "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
, 1);
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 fprintf(stderr
, "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
, 1);
649 for (ti
= as
->parms
[1].items
; ti
; ti
= ti
->next
) {
650 code
= BOZO_DeleteCellHost(tconn
, ti
->data
);
652 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
773 for (ti
= as
->parms
[1].items
; ti
; ti
= ti
->next
) {
774 temp
= atoi(ti
->data
);
775 code
= BOZO_DeleteKey(tconn
, temp
);
777 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
835 for (ti
= as
->parms
[1].items
; ti
; ti
= ti
->next
) {
836 code
= BOZO_AddSUser(tconn
, ti
->data
);
838 fprintf(stderr
, "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
, 1);
855 for (ti
= as
->parms
[1].items
; ti
; ti
= ti
->next
) {
856 code
= BOZO_DeleteSUser(tconn
, ti
->data
);
858 fprintf(stderr
, "bos: failed to delete user '%s', ", ti
->data
);
860 fprintf(stderr
, "(no such user)\n");
862 fprintf(stderr
, "(%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 fprintf(stderr
, "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 fprintf(stderr
, "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
, 1);
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 (stderr
, "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
, 1);
984 for (ti
= as
->parms
[1].items
; ti
; ti
= ti
->next
) {
985 code
= BOZO_DeleteBnode(tconn
, ti
->data
);
988 fprintf(stderr
, "bos: can't delete running instance '%s'\n", ti
->data
);
990 fprintf(stderr
, "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
, 1);
1006 for (ti
= as
->parms
[1].items
; ti
; ti
= ti
->next
) {
1007 code
= BOZO_SetStatus(tconn
, ti
->data
, BSTAT_NORMAL
);
1009 fprintf(stderr
, "bos: failed to start instance '%s' (%s)\n",
1010 ti
->data
, em(code
));
1016 StopServer(struct cmd_syndesc
*as
, void *arock
)
1018 struct rx_connection
*tconn
;
1020 struct cmd_item
*ti
;
1023 tconn
= GetConn(as
, 1);
1024 for (ti
= as
->parms
[1].items
; ti
; ti
= ti
->next
) {
1025 code
= BOZO_SetStatus(tconn
, ti
->data
, BSTAT_SHUTDOWN
);
1027 fprintf(stderr
, "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 fprintf(stderr
, "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
, int dodirs
)
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 fprintf(stderr
, "bos: could not parse partition ID '%s'\n", aparm1
);
1066 tp
= volutil_PartitionName(partNumber
);
1068 fprintf(stderr
, "bos: internal error parsing partition ID '%s'\n", aparm1
);
1071 strcpy(partName
, tp
);
1075 /* open the file name */
1077 outFile
= fopen(aoutName
, "w");
1079 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "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 fprintf(stderr
, "bos: command line too big\n");
1170 strcat(tbuffer
, " -orphans ");
1171 strcat(tbuffer
, orphans
);
1173 /* add the salvagedirs option if given */
1175 if (strlen(tbuffer
) + 14 > BOZO_BSSIZE
) {
1176 fprintf(stderr
, "bos: command line too big\n");
1179 strcat(tbuffer
, " -salvagedirs");
1184 parms
[1] = "now"; /* when to do it */
1186 BOZO_CreateBnode(aconn
, "cron", "salvage-tmp", parms
[0], parms
[1],
1187 parms
[2], parms
[3], parms
[4], notifier
);
1189 fprintf(stderr
, "bos: failed to start 'salvager' (%s)\n", em(code
));
1192 /* now wait for bnode to disappear */
1197 code
= BOZO_GetInstanceInfo(aconn
, "salvage-tmp", &tp
, &istatus
);
1200 if ((++count
% 5) == 0)
1201 printf("bos: waiting for salvage to complete.\n");
1203 if (code
!= BZNOENT
) {
1204 fprintf(stderr
, "bos: salvage failed (%s)\n", em(code
));
1209 /* now print the log file to the output file */
1210 printf("bos: salvage completed\n");
1211 if (aoutName
|| showlog
) {
1212 fprintf(outFile
, "SalvageLog:\n");
1213 tcall
= rx_NewCall(aconn
);
1214 /* MUST pass canonical (wire-format) salvager log path to bosserver */
1216 StartBOZO_GetLog(tcall
, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH
);
1218 code
= rx_EndCall(tcall
, code
);
1223 code
= rx_Read(tcall
, &buffer
, 1);
1226 putc(buffer
, outFile
);
1228 break; /* the end delimeter */
1230 code
= rx_EndCall(tcall
, 0);
1231 /* fall through into cleanup code */
1235 if (closeIt
&& outFile
)
1241 GetLogCmd(struct cmd_syndesc
*as
, void *arock
)
1243 struct rx_connection
*tconn
;
1244 struct rx_call
*tcall
;
1249 printf("Fetching log file '%s'...\n", as
->parms
[1].items
->data
);
1250 tconn
= GetConn(as
, 1);
1251 tcall
= rx_NewCall(tconn
);
1252 code
= StartBOZO_GetLog(tcall
, as
->parms
[1].items
->data
);
1254 code
= rx_EndCall(tcall
, code
);
1260 code
= rx_Read(tcall
, &buffer
, 1);
1266 break; /* the end delimeter */
1269 code
= rx_EndCall(tcall
, error
);
1270 /* fall through into cleanup code */
1274 afs_com_err("bos", code
, "(while reading log)");
1279 IsDAFS(struct rx_connection
*aconn
)
1281 char buffer
[BOZO_BSSIZE
];
1283 struct bozo_status istatus
;
1288 code
= BOZO_GetInstanceInfo(aconn
, "dafs", &tp
, &istatus
);
1290 /* no dafs bnode; cannot be dafs */
1294 /* dafs bnode is running; we must be dafs */
1298 /* At this point, either we have neither a dafs nor fs bnode running, or
1299 * we have an fs bnode running but the dafs bnode is stopped.
1301 * If an fs bnode is running, we are obviously not DAFS. If an fs bnode
1302 * is not running and a dafs bnode is not running... it's not certain if
1303 * we are DAFS or not DAFS. Just return 0 in that case; it shouldn't much
1304 * matter what we return, anyway */
1309 SalvageCmd(struct cmd_syndesc
*as
, void *arock
)
1311 struct rx_connection
*tconn
;
1314 char tname
[BOZO_BSSIZE
];
1316 extern struct ubik_client
*cstruct
;
1317 afs_int32 curGoal
, showlog
= 0, dafs
= 0;
1324 /* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
1325 tconn
= GetConn(as
, 1);
1327 /* find out whether fileserver is running demand attach fs */
1328 if (IsDAFS(tconn
)) {
1330 serviceName
= "dafs";
1335 /* we can do a volume, a partition or the whole thing, but not mixtures
1337 if (!as
->parms
[1].items
&& as
->parms
[2].items
) {
1338 fprintf(stderr
, "bos: must specify partition to salvage individual volume.\n");
1341 if (as
->parms
[5].items
&& as
->parms
[3].items
) {
1342 printf("bos: can not specify both -file and -showlog.\n");
1345 if (as
->parms
[4].items
&& (as
->parms
[1].items
|| as
->parms
[2].items
)) {
1346 fprintf(stderr
, "bos: can not specify -all with other flags.\n");
1350 /* get the output file name, if any */
1351 if (as
->parms
[3].items
)
1352 outName
= as
->parms
[3].items
->data
;
1356 if (as
->parms
[5].items
)
1359 /* parallel option */
1361 if (as
->parms
[6].items
)
1362 parallel
= as
->parms
[6].items
->data
;
1364 /* get the tmpdir filename if any */
1366 if (as
->parms
[7].items
)
1367 tmpDir
= as
->parms
[7].items
->data
;
1369 /* -orphans option */
1371 if (as
->parms
[8].items
) {
1372 orphans
= as
->parms
[8].items
->data
;
1376 if (!as
->parms
[9].items
) { /* -forceDAFS flag */
1377 fprintf(stderr
, "This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n");
1378 fprintf(stderr
, "must specify -forceDAFS flag in order to proceed.\n");
1383 if (as
->parms
[10].items
) { /* -salvagedirs */
1384 if (as
->parms
[4].items
) { /* -all */
1387 fprintf(stderr
, " -salvagedirs only possible with -all.\n");
1392 if (as
->parms
[4].items
) {
1393 /* salvage whole enchilada */
1394 curGoal
= GetServerGoal(tconn
, serviceName
);
1395 if (curGoal
== BSTAT_NORMAL
) {
1396 printf("bos: shutting down '%s'.\n", serviceName
);
1397 code
= BOZO_SetTStatus(tconn
, serviceName
, BSTAT_SHUTDOWN
);
1399 fprintf(stderr
, "bos: failed to stop '%s' (%s)\n", serviceName
, em(code
));
1402 code
= BOZO_WaitAll(tconn
); /* wait for shutdown to complete */
1405 (stderr
, "bos: failed to wait for file server shutdown, continuing.\n");
1407 /* now do the salvage operation */
1408 printf("Starting salvage.\n");
1409 rc
= DoSalvage(tconn
, NULL
, NULL
, outName
, showlog
, parallel
, tmpDir
,
1410 orphans
, dafs
, dodirs
);
1411 if (curGoal
== BSTAT_NORMAL
) {
1412 printf("bos: restarting %s.\n", serviceName
);
1413 code
= BOZO_SetTStatus(tconn
, serviceName
, BSTAT_NORMAL
);
1415 fprintf(stderr
, "bos: failed to restart '%s' (%s)\n", serviceName
, em(code
));
1421 } else if (!as
->parms
[2].items
) {
1422 if (!as
->parms
[1].items
) {
1424 (stderr
, "bos: must specify -all switch to salvage all partitions.\n");
1427 if (volutil_GetPartitionID(as
->parms
[1].items
->data
) < 0) {
1428 /* can't parse volume ID, so complain before shutting down
1431 fprintf(stderr
, "bos: can't interpret %s as partition ID.\n",
1432 as
->parms
[1].items
->data
);
1435 curGoal
= GetServerGoal(tconn
, serviceName
);
1436 /* salvage a whole partition (specified by parms[1]) */
1437 if (curGoal
== BSTAT_NORMAL
) {
1438 printf("bos: shutting down '%s'.\n", serviceName
);
1439 code
= BOZO_SetTStatus(tconn
, serviceName
, BSTAT_SHUTDOWN
);
1441 fprintf(stderr
, "bos: can't stop '%s' (%s)\n", serviceName
, em(code
));
1444 code
= BOZO_WaitAll(tconn
); /* wait for shutdown to complete */
1447 (stderr
, "bos: failed to wait for file server shutdown, continuing.\n");
1449 /* now do the salvage operation */
1450 printf("Starting salvage.\n");
1451 rc
= DoSalvage(tconn
, as
->parms
[1].items
->data
, NULL
, outName
,
1452 showlog
, parallel
, tmpDir
, orphans
, dafs
, 0);
1453 if (curGoal
== BSTAT_NORMAL
) {
1454 printf("bos: restarting '%s'.\n", serviceName
);
1455 code
= BOZO_SetTStatus(tconn
, serviceName
, BSTAT_NORMAL
);
1457 printf("bos: failed to restart '%s' (%s)\n", serviceName
, em(code
));
1464 /* salvage individual volume (don't shutdown fs first), just use
1465 * single-shot cron bnode. Must leave server running when using this
1466 * option, since salvager will ask file server for the volume */
1469 const char *confdir
;
1472 if (as
->parms
[ADDPARMOFFSET
].items
)
1473 tmpname
= as
->parms
[ADDPARMOFFSET
].items
->data
;
1477 localauth
= (as
->parms
[ADDPARMOFFSET
+ 2].items
!= 0);
1479 (localauth
? AFSDIR_SERVER_ETC_DIRPATH
:
1480 AFSDIR_CLIENT_ETC_DIRPATH
);
1482 code
= vsu_ClientInit(confdir
, tmpname
,
1483 AFSCONF_SECOPTS_FALLBACK_NULL
|
1484 AFSCONF_SECOPTS_NOAUTH
,
1488 newID
= vsu_GetVolumeID(as
->parms
[2].items
->data
, cstruct
, &err
);
1490 fprintf(stderr
, "bos: can't interpret %s as volume name or ID\n",
1491 as
->parms
[2].items
->data
);
1494 sprintf(tname
, "%u", newID
);
1497 (stderr
, "bos: can't initialize volume system client (code %d), trying anyway.\n",
1499 strncpy(tname
, as
->parms
[2].items
->data
, sizeof(tname
));
1501 if (volutil_GetPartitionID(as
->parms
[1].items
->data
) < 0) {
1502 /* can't parse volume ID, so complain before shutting down
1505 fprintf(stderr
, "bos: can't interpret %s as partition ID.\n",
1506 as
->parms
[1].items
->data
);
1509 printf("Starting salvage.\n");
1510 rc
= DoSalvage(tconn
, as
->parms
[1].items
->data
, tname
, outName
,
1511 showlog
, parallel
, tmpDir
, orphans
, dafs
, 0);
1519 IStatServer(struct cmd_syndesc
*as
, int int32p
)
1521 struct rx_connection
*tconn
;
1522 struct cmd_item
*ti
;
1525 tconn
= GetConn(as
, 0);
1526 for (ti
= as
->parms
[1].items
; ti
; ti
= ti
->next
) {
1527 DoStat(ti
->data
, tconn
, int32p
, firstTime
);
1534 DoStat(IN
char *aname
,
1535 IN
struct rx_connection
*aconn
,
1537 IN
int firstTime
) /* true iff first instance in cmd */
1543 struct bozo_status istatus
;
1545 char *is1
, *is2
, *is3
, *is4
; /* instance strings */
1548 code
= BOZO_GetInstanceInfo(aconn
, aname
, &tp
, &istatus
);
1550 fprintf(stderr
, "bos: failed to get instance info for '%s' (%s)\n", aname
,
1554 if (firstTime
&& aint32p
&& (istatus
.flags
& BOZO_BADDIRACCESS
))
1556 ("Bosserver reports inappropriate access on server directories\n");
1557 printf("Instance %s, ", aname
);
1559 printf("(type is %s) ", buffer
);
1560 if (istatus
.fileGoal
== istatus
.goal
) {
1562 printf("disabled, ");
1564 if (istatus
.fileGoal
)
1565 printf("temporarily disabled, ");
1567 printf("temporarily enabled, ");
1570 if (istatus
.flags
& BOZO_ERRORSTOP
)
1571 printf("stopped for too many errors, ");
1572 if (istatus
.flags
& BOZO_HASCORE
)
1573 printf("has core file, ");
1576 code
= BOZO_GetStatus(aconn
, aname
, &temp
, &tp
);
1578 fprintf(stderr
, "bos: failed to get status for instance '%s' (%s)\n", aname
,
1581 printf("currently ");
1582 if (temp
== BSTAT_NORMAL
)
1583 printf("running normally.\n");
1584 else if (temp
== BSTAT_SHUTDOWN
)
1585 printf("shutdown.\n");
1586 else if (temp
== BSTAT_STARTINGUP
)
1587 printf("starting up.\n");
1588 else if (temp
== BSTAT_SHUTTINGDOWN
)
1589 printf("shutting down.\n");
1590 if (buffer
[0] != 0) {
1591 printf(" Auxiliary status is: %s.\n", buffer
);
1595 /* are we done yet? */
1599 if (istatus
.procStartTime
)
1600 printf(" Process last started at %s (%d proc starts)\n",
1601 DateOf(istatus
.procStartTime
), istatus
.procStarts
);
1602 if (istatus
.lastAnyExit
) {
1603 printf(" Last exit at %s\n", DateOf(istatus
.lastAnyExit
));
1605 if (istatus
.lastErrorExit
) {
1606 is1
= is2
= is3
= is4
= NULL
;
1607 printf(" Last error exit at %s, ", DateOf(istatus
.lastErrorExit
));
1608 code
= BOZO_GetInstanceStrings(aconn
, aname
, &is1
, &is2
, &is3
, &is4
);
1609 /* don't complain about failing call, since could simply mean
1610 * interface mismatch.
1614 /* non-null instance string */
1615 printf("by %s, ", is1
);
1622 if (istatus
.errorSignal
) {
1623 if (istatus
.errorSignal
== SIGTERM
)
1624 printf("due to shutdown request\n");
1626 printf("due to signal %d\n", istatus
.errorSignal
);
1628 printf("by exiting with code %d\n", istatus
.errorCode
);
1632 /* try to display all the parms */
1635 code
= BOZO_GetInstanceParm(aconn
, aname
, i
, &tp
);
1638 printf(" Command %d is '%s'\n", i
+ 1, buffer
);
1641 code
= BOZO_GetInstanceParm(aconn
, aname
, 999, &tp
);
1643 /* Any type of failure is treated as not having a notifier program */
1644 printf(" Notifier is '%s'\n", buffer
);
1652 GetRestrict(struct cmd_syndesc
*as
, void *arock
)
1654 struct rx_connection
*tconn
;
1655 afs_int32 code
, val
;
1657 tconn
= GetConn(as
, 0);
1658 code
= BOZO_GetRestrictedMode(tconn
, &val
);
1660 fprintf(stderr
, "bos: failed to get restricted mode (%s)\n", em(code
));
1662 printf("Restricted mode is %s\n", val
? "on" : "off");
1668 SetRestrict(struct cmd_syndesc
*as
, void *arock
)
1670 struct rx_connection
*tconn
;
1671 afs_int32 code
, val
;
1673 tconn
= GetConn(as
, 1);
1674 util_GetInt32(as
->parms
[1].items
->data
, &val
);
1675 code
= BOZO_SetRestrictedMode(tconn
, val
);
1677 fprintf(stderr
, "bos: failed to set restricted mode (%s)\n", em(code
));
1682 add_std_args(struct cmd_syndesc
*ts
)
1684 cmd_Seek(ts
, ADDPARMOFFSET
);
1685 /* + 0 */ cmd_AddParm(ts
, "-cell", CMD_SINGLE
, CMD_OPTIONAL
, "cell name");
1686 /* + 1 */ cmd_AddParm(ts
, "-noauth", CMD_FLAG
, CMD_OPTIONAL
,
1687 "don't authenticate");
1688 /* + 2 */ cmd_AddParm(ts
, "-localauth", CMD_FLAG
, CMD_OPTIONAL
,
1689 "create tickets from KeyFile");
1692 #include "AFS_component_version_number.c"
1695 main(int argc
, char **argv
)
1698 struct cmd_syndesc
*ts
;
1700 __declspec(dllimport
)
1702 extern int afsconf_SawCell
;
1704 #ifdef AFS_AIX32_ENV
1706 * The following signal action for AIX is necessary so that in case of a
1707 * crash (i.e. core is generated) we can include the user's data section
1708 * in the core dump. Unfortunately, by default, only a partial core is
1709 * generated which, in many cases, isn't too useful.
1711 struct sigaction nsa
;
1713 sigemptyset(&nsa
.sa_mask
);
1714 nsa
.sa_handler
= SIG_DFL
;
1715 nsa
.sa_flags
= SA_FULLDUMP
;
1716 sigaction(SIGSEGV
, &nsa
, NULL
);
1717 sigaction(SIGABRT
, &nsa
, NULL
);
1723 fprintf(stderr
, "bos: could not initialize rx (%s)\n", em(code
));
1727 /* To resolve a AFSCELL environment "Note: ..." problem: Because bos calls ka_Init (why?) before any
1728 * checkup on the existance of a "-cell" option on the particular bos command we don't print the
1729 * message if a cell is passed in. Luckily the rest of the programs don't call these adhoc routines
1730 * and things work fine. Note that if the "-cell" isn't passed then we're still ok since later on
1731 * the proper routine (afsconf_GetCellInfo) is going to be called to do the right thing.
1733 afsconf_SawCell
= 1; /* Means don't print warning if AFSCELL is set */
1735 afsconf_SawCell
= 0; /* Reset it */
1736 /* don't check error code, since fails sometimes when we're setting up a
1738 initialize_CMD_error_table();
1739 initialize_BZ_error_table();
1741 ts
= cmd_CreateSyntax("start", StartServer
, NULL
, 0, "start running a server");
1742 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1743 cmd_AddParm(ts
, "-instance", CMD_LIST
, 0, "server process name");
1746 ts
= cmd_CreateSyntax("stop", StopServer
, NULL
, 0, "halt a server instance");
1747 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1748 cmd_AddParm(ts
, "-instance", CMD_LIST
, 0, "server process name");
1750 cmd_AddParm(ts
, "-wait", CMD_FLAG
, CMD_OPTIONAL
,
1751 "wait for process to stop");
1754 ts
= cmd_CreateSyntax("status", StatServer
, NULL
, 0,
1755 "show server instance status");
1756 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1757 cmd_AddParm(ts
, "-instance", CMD_LIST
, CMD_OPTIONAL
,
1758 "server process name");
1759 cmd_AddParm(ts
, "-long", CMD_FLAG
, CMD_OPTIONAL
, "long status");
1762 ts
= cmd_CreateSyntax("shutdown", Shutdown
, NULL
, 0, "shutdown all processes");
1763 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1764 cmd_AddParm(ts
, "-instance", CMD_LIST
, CMD_OPTIONAL
, "instances");
1766 cmd_AddParm(ts
, "-wait", CMD_FLAG
, CMD_OPTIONAL
,
1767 "wait for process to stop");
1770 ts
= cmd_CreateSyntax("startup", Startup
, NULL
, 0, "start all processes");
1771 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1772 cmd_AddParm(ts
, "-instance", CMD_LIST
, CMD_OPTIONAL
, "instances");
1775 ts
= cmd_CreateSyntax("restart", Restart
, NULL
, 0, "restart processes");
1776 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1777 cmd_AddParm(ts
, "-instance", CMD_LIST
, CMD_OPTIONAL
, "instances");
1778 cmd_AddParm(ts
, "-bosserver", CMD_FLAG
, CMD_OPTIONAL
,
1779 "restart bosserver");
1780 cmd_AddParm(ts
, "-all", CMD_FLAG
, CMD_OPTIONAL
, "restart all processes");
1785 ts
= cmd_CreateSyntax("create", CreateServer
, NULL
, 0,
1786 "create a new server instance");
1787 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1788 cmd_AddParm(ts
, "-instance", CMD_SINGLE
, 0, "server process name");
1789 cmd_AddParm(ts
, "-type", CMD_SINGLE
, 0, "server type");
1790 cmd_AddParm(ts
, "-cmd", CMD_LIST
, 0, "command lines");
1791 cmd_AddParm(ts
, "-notifier", CMD_SINGLE
, CMD_OPTIONAL
,
1792 "Notifier program");
1795 ts
= cmd_CreateSyntax("delete", DeleteServer
, NULL
, 0,
1796 "delete a server instance");
1797 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1798 cmd_AddParm(ts
, "-instance", CMD_LIST
, 0, "server process name");
1801 ts
= cmd_CreateSyntax("adduser", AddSUser
, NULL
, 0,
1802 "add users to super-user list");
1803 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1804 cmd_AddParm(ts
, "-user", CMD_LIST
, 0, "user names");
1807 ts
= cmd_CreateSyntax("removeuser", RemoveSUser
, NULL
, 0,
1808 "remove users from super-user list");
1809 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1810 cmd_AddParm(ts
, "-user", CMD_LIST
, 0, "user names");
1813 ts
= cmd_CreateSyntax("listusers", ListSUsers
, NULL
, 0, "list super-users");
1814 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1817 ts
= cmd_CreateSyntax("addkey", AddKey
, NULL
, 0,
1818 "add keys to key dbase (kvno 999 is bcrypt)");
1819 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1820 cmd_AddParm(ts
, "-key", CMD_SINGLE
, CMD_OPTIONAL
, "key");
1821 cmd_AddParm(ts
, "-kvno", CMD_SINGLE
, 0, "key version number");
1824 ts
= cmd_CreateSyntax("removekey", RemoveKey
, NULL
, 0,
1825 "remove keys from key dbase");
1826 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1827 cmd_AddParm(ts
, "-kvno", CMD_LIST
, 0, "key version number");
1830 ts
= cmd_CreateSyntax("listkeys", ListKeys
, NULL
, 0, "list keys");
1831 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1832 cmd_AddParm(ts
, "-showkey", CMD_FLAG
, CMD_OPTIONAL
,
1833 "show the actual key rather than the checksum");
1836 ts
= cmd_CreateSyntax("listhosts", ListHosts
, NULL
, 0, "get cell host list");
1837 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1839 cmd_CreateAlias(ts
, "getcell");
1841 ts
= cmd_CreateSyntax("setcellname", SetCellName
, NULL
, 0, "set cell name");
1842 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1843 cmd_AddParm(ts
, "-name", CMD_SINGLE
, 0, "cell name");
1846 ts
= cmd_CreateSyntax("addhost", AddHost
, NULL
, 0, "add host to cell dbase");
1847 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1848 cmd_AddParm(ts
, "-host", CMD_LIST
, 0, "host name");
1849 cmd_AddParm(ts
, "-clone", CMD_FLAG
, CMD_OPTIONAL
, "vote doesn't count");
1852 ts
= cmd_CreateSyntax("removehost", RemoveHost
, NULL
, 0,
1853 "remove host from cell dbase");
1854 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1855 cmd_AddParm(ts
, "-host", CMD_LIST
, 0, "host name");
1858 ts
= cmd_CreateSyntax("setauth", SetAuth
, NULL
, 0,
1859 "set authentication required flag");
1860 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1861 cmd_AddParm(ts
, "-authrequired", CMD_SINGLE
, 0,
1862 "on or off: authentication required for admin requests");
1865 ts
= cmd_CreateSyntax("install", Install
, NULL
, 0, "install program");
1866 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1867 cmd_AddParm(ts
, "-file", CMD_LIST
, 0, "files to install");
1868 cmd_AddParm(ts
, "-dir", CMD_SINGLE
, CMD_OPTIONAL
, "destination dir");
1871 ts
= cmd_CreateSyntax("uninstall", UnInstall
, NULL
, 0, "uninstall program");
1872 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1873 cmd_AddParm(ts
, "-file", CMD_LIST
, 0, "files to uninstall");
1874 cmd_AddParm(ts
, "-dir", CMD_SINGLE
, CMD_OPTIONAL
, "destination dir");
1877 ts
= cmd_CreateSyntax("getlog", GetLogCmd
, NULL
, 0, "examine log file");
1878 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1879 cmd_AddParm(ts
, "-file", CMD_SINGLE
, 0, "log file to examine");
1882 ts
= cmd_CreateSyntax("getdate", GetDate
, NULL
, 0, "get dates for programs");
1883 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1884 cmd_AddParm(ts
, "-file", CMD_LIST
, 0, "files to check");
1885 cmd_AddParm(ts
, "-dir", CMD_SINGLE
, CMD_OPTIONAL
, "destination dir");
1888 ts
= cmd_CreateSyntax("exec", Exec
, NULL
, 0, "execute shell command on server");
1889 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1890 cmd_AddParm(ts
, "-cmd", CMD_SINGLE
, 0, "command to execute");
1893 ts
= cmd_CreateSyntax("prune", Prune
, NULL
, 0, "prune server files");
1894 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1895 cmd_AddParm(ts
, "-bak", CMD_FLAG
, CMD_OPTIONAL
, "delete .BAK files");
1896 cmd_AddParm(ts
, "-old", CMD_FLAG
, CMD_OPTIONAL
, "delete .OLD files");
1897 cmd_AddParm(ts
, "-core", CMD_FLAG
, CMD_OPTIONAL
, "delete core files");
1898 cmd_AddParm(ts
, "-all", CMD_FLAG
, CMD_OPTIONAL
, "delete all junk files");
1901 ts
= cmd_CreateSyntax("setrestart", SetRestartCmd
, NULL
, 0,
1902 "set restart times");
1903 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_REQUIRED
, "machine name");
1904 cmd_AddParm(ts
, "-time", CMD_SINGLE
, CMD_REQUIRED
,
1905 "time to restart server");
1906 cmd_AddParm(ts
, "-general", CMD_FLAG
, CMD_OPTIONAL
,
1907 "set general restart time");
1908 cmd_AddParm(ts
, "-newbinary", CMD_FLAG
, CMD_OPTIONAL
,
1909 "set new binary restart time");
1911 cmd_CreateAlias(ts
, "setr");
1913 ts
= cmd_CreateSyntax("getrestart", GetRestartCmd
, NULL
, 0,
1914 "get restart times");
1915 cmd_AddParm(ts
, "-server", CMD_SINGLE
, CMD_REQUIRED
, "machine name");
1917 cmd_CreateAlias(ts
, "getr");
1919 ts
= cmd_CreateSyntax("salvage", SalvageCmd
, NULL
, 0,
1920 "salvage partition or volumes");
1921 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1922 cmd_AddParm(ts
, "-partition", CMD_SINGLE
, CMD_OPTIONAL
,
1923 "salvage partition");
1924 cmd_AddParm(ts
, "-volume", CMD_SINGLE
, CMD_OPTIONAL
,
1925 "salvage volume number or volume name");
1926 cmd_AddParm(ts
, "-file", CMD_SINGLE
, CMD_OPTIONAL
,
1927 "salvage log output file");
1928 cmd_AddParm(ts
, "-all", CMD_FLAG
, CMD_OPTIONAL
, "salvage whole server");
1929 cmd_AddParm(ts
, "-showlog", CMD_FLAG
, CMD_OPTIONAL
,
1930 "display salvage log");
1931 cmd_AddParm(ts
, "-parallel", CMD_SINGLE
, CMD_OPTIONAL
,
1932 "# of max parallel partition salvaging");
1933 cmd_AddParm(ts
, "-tmpdir", CMD_SINGLE
, CMD_OPTIONAL
,
1934 "directory to place tmp files");
1935 cmd_AddParm(ts
, "-orphans", CMD_SINGLE
, CMD_OPTIONAL
,
1936 "ignore | remove | attach");
1937 cmd_AddParm(ts
, "-forceDAFS", CMD_FLAG
, CMD_OPTIONAL
,
1938 "(DAFS) force salvage of demand attach fileserver");
1939 cmd_AddParm(ts
, "-salvagedirs", CMD_FLAG
, CMD_OPTIONAL
,
1940 "Force rebuild/salvage of all directories");
1943 ts
= cmd_CreateSyntax("getrestricted", GetRestrict
, NULL
, 0,
1944 "get restrict mode");
1945 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1948 ts
= cmd_CreateSyntax("setrestricted", SetRestrict
, NULL
, 0,
1949 "set restrict mode");
1950 cmd_AddParm(ts
, "-server", CMD_SINGLE
, 0, "machine name");
1951 cmd_AddParm(ts
, "-mode", CMD_SINGLE
, 0, "mode to set");
1955 code
= cmd_Dispatch(argc
, argv
);