Hi,

I would like to propose a change regarding the hard coded locations
of the monit configuration file.
Instead of having the fixed string "/usr/local/etc/monitrc" in file.c
why not using the (already existing) switch "--sysconfdir" provided
by the configure script?

The default location would remain "/usr/local/etc" (as sysconfdir is
defined as "$prefix/etc" and prefix is "/usr/local") but it would be
possible for people to override this. The pkgsrc package system for
NetBSD and Dragonfly BSD (and some other operating systems) is usually
set up to install into a directory hierarchy other than /usr/local.


As a consequence of this proposed change, it would be desirable to have
the location of the configuration file noted in the man page. Up to now
the parameters supplied to the configure script are not patched into the
man page during the configure or build stage.

The appended patches implement this proposal for using "--sysconfdir"
and building monit.1 dynamically from monit.1.in.
Apply all patches in the source directory, then rename the patched
"monit.1" to "monit.1.in", then run "configure" and "gmake".

ciao
     Klaus

$NetBSD$

C source files must be told where the "sysconfdir" is.

--- Makefile.in.orig    2007-01-11 23:04:46.000000000 +0100
+++ Makefile.in
@@ -61,7 +61,7 @@ PROG          = monit
 
 INCDIR         = -I. -I./device -I./http -I./process -I./protocols
 LIB            = @LEXLIB@ @LIBS@
-DEFINES                = [EMAIL PROTECTED]@
+DEFINES                = [EMAIL PROTECTED]@ -DSYSCONFDIR="\"@[EMAIL 
PROTECTED]""N
 
 # ------------------------------------------------------------------- #
 
$NetBSD$

Pre-processor macro SYSCONFDIR will be defined on the command line.
SYSCONFDIR has to be a string to enable string literal concatenation.

--- file.c.orig 2007-01-03 22:02:06.000000000 +0100
+++ file.c
@@ -145,9 +145,9 @@ time_t File_getTimestamp(char *object, m
 
 /**
  * Search the system for the monit control file. Try first ~/.monitrc,
- * if that fails try /etc/monitrc, then /usr/local/etc/monitrc and
- * finally ./monitrc.  Exit the application if the control file was
- * not found.
+ * if that fails try /etc/monitrc, then SYSCONFDIR/monitrc (default:
+ * /usr/local/etc/monitrc) and finally ./monitrc.
+ * Exit the application if the control file was not found.
  * @return The location of monits control file (monitrc)
  */
 char *File_findControlFile() {
@@ -164,7 +164,7 @@ char *File_findControlFile() {
     return (rcfile);
   }
   memset(rcfile, 0, STRLEN);
-  snprintf(rcfile, STRLEN, "/usr/local/etc/%s", MONITRC);
+  snprintf(rcfile, STRLEN, SYSCONFDIR "/%s", MONITRC);
   if(File_exist(rcfile)) {
     return (rcfile);
   }
@@ -174,7 +174,7 @@ char *File_findControlFile() {
     return (rcfile);
   }
   LogError("%s: Cannot find the control file at "
-      "~/.%s, /etc/%s, /usr/local/etc/%s or at ./%s \n",
+      "~/.%s, /etc/%s, " SYSCONFDIR "/%s or at ./%s \n",
       prog, MONITRC, MONITRC, MONITRC, MONITRC);
   exit(1);
   
$NetBSD$

Substitute variables in monit.1.in

--- configure.ac.orig   2007-02-19 23:39:58.000000000 +0100
+++ configure.ac
@@ -698,7 +698,7 @@ fi
 # ------------------------------------------------------------------------
 
 AC_CONFIG_HEADER([config.h])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile monit.1])
 AC_OUTPUT
 
 echo ""
--- monit.1.orig        2007-02-19 23:43:02.000000000 +0100
+++ monit.1     2007-04-17 00:00:04.000000000 +0200
@@ -308,7 +308,7 @@
 monit is configured and controlled via a control file called
 \&\fBmonitrc\fR. The default location for this file is ~/.monitrc. If
 this file does not exist, monit will try /etc/monitrc, then
-/usr/local/etc/monitrc and finally ./monitrc.
[EMAIL PROTECTED]@/monitrc and finally ./monitrc.
 .PP
 A monit control file consists of a series of service entries and
 global option statements in a free\-format, token-oriented syntax.
_______________________________________________
monit-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monit-dev

Reply via email to