Permalink
Browse files

Implement etc/config.d to place config snippets ( Lars Michelsen )

  • Loading branch information...
1 parent 9ccf3e0 commit f68359e1fb01660cef3a489591d471f9022dd8e0 @lingej committed Mar 14, 2012
Showing with 27 additions and 8 deletions.
  1. +2 −1 ChangeLog
  2. +1 −0 sample-config/Makefile.in
  3. +24 −7 share/pnp/application/models/config.php
View
@@ -5,7 +5,8 @@
* Bugfix: rrd_convert.pl use XML tag TEMPLATE instead of CHECKCOMMAND to selects RRDs ( Sven Velt )
* Feature: npcdmod.o increase perfdata buffer and log discarded perfdata ( Birger Schmidt )
* Feature: rrd_modify.pl to change number of data sources of an RRD file
- * Feature: new template check_apachestatus_auto.php
+ * Feature: New template check_apachestatus_auto.php
+ * Feature: Implement etc/config.d to place config snippets ( Lars Michelsen )
**pnp-0.6.16 11/21/2011**
* Bugfix: Fixed single quoted check_multi labels (Reported by Matthias Flacke)
@@ -36,6 +36,7 @@ install:
-rm -f $(DESTDIR)$(HTMLDIR)/conf/config.php
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(SYSCONFDIR)
+ $(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(SYSCONFDIR)/config.d
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(SYSCONFDIR)/check_commands
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(SYSCONFDIR)/pages
$(INSTALL) -m 644 $(INSTALL_OPTS) pnp/pnp4nagios_release $(DESTDIR)$(SYSCONFDIR)
@@ -39,15 +39,32 @@ public function read_config(){
throw new Kohana_Exception('error.config-not-found', $config.'.php');
}
- if (is_readable($config . "_local.php")) {
- $array_a = $views;
- $views = array();
- include ($config . "_local.php");
- $array_b = $views;
- if(sizeof($views) == 0 ){
- $views = $array_a;
+ // Load optional config files
+ // a) the _local.php config
+ // b) all .php files which do not start with a "." in config.d/
+ $custom_configs = array($config . "_local.php");
+ if (file_exists($config . ".d") && is_dir($config . ".d")) {
+ $dh = opendir($config . ".d");
+ while (($file = readdir($dh)) !== false) {
+ if ($file[0] != '.' && substr($file, -4) == '.php') {
+ $custom_configs[] = $config . ".d/" .$file;
+ }
}
+ closedir($dh);
}
+
+ foreach($custom_configs AS $config_file) {
+ if (is_readable($config_file)) {
+ $array_a = $views;
+ $views = array();
+ include ($config_file);
+ $array_b = $views;
+ if(sizeof($views) == 0 ){
+ $views = $array_a;
+ }
+ }
+ }
+
$this->conf = $conf;
$this->views = $views;
}

0 comments on commit f68359e

Please sign in to comment.