-
Notifications
You must be signed in to change notification settings - Fork 19
/
config.php
80 lines (67 loc) · 1.93 KB
/
config.php
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
<?php
## Custom values
#
# Add any custom values here. If a value is empty, the default value defined
# below is used.
$custom = array(
'targetdir' => '',
'apacheconfdir' => '',
'apacheconffile' => '',
'etc_conf' => '',
'htpasswd_file' => '',
# See config/vshell.conf for explanations of each value
'vshell_baseurl' => '',
'nagios_coreurl' => '',
'resultlimit' => '',
'lang' => '',
'TTL' => '',
);
## Default values
#
# Do not edit these defaults
$defaults = array();
$defaults['debian'] = array(
'targetdir' => '/usr/local/vshell',
'apacheconfdir' => '/etc/apache2/conf.d',
'apacheconffile' => 'vshell.conf',
'etc_conf' => 'vshell.conf',
'htpasswd_file' => '/etc/nagios3/htpasswd.users',
'vshell_baseurl' => 'vshell',
'nagios_coreurl' => 'nagios3',
'resultlimit' => '100',
'lang' => 'en_GB',
'TTL' => '90',
);
$defaults['redhat'] = array(
'targetdir' => '/usr/local/vshell',
'apacheconfdir' => '/etc/httpd/conf.d',
'apacheconffile' => 'vshell.conf',
'etc_conf' => 'vshell.conf',
'htpasswd_file' => '/etc/nagios/passwd',
'vshell_baseurl' => 'vshell',
'nagios_coreurl' => 'nagios',
'resultlimit' => '100',
'lang' => 'en_GB',
'TTL' => '90',
);
## Create definitions
#
# Determine the OS family, merge custom values with defaults,
# and create PHP definitions for each key.
$default_values = $defaults[get_os_family()];
$custom_values = array_filter($custom);
$config = array_merge($default_values, $custom_values);
create_definitions($config);
## Helper functions
function get_os_family(){
# Simple check, default to redhat
$output = system('test -s /etc/debian_version && echo "Debian"');
return ($output == 'Debian') ? 'debian' : 'redhat';
}
function create_definitions($values){
foreach($values as $key => $value){
$key = strtoupper($key);
define($key, $value);
}
}
// End of file install-config.php