Respect sysconfdir for configuration file location

The sysconfdir is used if it exists, otherwise it fallbacks
to the previous default /etc.
This commit is contained in:
James Sanderson 2016-11-06 19:30:01 +00:00 • committed by Andrea Mazzoleni
parent 8f625f2be4
commit ee1aa840f1
5 changed files with 40 additions and 16 deletions

View file

@ -241,7 +241,13 @@ void config(char* conf, size_t conf_size, const char* argv0)
#else
(void)argv0;
pathcpy(conf, conf_size, "/etc/" PACKAGE ".conf");
#ifdef SYSCONFDIR
/* if it exists, give precedence at sysconfdir, usually /usr/local/etc */
if (access(SYSCONFDIR "/" PACKAGE ".conf", F_OK) == 0)
pathcpy(conf, conf_size, SYSCONFDIR "/" PACKAGE ".conf");
else /* otherwise fallback to plain /etc */
#endif
pathcpy(conf, conf_size, "/etc/" PACKAGE ".conf");
#endif
}

View file

@ -364,6 +364,12 @@ AC_ARG_VAR([TESTENV_SSSE3], [Test environment for SSSE3])
AC_ARG_VAR([TESTENV_SSE42], [Test environment for SSE42])
AC_ARG_VAR([TESTENV_AVX2], [Test environment for AVX2])
dnl Expand default prefix, required to expand sysconfdir=$prefix/etc
test "x$prefix" = xNONE && prefix=$ac_default_prefix
dnl Set the configuration directory in config.h
AC_DEFINE_UNQUOTED([SYSCONFDIR],["$(eval echo $sysconfdir)"],[Configuration directory])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View file

@ -996,9 +996,11 @@ files using a different hash.
SnapRAID provides the following options:
.TP
.B \-c, \-\-conf CONFIG
Selects the configuration file. If not specified it\'s assumed
the file \[dq]/etc/snapraid.conf\[dq] in Unix, and \[dq]snapraid.conf\[dq] in
the current directory in Windows.
Selects the configuration file to use. If not specified in Unix
it\'s used the file \[dq]/usr/local/etc/snapraid.conf\[dq] if it exists,
or \[dq]/etc/snapraid.conf\[dq] otherwise.
In Windows it\'s used the file \[dq]snapraid.conf\[dq] in the same
directory of \[dq]snapraid.exe\[dq].
.TP
.B \-f, \-\-filter PATTERN
Filters the files to process in \[dq]check\[dq] and \[dq]fix\[dq].
@ -1231,8 +1233,10 @@ Prints the program version.
SnapRAID requires a configuration file to know where your disk array
is located, and where storing the parity information.
.PP
This configuration file is located in /etc/snapraid.conf in Unix or
in the execution directory in Windows.
In Unix it\'s used the file \[dq]/usr/local/etc/snapraid.conf\[dq] if it exists,
or \[dq]/etc/snapraid.conf\[dq] otherwise.
In Windows it\'s used the file \[dq]snapraid.conf\[dq] in the same
directory of \[dq]snapraid.exe\[dq].
.PP
It should contain the following options (case sensitive):
.SS parity FILE [,FILE] ...

View file

@ -694,9 +694,11 @@ Options
SnapRAID provides the following options:
-c, --conf CONFIG
Selects the configuration file. If not specified it's assumed
the file "/etc/snapraid.conf" in Unix, and "snapraid.conf" in
the current directory in Windows.
Selects the configuration file to use. If not specified in Unix
it's used the file "/usr/local/etc/snapraid.conf" if it exists,
or "/etc/snapraid.conf" otherwise.
In Windows it's used the file "snapraid.conf" in the same
directory of "snapraid.exe".
-f, --filter PATTERN
Filters the files to process in "check" and "fix".
@ -930,8 +932,10 @@ Configuration
SnapRAID requires a configuration file to know where your disk array
is located, and where storing the parity information.
This configuration file is located in /etc/snapraid.conf in Unix or
in the execution directory in Windows.
In Unix it's used the file "/usr/local/etc/snapraid.conf" if it exists,
or "/etc/snapraid.conf" otherwise.
In Windows it's used the file "snapraid.conf" in the same
directory of "snapraid.exe".
It should contain the following options (case sensitive):

View file

@ -755,9 +755,11 @@ files using a different hash.
SnapRAID provides the following options:
-c, --conf CONFIG
Selects the configuration file. If not specified it's assumed
the file "/etc/snapraid.conf" in Unix, and "snapraid.conf" in
the current directory in Windows.
Selects the configuration file to use. If not specified in Unix
it's used the file "/usr/local/etc/snapraid.conf" if it exists,
or "/etc/snapraid.conf" otherwise.
In Windows it's used the file "snapraid.conf" in the same
directory of "snapraid.exe".
-f, --filter PATTERN
Filters the files to process in "check" and "fix".
@ -994,8 +996,10 @@ SnapRAID provides the following options:
SnapRAID requires a configuration file to know where your disk array
is located, and where storing the parity information.
This configuration file is located in /etc/snapraid.conf in Unix or
in the execution directory in Windows.
In Unix it's used the file "/usr/local/etc/snapraid.conf" if it exists,
or "/etc/snapraid.conf" otherwise.
In Windows it's used the file "snapraid.conf" in the same
directory of "snapraid.exe".
It should contain the following options (case sensitive):