From dcc670d210fefd1393525c2a965dc46259db32a9 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Mon, 5 Mar 2018 17:06:53 +0100
Subject: [PATCH] install configuration under access-check subdirectory

---
 bin/Makefile.am                 |  4 ++--
 bin/access-check-manager.cgi.in |  2 +-
 bin/access-check-manager.pl.in  |  2 +-
 conf/Makefile.am                | 12 ++++++------
 configure.ac                    |  2 ++
 5 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/bin/Makefile.am b/bin/Makefile.am
index 7122811..18bf5d1 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -9,13 +9,13 @@ EXTRA_DIST = access-check-manager.pl.in access-check-manager.cgi.in
 access-check-manager.pl: Makefile access-check-manager.pl.in
 	sed \
 		-e 's|[@]modulesdir[@]|$(modulesdir)|' \
-		-e 's|[@]sysconfdir[@]|$(sysconfdir)|' \
+		-e 's|[@]confdir[@]|$(confdir)|' \
 		< $(srcdir)/$@.in > $@
 	chmod +x $@
 
 access-check-manager.cgi: Makefile access-check-manager.cgi.in
 	sed \
 		-e 's|[@]modulesdir[@]|$(modulesdir)|' \
-		-e 's|[@]sysconfdir[@]|$(sysconfdir)|' \
+		-e 's|[@]confdir[@]|$(confdir)|' \
 		< $(srcdir)/$@.in > $@
 	chmod +x $@
diff --git a/bin/access-check-manager.cgi.in b/bin/access-check-manager.cgi.in
index 75c0d21..6513a8a 100755
--- a/bin/access-check-manager.cgi.in
+++ b/bin/access-check-manager.cgi.in
@@ -10,7 +10,7 @@ use Config::Tiny;
 use AccountManager::App;
 
 my $configuration_file =
-    $ENV{ACCOUNTMANAGER_CONFIG} || '@sysconfdir@/manager.conf';
+    $ENV{ACCOUNTMANAGER_CONFIG} || '@confdir@/manager.conf';
 my $configuration = Config::Tiny->read($configuration_file);
 
 my $app = AccountManager::App->new(
diff --git a/bin/access-check-manager.pl.in b/bin/access-check-manager.pl.in
index c045493..43652a8 100755
--- a/bin/access-check-manager.pl.in
+++ b/bin/access-check-manager.pl.in
@@ -47,7 +47,7 @@ pod2usage(
 ) unless $action;
 
 my $configuration_file =
-    $options{configuration} || '@sysconfdir@/manager.conf';
+    $options{configuration} || '@confdir@/manager.conf';
 my $configuration = Config::Tiny->read($configuration_file);
 
 AccountManager::DB->register_db(
diff --git a/conf/Makefile.am b/conf/Makefile.am
index 4e9b2b6..6032406 100644
--- a/conf/Makefile.am
+++ b/conf/Makefile.am
@@ -7,17 +7,17 @@ EXTRA_DIST = manager.conf.in
 manager.conf: Makefile manager.conf.in
 	sed \
 		-e 's|[@]templatesdir[@]|$(templatesdir)|' \
-		-e 's|[@]sysconfdir[@]|$(sysconfdir)|' \
+		-e 's|[@]confdir[@]|$(confdir)|' \
 		< $(srcdir)/$@.in > $@
 	chmod +x $@
 
 install-data-local:
-	$(mkinstalldirs) $(DESTDIR)$(sysconfdir)
-	if [ -f $(DESTDIR)$(sysconfdir)/manager.conf ]; then                       \
-	    $(INSTALL_DATA) manager.conf $(DESTDIR)$(sysconfdir)/manager.conf.new; \
+	$(mkinstalldirs) $(DESTDIR)$(confdir)
+	if [ -f $(DESTDIR)$(confdir)/manager.conf ]; then                       \
+	    $(INSTALL_DATA) manager.conf $(DESTDIR)$(confdir)/manager.conf.new; \
 	else                                                                       \
-	    $(INSTALL_DATA) manager.conf $(DESTDIR)$(sysconfdir)/manager.conf;     \
+	    $(INSTALL_DATA) manager.conf $(DESTDIR)$(confdir)/manager.conf;     \
 	fi
 
 uninstall-local:
-	rm -f $(DESTDIR)$(sysconfdir)/manager.conf
+	rm -f $(DESTDIR)$(confdir)/manager.conf
diff --git a/configure.ac b/configure.ac
index 787c7d0..0108bae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,10 +3,12 @@ AC_INIT([Access Check Manager], 1.0)
 AM_INIT_AUTOMAKE([foreign])
 AC_REQUIRE_AUX_FILE([tap-driver.sh])
 
+confdir=$sysconfdir/access-check
 wwwdir=$datadir/access-check/www
 modulesdir=$datadir/access-check/lib
 templatesdir=$datadir/access-check/templates
 
+AC_SUBST(confdir)
 AC_SUBST(wwwdir)
 AC_SUBST(modulesdir)
 AC_SUBST(templatesdir)
-- 
GitLab