summaryrefslogtreecommitdiff
path: root/Build.PL
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-05-15 16:59:54 +0200
committerDaniel Friesel <derf@finalrewind.org>2014-05-15 16:59:54 +0200
commit62bbd806c9c4a34169968af71d733a0a5123e462 (patch)
tree9e4a75dc346b2c8867e28e2e0b8e9b8a4d7694fd /Build.PL
parent616907aa2e82709538cb67bfda1fb2444793cbeb (diff)
Build.PL: Try icinga2 paths first, default to icinga1
Diffstat (limited to 'Build.PL')
-rw-r--r--Build.PL60
1 files changed, 48 insertions, 12 deletions
diff --git a/Build.PL b/Build.PL
index 740f87b..6de8dd3 100644
--- a/Build.PL
+++ b/Build.PL
@@ -4,6 +4,21 @@ use strict;
use warnings;
use Module::Build;
+
+# defaults at the end
+my @object_paths = (
+ '/var/cache/icinga2/objects.cache',
+ '/var/cache/icinga/objects.cache',
+);
+my @status_paths = (
+ '/var/cache/icinga2/status.dat',
+ '/var/lib/icinga/status.dat',
+);
+my @command_paths = (
+ '/var/run/icinga2/cmd/icinga.cmd',
+ '/var/lib/icinga/rw/icinga.cmd',
+);
+
my $build = Module::Build->new(
build_requires => {
'Test::More' => 0,
@@ -68,28 +83,49 @@ EOF
if ($build->args('icli-object-file')) {
$build->config_data(object_file => $build->args('icli-object-file'));
}
-elsif (not -e $build->config_data('object_file')) {
- my $reply = $build->prompt('Enter location of Icinga objects.cache',
- $build->config_data('object_file'));
- $build->config_data(object_file => $reply);
+else {
+ for my $path (@object_paths) {
+ if (not -e $build->config_data('object_file')) {
+ $build->config_data(object_file => $path);
+ }
+ }
+ if (not -e $build->config_data('object_file')) {
+ my $reply = $build->prompt('Enter location of Icinga objects.cache',
+ $build->config_data('object_file'));
+ $build->config_data(object_file => $reply);
+ }
}
if ($build->args('icli-status-file')) {
$build->config_data(status_file => $build->args('icli-status-file'));
}
-elsif (not -e $build->config_data('status_file')) {
- my $reply = $build->prompt('Enter location of Icinga status.dat',
- $build->config_data('status_file'));
- $build->config_data(status_file => $reply);
+else {
+ for my $path (@status_paths) {
+ if (not -e $build->config_data('status_file')) {
+ $build->config_data(status_file => $path);
+ }
+ }
+ if (not -e $build->config_data('status_file')) {
+ my $reply = $build->prompt('Enter location of Icinga status.dat',
+ $build->config_data('status_file'));
+ $build->config_data(status_file => $reply);
+ }
}
if ($build->args('icli-command-file')) {
$build->config_data(command_file => $build->args('icli-command-file'));
}
-elsif (not -e $build->config_data('command_file')) {
- my $reply = $build->prompt('Enter location of Icinga command pipe',
- $build->config_data('command_file'));
- $build->config_data(command_file => $reply);
+else {
+ for my $path (@command_paths) {
+ if (not -e $build->config_data('command_file')) {
+ $build->config_data(command_file => $path);
+ }
+ }
+ if (not -e $build->config_data('command_file')) {
+ my $reply = $build->prompt('Enter location of Icinga command pipe',
+ $build->config_data('command_file'));
+ $build->config_data(command_file => $reply);
+ }
}
$build->create_build_script();