Add a new -d argument which is used to specify an alternate root for log
files similar to DESTDIR in the BSD make process. This only affects log file paths not config file (-f) or archive directory (-a) paths.
This commit is contained in:
parent
cfeb1f524d
commit
842ba60ee2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=136127
@ -28,6 +28,7 @@
|
||||
.Op Fl CFnrsv
|
||||
.Op Fl R Ar tagname
|
||||
.Op Fl a Ar directory
|
||||
.Op Fl d Ar directory
|
||||
.Op Fl f Ar config_file
|
||||
.Op Ar
|
||||
.Sh DESCRIPTION
|
||||
@ -99,6 +100,15 @@ does not exist,
|
||||
it will be created when
|
||||
.Nm
|
||||
is run.
|
||||
.It Fl d Ar directory
|
||||
Specify a
|
||||
.Ar directory
|
||||
which all log files will be relative to.
|
||||
To allow archiving of logs outside the root, the
|
||||
.Ar directory
|
||||
passed to the
|
||||
.Fl a
|
||||
option is unaffected.
|
||||
.It Fl v
|
||||
Place
|
||||
.Nm
|
||||
|
@ -187,6 +187,7 @@ int rotatereq = 0; /* -R = Always rotate the file(s) as given */
|
||||
/* the run command). */
|
||||
char *requestor; /* The name given on a -R request */
|
||||
char *archdirname; /* Directory path to old logfiles archive */
|
||||
char *destdir = NULL; /* Directory to treat at root for logs */
|
||||
const char *conf; /* Configuration file to use */
|
||||
|
||||
struct ptime_data *dbg_timenow; /* A "timenow" value set via -D option */
|
||||
@ -339,7 +340,10 @@ init_entry(const char *fname, struct conf_entry *src_entry)
|
||||
if (tempwork == NULL)
|
||||
err(1, "malloc of conf_entry for %s", fname);
|
||||
|
||||
tempwork->log = strdup(fname);
|
||||
if (destdir == NULL)
|
||||
tempwork->log = strdup(fname);
|
||||
else
|
||||
asprintf(&tempwork->log, "%s%s", destdir, fname);
|
||||
if (tempwork->log == NULL)
|
||||
err(1, "strdup for %s", fname);
|
||||
|
||||
@ -694,12 +698,15 @@ parse_args(int argc, char **argv)
|
||||
*p = '\0';
|
||||
|
||||
/* Parse command line options. */
|
||||
while ((ch = getopt(argc, argv, "a:f:nrsvCD:FR:")) != -1)
|
||||
while ((ch = getopt(argc, argv, "a:d:f:nrsvCD:FR:")) != -1)
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
archtodir++;
|
||||
archdirname = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
destdir = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
conf = optarg;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user