From 1b98f858211fe54bda4aa642136887e49f0a22c4 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 23 Jan 2014 16:44:12 +0100 Subject: [PATCH] conf: Generate and install config sippets for option descriptions The strongswan.d directory is also created relative to the configured location of strongswan.conf. --- conf/.gitignore | 3 ++ conf/Makefile.am | 67 ++++++++++++++++++++++++++++++++++++++--- conf/default.opt | 3 ++ conf/options/charon.opt | 2 ++ conf/plugins/test.opt | 30 ++++++++++++++++++ conf/strongswan.conf | 3 +- configure.ac | 1 + 7 files changed, 103 insertions(+), 6 deletions(-) create mode 100644 conf/.gitignore create mode 100644 conf/default.opt create mode 100644 conf/options/charon.opt create mode 100644 conf/plugins/test.opt diff --git a/conf/.gitignore b/conf/.gitignore new file mode 100644 index 000000000..1a3e5248a --- /dev/null +++ b/conf/.gitignore @@ -0,0 +1,3 @@ +default.conf +*/*.conf +*/*.tmp \ No newline at end of file diff --git a/conf/Makefile.am b/conf/Makefile.am index 7a5c263b1..bdab4d39a 100644 --- a/conf/Makefile.am +++ b/conf/Makefile.am @@ -1,6 +1,63 @@ -EXTRA_DIST = strongswan.conf +# make this relative to the location of strongswan.conf +strongswanconfdir = `dirname $(strongswan_conf)` +strongswanddir = $(strongswanconfdir)/strongswan.d +charonconfdir = $(strongswanddir)/charon -install-exec-local : - test -e "$(DESTDIR)${sysconfdir}" || $(INSTALL) -d "$(DESTDIR)$(sysconfdir)" - test -e "$(DESTDIR)$(sysconfdir)/strongswan.conf" || $(INSTALL) -m 640 $(srcdir)/strongswan.conf $(DESTDIR)$(sysconfdir)/strongswan.conf || true - test -e "$(DESTDIR)${sysconfdir}/strongswan.d" || $(INSTALL) -d "$(DESTDIR)$(sysconfdir)/strongswan.d" +options = \ + options/charon.opt + +plugins = \ + plugins/test.opt + +alloptions = $(options) $(plugins) + +confsnippets = $(alloptions:opt=conf) + +# we only install snippets for enabled plugins +plugins_install_tmp = $(charon_plugins:%=plugins/%.tmp) +plugins_install_src = $(charon_plugins:%=plugins/%.conf) + +strongswand_DATA = $(options:opt=conf) +charonconf_DATA = $(plugins_install_src) + +BUILT_SOURCES = default.conf $(confsnippets) +EXTRA_DIST = format-options.py strongswan.conf default.opt \ + default.conf $(alloptions) $(confsnippets) + +.opt.conf: + $(AM_V_GEN) \ + case "$<" in \ + *plugins/*) \ + sed \ + -e "s:\@PLUGIN_NAME\@:`basename $< .opt`:" \ + $(srcdir)/default.opt | cat - $< | \ + $(PYTHON) $(srcdir)/format-options.py -f conf -r charon.plugins > $(srcdir)/$@ \ + ;; \ + *) \ + $(PYTHON) $(srcdir)/format-options.py -f conf -r charon.plugins $< > $(srcdir)/$@ \ + ;; \ + esac + +# we need another implicit rule to generate files from the generic template only +# if the rules above did not catch it. this requires an intermediate step that +# generates a copy of the generic config template. +$(plugins_install_tmp): + @cp $(srcdir)/default.conf $(srcdir)/$@ + +.tmp.conf: + $(AM_V_GEN) \ + sed \ + -e "s:\@PLUGIN_NAME\@:`basename $< .tmp`:" \ + $(srcdir)/$< > $(srcdir)/$@ + +maintainer-clean-local: + cd $(srcdir) && \ + rm -f $(confsnippets) default.conf plugins/*.conf plugins/*.tmp + +install-exec-local: + test -e "$(DESTDIR)${strongswanconfdir}" || $(INSTALL) -d "$(DESTDIR)$(strongswanconfdir)" + test -e "$(DESTDIR)$(strongswanconfdir)/strongswan.conf" || $(INSTALL) -m 640 $(srcdir)/strongswan.conf $(DESTDIR)$(strongswanconfdir)/strongswan.conf || true + +install-data-hook: + chmod 0640 $(DESTDIR)$(strongswanddir)/*.conf + chmod 0640 $(DESTDIR)$(charonconfdir)/*.conf diff --git a/conf/default.opt b/conf/default.opt new file mode 100644 index 000000000..8c833642d --- /dev/null +++ b/conf/default.opt @@ -0,0 +1,3 @@ +charon.plugins.@PLUGIN_NAME@.load := yes + Whether to load the plugin. Can also be an integer to increase the priority + of this plugin. diff --git a/conf/options/charon.opt b/conf/options/charon.opt new file mode 100644 index 000000000..a7a2259a5 --- /dev/null +++ b/conf/options/charon.opt @@ -0,0 +1,2 @@ +charon.threads = 16 + Number of threads \ No newline at end of file diff --git a/conf/plugins/test.opt b/conf/plugins/test.opt new file mode 100644 index 000000000..9d962e30d --- /dev/null +++ b/conf/plugins/test.opt @@ -0,0 +1,30 @@ +charon.plugins.test.opt + This is a normal option without default + +charon.plugins.test.noncomment := set this + This will not be commented out + +charon.plugins.test.def = default + Option with default + +charon.plugins.test.sectionnocomment.opt = val + The section this is in has no description + +charon.plugins.test.sub {} + This section has comments + +charon.plugins.test.sub.opt = option in sub + Section option + +charon.plugins.test. { # } + Commented example section + +charon.plugins.test..val = value + This is commented anyway + +charon.plugins.test..assign := value + This is commented too because of the commented section + +charon.plugins.test.sub = value + Sections can also be options with values + Longer description with **bold** and _italic_. diff --git a/conf/strongswan.conf b/conf/strongswan.conf index b2493e84f..d90672861 100644 --- a/conf/strongswan.conf +++ b/conf/strongswan.conf @@ -5,8 +5,9 @@ # Configuration changes should be made in the included files charon { + load_modular = yes plugins { - + include strongswan.d/charon/*.conf } } diff --git a/configure.ac b/configure.ac index 2eba4d5ca..cfa9b4a99 100644 --- a/configure.ac +++ b/configure.ac @@ -302,6 +302,7 @@ AC_PROG_EGREP AC_PROG_AWK AC_PROG_LEX AC_PROG_YACC +AM_PATH_PYTHON(,,[:]) AC_PATH_PROG([PERL], [perl], [], [$PATH:/bin:/usr/bin:/usr/local/bin]) AC_PATH_PROG([GPERF], [gperf], [], [$PATH:/bin:/usr/bin:/usr/local/bin])