diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index d410cb6a..10b1f953 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -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 } diff --git a/configure.ac b/configure.ac index 845b6488..d78bb769 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/snapraid.1 b/snapraid.1 index 5d6178ba..6ec25a19 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -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] ... diff --git a/snapraid.d b/snapraid.d index 82c78620..d125d1bd 100644 --- a/snapraid.d +++ b/snapraid.d @@ -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): diff --git a/snapraid.txt b/snapraid.txt index 86067808..f0b9fb43 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -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):