From 222f8a5ea2cbf73db03ceacf68fa06c57769a0d2 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Thu, 24 Mar 2011 12:28:10 +0000 Subject: [PATCH] vlserver: Add options for config, log and db Make it possible to set the location of the vlserver's configuration directory, database file, and the file that it logs to, from the command line. This makes it possible to bring up a vlserver without requiring an installation on the system for testing purposes. Change-Id: I0a3fcc4fd10274588c1530f8b4f3e9782084c58c Reviewed-on: http://gerrit.openafs.org/4440 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman --- doc/man-pages/pod8/vlserver.pod | 31 +++++++++++++++--- src/vlserver/vlserver.c | 58 +++++++++++++++++++++++---------- 2 files changed, 68 insertions(+), 21 deletions(-) diff --git a/doc/man-pages/pod8/vlserver.pod b/doc/man-pages/pod8/vlserver.pod index cb892afbe..fb3501dcf 100644 --- a/doc/man-pages/pod8/vlserver.pod +++ b/doc/man-pages/pod8/vlserver.pod @@ -7,10 +7,13 @@ vlserver - Initializes the Volume Location Server =for html
-B S<<< [B<-p> >] >>> [B<-nojumbo>] [B<-jumbo>] [B<-rxbind>] S<<< [B<-d> >] >>> - [B<-allow-dotted-principals>] [B<-enable_peer_stats>] [B<-enable_process_stats>] - S<<< [B<-auditlog> >] >>> [B<-audit-interface> (file | sysvmq)] - [B<-help>] +vlserver S<<< [B<-p> >] >>> [B<-nojumbo>] +[B<-jumbo>] [B<-rxbind>] S<<< [B<-d> >] >>> +[B<-allow-dotted-principals>] S<<< [B<-database >] >>> +S<<< [B<-logfile >] >>> S<<< [B<-config >] >>> +[B<-enable_peer_stats>] [B<-enable_process_stats>] +S<<< [B<-auditlog> >] >>> S<<< [B<-audit-interface> (file | sysvmq)] >>> +[B<-help>] =for html
@@ -123,6 +126,26 @@ L for an explanation of each interface. Bind the Rx socket to the primary interface only. (If not specified, the Rx socket will listen on all interfaces.) +=item B<-logfile > + +Sets the file to use for server logging. If logfile is not specified, and +no other logging options are supplied, this will be F. +Note that this option is intended for debugging and testing purposes. +Changing the location of the log file from the command line may result +in undesirable interactions with tools such as B. + +=item B<-database > + +Set the location of the database used by this program. This option is +intended primarily for testing purposes. + +=item B<-config > + +Set the location of the configuration directory used to configure this +service. In a typical configuration this will be F - this +option allows the use of alternative configuration locations for testing +purposes. + =item B<-help> Prints the online help for this command. All other valid options are diff --git a/src/vlserver/vlserver.c b/src/vlserver/vlserver.c index ffeb49885..bc1ad86f5 100644 --- a/src/vlserver/vlserver.c +++ b/src/vlserver/vlserver.c @@ -38,7 +38,6 @@ #include "vlserver_internal.h" #define MAXLWP 16 -const char *vl_dbaseName; struct afsconf_dir *vldb_confdir = 0; /* vldb configuration dir */ int lwps = 9; @@ -132,6 +131,10 @@ main(int argc, char **argv) char *auditFileName = NULL; afs_uint32 host = ntohl(INADDR_ANY); + const char *vl_dbaseName; + const char *configDir; + const char *logFile; + #ifdef AFS_AIX32_ENV /* * The following signal action for AIX is necessary so that in case of a @@ -150,6 +153,20 @@ main(int argc, char **argv) #endif osi_audit_init(); + /* Initialize dirpaths */ + if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) { +#ifdef AFS_NT40_ENV + ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0); +#endif + fprintf(stderr, "%s: Unable to obtain AFS server directory.\n", + argv[0]); + exit(2); + } + + vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH; + configDir = AFSDIR_SERVER_ETC_DIRPATH; + logFile = AFSDIR_SERVER_PTLOG_FILEPATH; + /* Parse command line */ for (index = 1; index < argc; index++) { if (strcmp(argv[index], "-noauth") == 0) { @@ -220,11 +237,29 @@ main(int argc, char **argv) serverLogSyslog = 1; serverLogSyslogFacility = atoi(argv[index] + 8); #endif + } else if ((strcmp(argv[index], "-database") == 0) + || (strcmp(argv[index], "-db") == 0)) { + vl_dbaseName = argv[++index]; + } else if (strcmp(argv[index], "-config") == 0) { + if ((index + 1) > argc) { + fprintf(stderr, "missing argument for -config\n"); + return -1; + } + configDir = argv[++index]; + } else if (strcmp(argv[index], "-logfile") == 0) { + if ((index + 1) > argc) { + fprintf(stderr, "missing argument for -logfile\n"); + return -1; + } + logFile = argv[++index]; } else { /* support help flag */ - printf("Usage: vlserver [-p ] [-nojumbo] " + printf("Usage: vlserver [-database ] [-nojumbo] " "[-rxmaxmtu ] [-rxbind] [-allow-dotted-principals] " - "[-auditlog ] [-jumbo] [-d ] "); + "[-auditlog ] [-jumbo] [-d ] " + "[-config ] " + "[-logfile ] "); #ifndef AFS_NT40_ENV printf("[-syslog[=FACILITY]] "); #endif @@ -239,28 +274,17 @@ main(int argc, char **argv) osi_audit_file(auditFileName); } - /* Initialize dirpaths */ - if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) { -#ifdef AFS_NT40_ENV - ReportErrorEventAlt(AFSEVT_SVR_NO_INSTALL_DIR, 0, argv[0], 0); -#endif - fprintf(stderr, "%s: Unable to obtain AFS server directory.\n", - argv[0]); - exit(2); - } - vl_dbaseName = AFSDIR_SERVER_VLDB_FILEPATH; - #ifndef AFS_NT40_ENV serverLogSyslogTag = "vlserver"; #endif - OpenLog(AFSDIR_SERVER_VLOG_FILEPATH); /* set up logging */ + OpenLog(logFile); /* set up logging */ SetupLogSignals(); - tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); + tdir = afsconf_Open(configDir); if (!tdir) { printf ("vlserver: can't open configuration files in dir %s, giving up.\n", - AFSDIR_SERVER_ETC_DIRPATH); + configDir); exit(1); } #ifdef AFS_NT40_ENV -- 2.39.5