Skip to content

Commit

Permalink
Add sysconfdir to search path for config files
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Dave committed Nov 5, 2024
1 parent 4c6de19 commit d79e5c5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ACLOCAL_AMFLAGS = -I m4

SUBDIRS = src po

pkgsysconfdir = $(sysconfdir)/@PACKAGE@
libstatedir = @localstatedir@/lib/@PACKAGE@

dist_libstate_DATA = \
Expand Down
5 changes: 5 additions & 0 deletions doc/motionplus_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,11 @@ <h2><a name="config_files"></a> The Configuration Files </h2>
by --localstatedir=DIR during the configure step of installation. If this was
not defined, it will default to /var/lib/motionplus or /usr/local/var/lib/motionplus
depending upon your system</li>
<li> The directory defined by --sysconfdir=DIR during the configure step of installation.
If this was not defined, it will default to /etc/motionplus or /usr/local/etc/motionplus
depending upon your system. Please note that the use of this directory for the configuration
files is deprecated. Some significant functionality of Motionplus will not be available
if the configuration files are in this directory.</li>
</ol>
<p></p>
The motionplus.conf file specifies parameters for the entire MotionPlus application and defaults for
Expand Down
5 changes: 4 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
# */


AM_CPPFLAGS= -Dconfigdir=\"$(localstatedir)/lib/@PACKAGE@\" -DLOCALEDIR=\"$(localedir)\"
AM_CPPFLAGS= \
-Dconfigdir=\"$(localstatedir)/lib/@PACKAGE@\" \
-Dsysconfdir=\"$(sysconfdir)/motionplus\" \
-DLOCALEDIR=\"$(localedir)\"

LDADD = $(LIBINTL)

Expand Down
15 changes: 15 additions & 0 deletions src/conf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4310,6 +4310,21 @@ void cls_config::init()
}
}

if (filename == "") {
filename = std::string( sysconfdir ) + std::string("/motionplus.conf");
if (stat(filename.c_str(), &statbuf) != 0) {
filename = "";
}
if (filename != "") {
MOTPLS_LOG(WRN, TYPE_ALL, SHOW_ERRNO
,_("The configuration file location '%s' is deprecated.")
, sysconfdir );
MOTPLS_LOG(WRN, TYPE_ALL, SHOW_ERRNO
,_("The new default configuration file location is '%s'")
, configdir );
}
}

if (filename == "") {
MOTPLS_LOG(ALR, TYPE_ALL, SHOW_ERRNO
,_("Could not open configuration file"));
Expand Down

0 comments on commit d79e5c5

Please sign in to comment.