vlserver: Add options for config, log and db
authorSimon Wilkinson <sxw@your-file-system.com>
Thu, 24 Mar 2011 12:28:10 +0000 (12:28 +0000)
committerJeffrey Altman <jaltman@openafs.org>
Fri, 8 Apr 2011 04:51:29 +0000 (21:51 -0700)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>

doc/man-pages/pod8/vlserver.pod
src/vlserver/vlserver.c

index cb892af..fb3501d 100644 (file)
@@ -7,10 +7,13 @@ vlserver - Initializes the Volume Location Server
 =for html
 <div class="synopsis">
 
-B<vlserver> S<<< [B<-p> <I<number of threads>>] >>> [B<-nojumbo>] [B<-jumbo>] [B<-rxbind>] S<<< [B<-d> <I<debug level>>] >>>
-    [B<-allow-dotted-principals>] [B<-enable_peer_stats>] [B<-enable_process_stats>] 
-        S<<< [B<-auditlog> <I<log path>>] >>> [B<-audit-interface> (file | sysvmq)]
-    [B<-help>]
+vlserver S<<< [B<-p> <I<number of threads>>] >>> [B<-nojumbo>]
+[B<-jumbo>] [B<-rxbind>] S<<< [B<-d> <I<debug level>>] >>>
+[B<-allow-dotted-principals>] S<<< [B<-database <I<database path>>] >>>
+S<<< [B<-logfile <I<log file>>] >>> S<<< [B<-config <I<configuration path>>] >>>
+[B<-enable_peer_stats>] [B<-enable_process_stats>]
+S<<< [B<-auditlog> <I<log path>>] >>> S<<< [B<-audit-interface> (file | sysvmq)] >>>
+[B<-help>]
 
 =for html
 </div>
@@ -123,6 +126,26 @@ L<fileserver(8)> 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 <I<log file>>
+
+Sets the file to use for server logging. If logfile is not specified, and
+no other logging options are supplied, this will be F</usr/afs/logs/VLLog>.
+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<bos>.
+
+=item B<-database <I<databse path>>
+
+Set the location of the database used by this program. This option is
+intended primarily for testing purposes.
+
+=item B<-config <I<configuration directory>>
+
+Set the location of the configuration directory used to configure this
+service. In a typical configuration this will be F</usr/afs/etc> - 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
index ffeb498..bc1ad86 100644 (file)
@@ -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 <number of processes>] [-nojumbo] "
+           printf("Usage: vlserver [-database <db path] "
+                  "[-p <number of processes>] [-nojumbo] "
                   "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
-                  "[-auditlog <log path>] [-jumbo] [-d <debug level>] ");
+                  "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
+                  "[-config <config directory path>] "
+                  "[-logfile <log file path>] ");
 #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