forked from sni/Thruk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·212 lines (176 loc) · 8.27 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long qw//;
eval "use inc::Module::Install";
if($@ && !-e 'Makefile') {
print STDERR "Module::Install is required to build Thruk from source.\n\n";
print STDERR $@;
exit 1;
}
alarm(180);
my $options = {
'prefix' => '/usr/local',
'htmlurl' => '/thruk',
'thruk-user' => `id -un`,
'thruk-group' => `id -gn`,
'httpd-conf' => '',
'logrotatedir' => '',
'nocompress' => 0,
'quiet' => 0,
};
Getopt::Long::Configure('no_ignore_case');
Getopt::Long::Configure('bundling');
Getopt::Long::Configure('pass_through');
Getopt::Long::GetOptions (
"h|help" => \$options->{'help'},
"v|verbose" => sub { $options->{'verbose'}++ },
"prefix=s" => \$options->{'prefix'},
"exec-prefix=s" => \$options->{'eprefix'},
"bindir=s" => \$options->{'bindir'},
"libdir=s" => \$options->{'libdir'},
"sysconfdir=s" => \$options->{'sysconfdir'},
"localstatedir=s" => \$options->{'localstatedir'},
"datadir=s" => \$options->{'datadir'},
"mandir=s" => \$options->{'mandir'},
"with-tempdir=s" => \$options->{'tmpdir'},
"with-initdir=s" => \$options->{'initdir'},
"with-logrotatedir=s" => \$options->{'logrotatedir'},
"with-logdir=s" => \$options->{'logdir'},
"with-htmlurl=s" => \$options->{'htmlurl'},
"with-httpd-conf=s" => \$options->{'httpd-conf'},
"with-checkresultdir=s" => \$options->{'with-checkresultdir'},
"with-thruk-user=s" => \$options->{'thruk-user'},
"with-thruk-group=s" => \$options->{'thruk-group'},
"with-thruk-libs=s" => \$options->{'thruk-libs'},
"with-thruk-tempdir=s" => \$options->{'thruk-tempdir'},
"with-thruk-vardir=s" => \$options->{'thruk-vardir'},
"with-thruk-logdir=s" => \$options->{'thruk-logdir'},
"without-compress" => \$options->{'nocompress'},
"quiet|q" => \$options->{'quiet'},
) or warn "error in options";
if($options->{'help'}) {
require Pod::Usage;
Pod::Usage::pod2usage( { -verbose => 2, -exit => 3 } );
}
$options->{'initdir'} = $options->{'initdir'} || $options->{'prefix'}.'/etc/init.d';
$options->{'logdir'} = $options->{'logdir'} || $options->{'prefix'}.'/var/log/thruk';
$options->{'thruk-libs'} = $options->{'thruk-libs'} || $options->{'prefix'}.'/lib/thruk/perl5';
$options->{'checkresultdir'} = $options->{'checkresultdir'} || $options->{'prefix'}.'/var/cache/naemon/checkresults';
$options->{'eprefix'} = $options->{'prefix'} unless $options->{'eprefix'};
$options->{'bindir'} = $options->{'prefix'}.'/bin' unless $options->{'bindir'};
$options->{'sysconfdir'} = $options->{'prefix'}.'/etc' unless $options->{'sysconfdir'};
$options->{'tmpdir'} = $options->{'prefix'}.'/tmp' unless $options->{'tmpdir'};
$options->{'localstatedir'} = $options->{'prefix'}.'/var' unless $options->{'localstatedir'};
$options->{'libdir'} = $options->{'prefix'}.'/lib' unless $options->{'libdir'};
$options->{'datadir'} = $options->{'prefix'}.'/share' unless $options->{'datadir'};
$options->{'mandir'} = $options->{'prefix'}.'/man' unless $options->{'mandir'};
$options->{'tmpdir'} = $options->{'thruk-tempdir'} if $options->{'thruk-tempdir'};
$options->{'localstatedir'} = $options->{'thruk-vardir'} if $options->{'thruk-vardir'};
$options->{'logdir'} = $options->{'thruk-logdir'} if $options->{'thruk-logdir'};
chomp($options->{'thruk-user'});
chomp($options->{'thruk-group'});
$options->{'htmlurl'} =~ s|/+$||mx;
$options->{'htmlurl'} =~ s|^/+||mx;
$options->{'htmlurl'} = '/'.$options->{'htmlurl'};
$options->{'compress'} = $options->{'nocompress'} ? 'disabled' : 'enabled';
open(my $fh, '>', 'script/append.make.options') or die("cannot write to: append.make.options:".$!);
print $fh <<EOT;
### THRUK
PREFIX = $options->{'prefix'}
EPREFIX = $options->{'eprefix'}
BINDIR = $options->{'bindir'}
SYSCONFDIR = $options->{'sysconfdir'}
LIBDIR = $options->{'libdir'}
TMPDIR = $options->{'tmpdir'}
LOCALSTATEDIR = $options->{'localstatedir'}
DATADIR = $options->{'datadir'}
MANDIR = $options->{'mandir'}
INITDIR = $options->{'initdir'}
LOGROTATEDIR = $options->{'logrotatedir'}
LOGDIR = $options->{'logdir'}
HTMLURL = $options->{'htmlurl'}
HTTPDCONF = $options->{'httpd-conf'}
THRUKUSER = $options->{'thruk-user'}
THRUKGROUP = $options->{'thruk-group'}
THRUKLIBS = $options->{'thruk-libs'}
CHECKRESULTDIR = $options->{'checkresultdir'}
THRUKCOMPRESS = $options->{'compress'}
EOT
close($fh);
my $out = `yes n | $^X Makefile.PL 2>&1`;
if(!-e "Makefile") {
print "configure failed:\n\n";
print $out;
exit 1;
}
exit if $options->{'quiet'};
$options->{'httpd-conf'} = '** not installed **' unless $options->{'httpd-conf'};
$options->{'logrotatedir'} = '** not installed **' unless $options->{'logrotatedir'};
print <<EOT;
*************************************
* THRUK - configuration
*************************************
eprefix = $options->{'eprefix'}
bindir = $options->{'bindir'}
sysconfdir = $options->{'sysconfdir'}
libdir = $options->{'libdir'}
tmpdir = $options->{'tmpdir'}
localstatedir = $options->{'localstatedir'}
datadir = $options->{'datadir'}
mandir = $options->{'mandir'}
initdir = $options->{'initdir'}
logrotatedir = $options->{'logrotatedir'}
logdir = $options->{'logdir'}
htmlurl = $options->{'htmlurl'}
httpd-conf = $options->{'httpd-conf'}
thruk-user = $options->{'thruk-user'}
thruk-group = $options->{'thruk-group'}
thruk-libs = $options->{'thruk-libs'}
checkresultdir = $options->{'checkresultdir'}
css/js compression = $options->{'compress'}
now run
perl Makefile.PL
make
make install
to install thruk with these settings.
EOT
exit;
1;
__END__
##############################################
=head1 SYNOPSIS
Usage: configure [options]
Options:
-h, --help Show this help message and exit
-v, --verbose Print verbose output
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local/' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--datadir=DIR read-only architecture-independent data [PREFIX/share]
--mandir=DIR man documentation [DATADIR/man]
Optional Settings:
--with-htmlurl=<local-url> sets URL for public html [/thruk]
--with-tempdir sets the temp folder [PREFIX/tmp]
--with-initdir sets the folder for rc scripts
--with-httpd-conf sets path to Apache conf.d directory
--with-logrotatedir sets path to logrotates.d directory
--with-logdir sets path to log files [PREFIX/var/log/thruk]
--with-thruk-libs sets path to thruk libs directory [PREFIX/lib/thruk/perl5]
--with-thruk-user sets user name to run thruk [thruk]
--with-thruk-group sets group name to run thruk [thruk]
--with-checkresultdir sets path to Naemon/Nagios/Icinga/Shinken checkresult directory [PREFIX/var/cache/naemon/checkresults]
--without-compress skip compression of css and javascript files which requires yui-compressor
=cut