cloud-mu 3.6.10 → 3.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Berksfile +2 -3
- data/Berksfile.lock +11 -14
- data/bin/mu-aws-setup +16 -4
- data/bin/mu-configure +2 -1
- data/cloud-mu.gemspec +2 -2
- data/cookbooks/mu-firewall/Berksfile +1 -1
- data/cookbooks/mu-firewall/attributes/default.rb +2 -2
- data/cookbooks/mu-firewall/metadata.rb +3 -3
- data/cookbooks/mu-firewall/recipes/default.rb +11 -2
- data/cookbooks/mu-master/Berksfile +1 -1
- data/cookbooks/mu-master/attributes/default.rb +14 -1
- data/cookbooks/mu-master/files/default/389ds-perl/ASDialogs.pm +173 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminMigration.pm +569 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminServer.pm +952 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminUtil.pm +983 -0
- data/cookbooks/mu-master/files/default/389ds-perl/ConfigDSDialogs.pm +449 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSCreate.pm +1551 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSDialogs.pm +233 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSMigration.pm +1175 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdate.pm +534 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdateDialogs.pm +152 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUtil.pm +1710 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Dialog.pm +249 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DialogManager.pm +212 -0
- data/cookbooks/mu-master/files/default/389ds-perl/FileConn.pm +461 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Inf.pm +268 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Migration.pm +327 -0
- data/cookbooks/mu-master/files/default/389ds-perl/RegDSDialogs.pm +94 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Resource.pm +137 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Setup.pm +240 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupDialogs.pm +243 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupLog.pm +82 -0
- data/cookbooks/mu-master/files/default/setCertName.ldif +4 -0
- data/cookbooks/mu-master/libraries/mu.rb +2 -2
- data/cookbooks/mu-master/metadata.rb +1 -1
- data/cookbooks/mu-master/recipes/389ds.rb +71 -32
- data/cookbooks/mu-master/recipes/basepackages.rb +5 -0
- data/cookbooks/mu-master/recipes/default.rb +16 -5
- data/cookbooks/mu-master/recipes/init.rb +36 -3
- data/cookbooks/mu-master/recipes/ssl-certs.rb +6 -0
- data/cookbooks/mu-master/recipes/sssd.rb +85 -62
- data/cookbooks/mu-master/recipes/update_nagios_only.rb +7 -1
- data/cookbooks/mu-master/templates/default/389-directory-setup.inf.erb +11 -26
- data/cookbooks/mu-master/templates/default/sssd.conf.erb +18 -8
- data/cookbooks/mu-tools/files/default/Mu_CA.pem +33 -0
- data/cookbooks/mu-tools/metadata.rb +0 -1
- data/cookbooks/mu-tools/recipes/set_local_fw.rb +7 -1
- data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +5 -1
- data/cookbooks/nagios/CHANGELOG.md +679 -0
- data/cookbooks/nagios/LICENSE +201 -0
- data/cookbooks/nagios/README.md +340 -0
- data/cookbooks/nagios/attributes/config.rb +163 -0
- data/cookbooks/nagios/attributes/default.rb +204 -0
- data/cookbooks/nagios/libraries/base.rb +311 -0
- data/cookbooks/nagios/libraries/command.rb +68 -0
- data/cookbooks/nagios/libraries/contact.rb +229 -0
- data/cookbooks/nagios/libraries/contactgroup.rb +111 -0
- data/cookbooks/{firewall/recipes/disable_firewall.rb → nagios/libraries/custom_option.rb} +20 -7
- data/cookbooks/nagios/libraries/data_bag_helper.rb +23 -0
- data/cookbooks/nagios/libraries/default.rb +90 -0
- data/cookbooks/nagios/libraries/helpers.rb +229 -0
- data/cookbooks/nagios/libraries/host.rb +410 -0
- data/cookbooks/nagios/libraries/hostdependency.rb +178 -0
- data/cookbooks/nagios/libraries/hostescalation.rb +170 -0
- data/cookbooks/nagios/libraries/hostgroup.rb +117 -0
- data/cookbooks/nagios/libraries/nagios.rb +277 -0
- data/cookbooks/nagios/libraries/resource.rb +59 -0
- data/cookbooks/nagios/libraries/service.rb +449 -0
- data/cookbooks/nagios/libraries/servicedependency.rb +213 -0
- data/cookbooks/nagios/libraries/serviceescalation.rb +193 -0
- data/cookbooks/nagios/libraries/servicegroup.rb +142 -0
- data/cookbooks/nagios/libraries/timeperiod.rb +159 -0
- data/cookbooks/nagios/libraries/users_helper.rb +54 -0
- data/cookbooks/nagios/metadata.json +44 -0
- data/cookbooks/nagios/metadata.rb +22 -0
- data/cookbooks/nagios/recipes/_load_databag_config.rb +153 -0
- data/cookbooks/nagios/recipes/_load_default_config.rb +241 -0
- data/cookbooks/nagios/recipes/apache.rb +114 -0
- data/cookbooks/nagios/recipes/default.rb +41 -0
- data/cookbooks/nagios/recipes/nginx.rb +114 -0
- data/cookbooks/nagios/recipes/pagerduty.rb +95 -0
- data/cookbooks/nagios/recipes/server.rb +182 -0
- data/cookbooks/nagios/recipes/server_package.rb +85 -0
- data/cookbooks/nagios/recipes/server_source.rb +137 -0
- data/cookbooks/nagios/resources/command.rb +34 -0
- data/cookbooks/nagios/resources/conf.rb +52 -0
- data/cookbooks/nagios/resources/contact.rb +34 -0
- data/cookbooks/nagios/resources/contactgroup.rb +35 -0
- data/cookbooks/nagios/resources/host.rb +35 -0
- data/cookbooks/nagios/resources/hostdependency.rb +35 -0
- data/cookbooks/nagios/resources/hostescalation.rb +36 -0
- data/cookbooks/nagios/resources/hostgroup.rb +35 -0
- data/cookbooks/nagios/resources/resource.rb +34 -0
- data/cookbooks/nagios/resources/service.rb +35 -0
- data/cookbooks/nagios/resources/servicedependency.rb +35 -0
- data/cookbooks/nagios/resources/serviceescalation.rb +35 -0
- data/cookbooks/nagios/resources/servicegroup.rb +35 -0
- data/cookbooks/nagios/resources/timeperiod.rb +35 -0
- data/cookbooks/nagios/templates/apache2.conf.erb +102 -0
- data/cookbooks/nagios/templates/cgi.cfg.erb +266 -0
- data/cookbooks/nagios/templates/commands.cfg.erb +13 -0
- data/cookbooks/nagios/templates/contacts.cfg.erb +37 -0
- data/cookbooks/nagios/templates/hostgroups.cfg.erb +25 -0
- data/cookbooks/nagios/templates/hosts.cfg.erb +15 -0
- data/cookbooks/nagios/templates/htpasswd.users.erb +6 -0
- data/cookbooks/nagios/templates/nagios.cfg.erb +22 -0
- data/cookbooks/nagios/templates/nginx.conf.erb +80 -0
- data/cookbooks/nagios/templates/pagerduty.cgi.erb +185 -0
- data/cookbooks/nagios/templates/resource.cfg.erb +27 -0
- data/cookbooks/nagios/templates/servicedependencies.cfg.erb +15 -0
- data/cookbooks/nagios/templates/servicegroups.cfg.erb +14 -0
- data/cookbooks/nagios/templates/services.cfg.erb +14 -0
- data/cookbooks/nagios/templates/spawn-fcgi.erb +10 -0
- data/cookbooks/nagios/templates/templates.cfg.erb +31 -0
- data/cookbooks/nagios/templates/timeperiods.cfg.erb +13 -0
- data/extras/platform_berksfile_base +3 -3
- data/extras/python_rpm/build.sh +4 -4
- data/extras/python_rpm/muthon.spec +2 -4
- data/extras/vault_tools/export_vaults.sh +11 -1
- data/install/installer +1 -1
- data/modules/mu/kittens.rb +27523 -0
- data/modules/mu/master/ldap.rb +48 -31
- data/modules/mu/master.rb +69 -0
- data/modules/mu/mu.yaml.rb +351 -0
- data/modules/mu/providers/aws/firewall_rule.rb +3 -1
- data/modules/mu/providers/aws.rb +11 -5
- data/modules/mu.rb +5 -4
- metadata +99 -48
- data/cookbooks/firewall/CHANGELOG.md +0 -488
- data/cookbooks/firewall/LICENSE +0 -202
- data/cookbooks/firewall/README.md +0 -366
- data/cookbooks/firewall/TODO.md +0 -6
- data/cookbooks/firewall/attributes/default.rb +0 -5
- data/cookbooks/firewall/attributes/firewalld.rb +0 -8
- data/cookbooks/firewall/attributes/iptables.rb +0 -17
- data/cookbooks/firewall/attributes/ufw.rb +0 -12
- data/cookbooks/firewall/attributes/windows.rb +0 -8
- data/cookbooks/firewall/libraries/helpers.rb +0 -105
- data/cookbooks/firewall/libraries/helpers_firewalld.rb +0 -116
- data/cookbooks/firewall/libraries/helpers_firewalld_dbus.rb +0 -72
- data/cookbooks/firewall/libraries/helpers_iptables.rb +0 -112
- data/cookbooks/firewall/libraries/helpers_nftables.rb +0 -170
- data/cookbooks/firewall/libraries/helpers_ufw.rb +0 -142
- data/cookbooks/firewall/libraries/helpers_windows.rb +0 -129
- data/cookbooks/firewall/libraries/provider_firewall_firewalld.rb +0 -179
- data/cookbooks/firewall/libraries/provider_firewall_iptables.rb +0 -171
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu1404.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_rule.rb +0 -34
- data/cookbooks/firewall/libraries/provider_firewall_ufw.rb +0 -138
- data/cookbooks/firewall/libraries/provider_firewall_windows.rb +0 -126
- data/cookbooks/firewall/libraries/resource_firewall.rb +0 -26
- data/cookbooks/firewall/libraries/resource_firewall_rule.rb +0 -52
- data/cookbooks/firewall/metadata.json +0 -40
- data/cookbooks/firewall/metadata.rb +0 -15
- data/cookbooks/firewall/recipes/default.rb +0 -76
- data/cookbooks/firewall/recipes/firewalld.rb +0 -87
- data/cookbooks/firewall/resources/firewalld.rb +0 -28
- data/cookbooks/firewall/resources/firewalld_config.rb +0 -39
- data/cookbooks/firewall/resources/firewalld_helpers.rb +0 -106
- data/cookbooks/firewall/resources/firewalld_icmptype.rb +0 -88
- data/cookbooks/firewall/resources/firewalld_ipset.rb +0 -104
- data/cookbooks/firewall/resources/firewalld_policy.rb +0 -115
- data/cookbooks/firewall/resources/firewalld_service.rb +0 -98
- data/cookbooks/firewall/resources/firewalld_zone.rb +0 -118
- data/cookbooks/firewall/resources/nftables.rb +0 -71
- data/cookbooks/firewall/resources/nftables_rule.rb +0 -113
- data/cookbooks/firewall/templates/default/ufw/default.erb +0 -13
- /data/cookbooks/{firewall → nagios}/chefignore +0 -0
- /data/cookbooks/{firewall → nagios}/renovate.json +0 -0
@@ -0,0 +1,240 @@
|
|
1
|
+
# BEGIN COPYRIGHT BLOCK
|
2
|
+
# Copyright (C) 2007 Red Hat, Inc.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# License: GPL (version 3 or any later version).
|
6
|
+
# See LICENSE for details.
|
7
|
+
# END COPYRIGHT BLOCK
|
8
|
+
#
|
9
|
+
|
10
|
+
###########################
|
11
|
+
#
|
12
|
+
# This perl module provides a way to set up a new installation after
|
13
|
+
# the binaries have already been extracted. This is typically after
|
14
|
+
# using native packaging support to install the package e.g. RPM,
|
15
|
+
# pkgadd, depot, etc. This script will show the license, readme,
|
16
|
+
# dsktune, then run the usual setup pre and post installers.
|
17
|
+
#
|
18
|
+
##########################
|
19
|
+
|
20
|
+
package Setup;
|
21
|
+
use Exporter ();
|
22
|
+
@ISA = qw(Exporter);
|
23
|
+
@EXPORT = qw($SILENT $EXPRESS $TYPICAL $CUSTOM);
|
24
|
+
@EXPORT_OK = qw($SILENT $EXPRESS $TYPICAL $CUSTOM);
|
25
|
+
|
26
|
+
# hostname
|
27
|
+
use Sys::Hostname; # hostname()
|
28
|
+
|
29
|
+
# load perldap
|
30
|
+
use Mozilla::LDAP::Conn;
|
31
|
+
use Mozilla::LDAP::Utils qw(normalizeDN);
|
32
|
+
use Mozilla::LDAP::API qw(ldap_explode_dn);
|
33
|
+
use Mozilla::LDAP::LDIF;
|
34
|
+
|
35
|
+
use Getopt::Long;
|
36
|
+
|
37
|
+
use SetupLog;
|
38
|
+
use DSUtil;
|
39
|
+
use Inf;
|
40
|
+
|
41
|
+
use strict;
|
42
|
+
use vars qw($EXPRESS $TYPICAL $CUSTOM $SILENT);
|
43
|
+
|
44
|
+
# the setup types
|
45
|
+
$EXPRESS = 1;
|
46
|
+
$TYPICAL = 2;
|
47
|
+
$CUSTOM = 3;
|
48
|
+
$SILENT = 4;
|
49
|
+
|
50
|
+
# process command line options
|
51
|
+
Getopt::Long::Configure(qw(bundling)); # bundling allows -ddddd
|
52
|
+
|
53
|
+
sub VersionMessage {
|
54
|
+
print "389 Directory Server Setup Program Version 1.3.11.12\n";
|
55
|
+
}
|
56
|
+
|
57
|
+
sub HelpMessage {
|
58
|
+
print <<EOF;
|
59
|
+
Usage: $0 [--options] -- [args]
|
60
|
+
options:
|
61
|
+
--help This message
|
62
|
+
--version Print the version and exit
|
63
|
+
--debug Turn on debugging
|
64
|
+
--silent Use silent setup - no user input
|
65
|
+
--file=name Use the file 'name' in .inf format to supply the default answers
|
66
|
+
--keepcache Do not delete the temporary .inf file generated by this program
|
67
|
+
--logfile Log setup messages to this file - otherwise, a temp file will be used
|
68
|
+
--update Update an existing installation (e.g. after upgrading packages)
|
69
|
+
--continue (update only) keep going despite errors (also --force)
|
70
|
+
For all options, you can also use the short name e.g. -h, -d, etc. For the -d argument,
|
71
|
+
specifying it more than once will increase the debug level e.g. -ddddd
|
72
|
+
|
73
|
+
args:
|
74
|
+
You can supply default .inf data in this format:
|
75
|
+
section.param=value
|
76
|
+
e.g.
|
77
|
+
General.FullMachineName=foo.example.com
|
78
|
+
or
|
79
|
+
"slapd.Suffix=dc=example,dc=com"
|
80
|
+
Values passed in this manner will override values in an .inf file given with the -f argument.
|
81
|
+
EOF
|
82
|
+
}
|
83
|
+
|
84
|
+
sub new {
|
85
|
+
my $type = shift;
|
86
|
+
my $self = {};
|
87
|
+
$self = bless $self, $type;
|
88
|
+
$self->init(@_);
|
89
|
+
return $self;
|
90
|
+
}
|
91
|
+
|
92
|
+
sub init {
|
93
|
+
my $self = shift;
|
94
|
+
$self->{res} = shift;
|
95
|
+
my ($silent, $inffile, $keep, $preonly, $logfile, $update, $force);
|
96
|
+
|
97
|
+
GetOptions('help|h|?' => sub { VersionMessage(); HelpMessage(); exit 0 },
|
98
|
+
'version|v' => sub { VersionMessage(); exit 0 },
|
99
|
+
'debug|d+' => \$DSUtil::debuglevel,
|
100
|
+
'silent|s' => \$silent,
|
101
|
+
'file|f=s' => \$inffile,
|
102
|
+
'keepcache|k' => \$keep,
|
103
|
+
'preonly|p' => \$preonly,
|
104
|
+
'logfile|l=s' => \$logfile,
|
105
|
+
'update|u' => \$update,
|
106
|
+
'continue|force|c' => \$force
|
107
|
+
);
|
108
|
+
|
109
|
+
$self->{silent} = $silent;
|
110
|
+
$self->{keep} = $keep;
|
111
|
+
$self->{preonly} = $preonly;
|
112
|
+
$self->{update} = $update;
|
113
|
+
$self->{force} = $force;
|
114
|
+
$self->{logfile} = $logfile;
|
115
|
+
$self->{log} = new SetupLog($self->{logfile});
|
116
|
+
DSUtil::setDebugLog($self->{log});
|
117
|
+
# if user supplied inf file, use that to initialize
|
118
|
+
if (defined($inffile)) {
|
119
|
+
$self->{inf} = new Inf($inffile);
|
120
|
+
if(!$self->{inf}){
|
121
|
+
$self->doExit(1);
|
122
|
+
}
|
123
|
+
} else {
|
124
|
+
$self->{inf} = new Inf;
|
125
|
+
}
|
126
|
+
|
127
|
+
# see if user passed in default inf values - also, command line
|
128
|
+
# arguments override those passed in via an inf file - this
|
129
|
+
# allows the reuse of .inf files with some parameters overridden
|
130
|
+
if (!$self->{inf}->updateFromArgs(@ARGV)) {
|
131
|
+
HelpMessage();
|
132
|
+
exit 1;
|
133
|
+
}
|
134
|
+
|
135
|
+
# this is the base config directory - the directory containing
|
136
|
+
# the slapd-instance instance specific config directories
|
137
|
+
$self->{configdir} = $ENV{DS_CONFIG_DIR} || "/etc/dirsrv";
|
138
|
+
}
|
139
|
+
|
140
|
+
# log only goes the the logfile
|
141
|
+
sub log {
|
142
|
+
my $self = shift;
|
143
|
+
my $level = shift;
|
144
|
+
$self->{log}->logMessage($level, "Setup", @_);
|
145
|
+
}
|
146
|
+
|
147
|
+
# msg does to the screen and optionally to the log file
|
148
|
+
# if you use msg like this:
|
149
|
+
# msg(0, "some message")
|
150
|
+
# it will go only to the screen
|
151
|
+
# if you use msg like this:
|
152
|
+
# msg($WARN, "some message")
|
153
|
+
# it will go to the screen and to the log at the $WARN level
|
154
|
+
# all messages are localizable - you must define a resource key
|
155
|
+
# the first string passed to this method is a resource key
|
156
|
+
# additional strings are used as "arguments" to that resource key
|
157
|
+
# if you want to print un-localizable messages, use debug or write
|
158
|
+
# directly to the log or screen
|
159
|
+
sub msg {
|
160
|
+
my $self = shift;
|
161
|
+
my $level = shift;
|
162
|
+
my @ary = @_;
|
163
|
+
if (!$level && @ary) {
|
164
|
+
# e.g. msg(0, "string") - no logging
|
165
|
+
} elsif ($level and @ary and grep {/^$level$/} $self->{log}->levels()) {
|
166
|
+
# e.g. msg($WARN, "string") - print and log
|
167
|
+
} else {
|
168
|
+
# log at default INFO level
|
169
|
+
unshift @ary, $level;
|
170
|
+
$level = $INFO;
|
171
|
+
}
|
172
|
+
# @text is an array of strings for one message or
|
173
|
+
# an array of array refs, each one is a message
|
174
|
+
while (@ary) {
|
175
|
+
my @text = shift @ary;
|
176
|
+
|
177
|
+
last if (!@text or !$text[0]);
|
178
|
+
|
179
|
+
# element is an array ref - just pass to getText
|
180
|
+
# else is a list of strings
|
181
|
+
# NOTE: this will NOT work if ary contains
|
182
|
+
# consecutive simple string errors not separated
|
183
|
+
# by an array ref e.g. this will work
|
184
|
+
# ARRAY, 'errkey', arg, arg, ARRAY
|
185
|
+
# this will not work
|
186
|
+
# ARRAY, 'errkey', arg, 'errkey2', arg2, ARRAY
|
187
|
+
while (@ary and !ref($ary[0])) {
|
188
|
+
push @text, shift @ary;
|
189
|
+
}
|
190
|
+
my $string = $self->{res}->getText(@text);
|
191
|
+
if ($level) {
|
192
|
+
$self->log($level, $string);
|
193
|
+
}
|
194
|
+
print $string;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
sub doExit {
|
199
|
+
my $self = shift;
|
200
|
+
my $code = shift;
|
201
|
+
if (!defined($code)) {
|
202
|
+
$code = 1;
|
203
|
+
}
|
204
|
+
|
205
|
+
if ($code) {
|
206
|
+
$self->msg($FATAL, 'setup_exiting', $self->{log}->{filename});
|
207
|
+
} else {
|
208
|
+
$self->msg($SUCCESS, 'setup_exiting', $self->{log}->{filename});
|
209
|
+
}
|
210
|
+
exit $code;
|
211
|
+
}
|
212
|
+
|
213
|
+
# get a list of the directory servers in configdir
|
214
|
+
sub getDirServers {
|
215
|
+
my $self = shift;
|
216
|
+
if (!$self->{dirservers}) {
|
217
|
+
$self->{dirservers} = [];
|
218
|
+
for my $dir (glob("$self->{configdir}/slapd-*")) {
|
219
|
+
next if ($dir =~ /\.removed$/); # skip removed instances
|
220
|
+
if (-d $dir) {
|
221
|
+
$dir =~ s,$self->{configdir}/,,; # strip off dir part
|
222
|
+
push @{$self->{dirservers}}, $dir;
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
return @{$self->{dirservers}};
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
#############################################################################
|
231
|
+
# Mandatory TRUE return value.
|
232
|
+
#
|
233
|
+
1;
|
234
|
+
|
235
|
+
# emacs settings
|
236
|
+
# Local Variables:
|
237
|
+
# mode:perl
|
238
|
+
# indent-tabs-mode: nil
|
239
|
+
# tab-width: 4
|
240
|
+
# End:
|
@@ -0,0 +1,243 @@
|
|
1
|
+
# BEGIN COPYRIGHT BLOCK
|
2
|
+
# Copyright (C) 2007 Red Hat, Inc.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# License: GPL (version 3 or any later version).
|
6
|
+
# See LICENSE for details.
|
7
|
+
# END COPYRIGHT BLOCK
|
8
|
+
#
|
9
|
+
|
10
|
+
package SetupDialogs;
|
11
|
+
|
12
|
+
use strict;
|
13
|
+
|
14
|
+
use DialogManager;
|
15
|
+
use Setup;
|
16
|
+
use Dialog;
|
17
|
+
use Sys::Hostname;
|
18
|
+
use DSUtil;
|
19
|
+
|
20
|
+
my $welcome = new DialogYesNo (
|
21
|
+
$EXPRESS,
|
22
|
+
['dialog_welcome_text', 'brand', 'brand'],
|
23
|
+
1,
|
24
|
+
sub {
|
25
|
+
my $self = shift;
|
26
|
+
my $ans = shift;
|
27
|
+
my $res = $self->handleResponse($ans);
|
28
|
+
if ($res == $DialogManager::NEXT) {
|
29
|
+
$res = $DialogManager::ERR if (!$self->isYes());
|
30
|
+
}
|
31
|
+
return $res;
|
32
|
+
},
|
33
|
+
['dialog_welcome_prompt'],
|
34
|
+
);
|
35
|
+
|
36
|
+
my $dsktune = new DialogYesNo (
|
37
|
+
$EXPRESS,
|
38
|
+
'dialog_dsktune_text',
|
39
|
+
0,
|
40
|
+
sub {
|
41
|
+
my $self = shift;
|
42
|
+
my $ans = shift;
|
43
|
+
my $res = $self->handleResponse($ans);
|
44
|
+
if ($res == $DialogManager::NEXT) {
|
45
|
+
$res = $DialogManager::ERR if (!$self->isYes());
|
46
|
+
}
|
47
|
+
return $res;
|
48
|
+
},
|
49
|
+
['dialog_dsktune_prompt']
|
50
|
+
);
|
51
|
+
|
52
|
+
$? = 0; # clear error condition
|
53
|
+
my $dsktune_output = `/usr/bin/dsktune`;
|
54
|
+
my $dsktune_result = $?;
|
55
|
+
$dsktune->{defaultIsYes} = $dsktune_result ? 0 : 1;
|
56
|
+
$dsktune->{text} = [$dsktune->{text}, $dsktune_output];
|
57
|
+
|
58
|
+
my $setuptype = new Dialog (
|
59
|
+
$EXPRESS,
|
60
|
+
'dialog_setuptype_text',
|
61
|
+
sub {
|
62
|
+
my $self = shift;
|
63
|
+
return $self->{manager}->getType();
|
64
|
+
},
|
65
|
+
sub {
|
66
|
+
my $self = shift;
|
67
|
+
my $ans = shift;
|
68
|
+
my $res = $DialogManager::SAME;
|
69
|
+
if ($ans < $EXPRESS or $ans > $CUSTOM) {
|
70
|
+
$self->{manager}->alert("dialog_setuptype_error");
|
71
|
+
} else {
|
72
|
+
$res = $DialogManager::NEXT;
|
73
|
+
$self->{manager}->setType($ans);
|
74
|
+
}
|
75
|
+
return $res;
|
76
|
+
},
|
77
|
+
['dialog_setuptype_prompt']
|
78
|
+
);
|
79
|
+
|
80
|
+
my $hostdlg = new Dialog (
|
81
|
+
$TYPICAL,
|
82
|
+
'dialog_hostname_text',
|
83
|
+
sub {
|
84
|
+
my $self = shift;
|
85
|
+
return $self->{manager}->{inf}->{General}->{FullMachineName} ||
|
86
|
+
hostname();
|
87
|
+
},
|
88
|
+
sub {
|
89
|
+
my $self = shift;
|
90
|
+
my $ans = shift;
|
91
|
+
my $res = $DialogManager::NEXT;
|
92
|
+
my $str;
|
93
|
+
if ($str = checkHostname($ans, $self->{manager}->{res})) {
|
94
|
+
my $promptary = ["dialog_hostname_warning", $str, $ans];
|
95
|
+
my $yesorno = $self->{manager}->showPrompt($promptary, $self->{manager}->getText("no"));
|
96
|
+
$res = DialogYesNo::handleResponse($self, $yesorno);
|
97
|
+
if ($res == $DialogManager::NEXT) {
|
98
|
+
$res = $DialogManager::SAME if (!DialogYesNo::isYes($self));
|
99
|
+
}
|
100
|
+
}
|
101
|
+
$self->{manager}->{inf}->{General}->{FullMachineName} = $ans;
|
102
|
+
return $res;
|
103
|
+
},
|
104
|
+
['dialog_hostname_prompt']
|
105
|
+
);
|
106
|
+
|
107
|
+
# must verify that the user or uid specified by the user to run the server as
|
108
|
+
# is a valid uid
|
109
|
+
sub verifyUserChoice {
|
110
|
+
my $self = shift;
|
111
|
+
my $ans = shift;
|
112
|
+
my $res = $DialogManager::NEXT;
|
113
|
+
# convert numeric uid to string
|
114
|
+
my $strans = $ans;
|
115
|
+
if ($ans =~ /^\d/) { # numeric - convert to string
|
116
|
+
$strans = getpwuid $ans;
|
117
|
+
if (!$strans) {
|
118
|
+
$self->{manager}->alert("dialog_ssuser_error", $ans);
|
119
|
+
return $DialogManager::SAME;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
if ($> != 0) { # if not root, the user must be our uid
|
123
|
+
my $username = getLogin;
|
124
|
+
if ($strans ne $username) {
|
125
|
+
$self->{manager}->alert("dialog_ssuser_must_be_same", $username);
|
126
|
+
return $DialogManager::SAME;
|
127
|
+
}
|
128
|
+
} else { # user is root - verify id
|
129
|
+
my $nuid = getpwnam $strans;
|
130
|
+
if (!defined($nuid)) {
|
131
|
+
$self->{manager}->alert("dialog_ssuser_error", $ans);
|
132
|
+
return $DialogManager::SAME;
|
133
|
+
}
|
134
|
+
if (!$nuid) {
|
135
|
+
$self->{manager}->alert("dialog_ssuser_root_warning");
|
136
|
+
}
|
137
|
+
}
|
138
|
+
$self->{manager}->{inf}->{General}->{SuiteSpotUserID} = $ans;
|
139
|
+
return $res;
|
140
|
+
}
|
141
|
+
|
142
|
+
# must verify that the given group is one of the groups the given user
|
143
|
+
# belongs to
|
144
|
+
sub verifyGroupChoice {
|
145
|
+
my $self = shift;
|
146
|
+
my $ans = shift;
|
147
|
+
my $res = $DialogManager::NEXT;
|
148
|
+
my ($dummy, $memstr);
|
149
|
+
my $strgrp;
|
150
|
+
my $numgrp;
|
151
|
+
if ($ans =~ /^\d/) { # numeric
|
152
|
+
$numgrp = $ans;
|
153
|
+
($strgrp, $dummy, $dummy, $memstr) = getgrgid $ans;
|
154
|
+
} else {
|
155
|
+
$strgrp = $ans;
|
156
|
+
($dummy, $dummy, $numgrp, $memstr) = getgrnam $ans;
|
157
|
+
}
|
158
|
+
|
159
|
+
if (!defined($strgrp) or !defined($numgrp)) {
|
160
|
+
$self->{manager}->alert("dialog_ssgroup_error", $ans);
|
161
|
+
return $DialogManager::SAME;
|
162
|
+
}
|
163
|
+
|
164
|
+
# get the user id, and then get the user's default group id
|
165
|
+
my $uid = $self->{manager}->{inf}->{General}->{SuiteSpotUserID};
|
166
|
+
my $usergid;
|
167
|
+
if ($uid =~ /^\d/) { # numeric
|
168
|
+
($uid, $dummy, $dummy, $usergid, $dummy) = getpwuid $uid;
|
169
|
+
} else { # string
|
170
|
+
($uid, $dummy, $dummy, $usergid, $dummy) = getpwnam $uid;
|
171
|
+
}
|
172
|
+
|
173
|
+
if ($numgrp == $usergid) {
|
174
|
+
$self->{manager}->{inf}->{General}->{SuiteSpotGroup} = $ans;
|
175
|
+
} elsif ($memstr) { # see if the user is in the member list
|
176
|
+
if ($memstr =~ /\b$uid\b/) { # uid exactly matches one of the users in the member string
|
177
|
+
$self->{manager}->{inf}->{General}->{SuiteSpotGroup} = $ans;
|
178
|
+
} else { # no match
|
179
|
+
$self->{manager}->alert("dialog_ssgroup_no_match",
|
180
|
+
$self->{manager}->{inf}->{General}->{SuiteSpotUserID},
|
181
|
+
$ans, $memstr);
|
182
|
+
$res = $DialogManager::SAME;
|
183
|
+
}
|
184
|
+
} else { # user not in group
|
185
|
+
$self->{manager}->alert("dialog_ssgroup_no_user",
|
186
|
+
$self->{manager}->{inf}->{General}->{SuiteSpotUserID},
|
187
|
+
$ans);
|
188
|
+
$res = $DialogManager::SAME;
|
189
|
+
}
|
190
|
+
return $res;
|
191
|
+
}
|
192
|
+
|
193
|
+
my $usergroup = new Dialog (
|
194
|
+
$TYPICAL,
|
195
|
+
'dialog_ssuser_text',
|
196
|
+
sub {
|
197
|
+
my $self = shift;
|
198
|
+
my $index = shift;
|
199
|
+
if ($index == 0) {
|
200
|
+
my $username = $self->{manager}->{inf}->{General}->{SuiteSpotUserID};
|
201
|
+
if (!$username) {
|
202
|
+
if ($> == 0) { # if root, use the default user
|
203
|
+
$username = "dirsrv";
|
204
|
+
} else { # if not root, use the user's uid
|
205
|
+
$username = getLogin;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
return $username;
|
209
|
+
} else { # group
|
210
|
+
my $groupname = $self->{manager}->{inf}->{General}->{SuiteSpotGroup};
|
211
|
+
if (!$groupname) {
|
212
|
+
if ($> == 0) { # if root, use the default group
|
213
|
+
$groupname = "dirsrv";
|
214
|
+
} else { # if not root, use the user's gid
|
215
|
+
$groupname = getgrgid $(;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
return $groupname;
|
219
|
+
}
|
220
|
+
},
|
221
|
+
sub {
|
222
|
+
my $self = shift;
|
223
|
+
my $ans = shift;
|
224
|
+
my $index = shift;
|
225
|
+
if ($index == 0) {
|
226
|
+
return verifyUserChoice($self, $ans);
|
227
|
+
} else {
|
228
|
+
return verifyGroupChoice($self, $ans);
|
229
|
+
}
|
230
|
+
},
|
231
|
+
['dialog_ssuser_prompt'], ['dialog_ssgroup_prompt']
|
232
|
+
);
|
233
|
+
|
234
|
+
|
235
|
+
sub getDialogs {
|
236
|
+
return ($welcome, $dsktune, $setuptype, $hostdlg, $usergroup);
|
237
|
+
}
|
238
|
+
|
239
|
+
sub getRegDialogs {
|
240
|
+
return ($usergroup);
|
241
|
+
}
|
242
|
+
|
243
|
+
1;
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# BEGIN COPYRIGHT BLOCK
|
2
|
+
# Copyright (C) 2007 Red Hat, Inc.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# License: GPL (version 3 or any later version).
|
6
|
+
# See LICENSE for details.
|
7
|
+
# END COPYRIGHT BLOCK
|
8
|
+
#
|
9
|
+
# This implements SetupLog from setuputil InstallLog in perl
|
10
|
+
#
|
11
|
+
package SetupLog;
|
12
|
+
use Exporter ();
|
13
|
+
@ISA = qw(Exporter);
|
14
|
+
@EXPORT = qw($FATAL $START $SUCCESS $WARN $INFO $DEBUG);
|
15
|
+
@EXPORT_OK = qw($FATAL $START $SUCCESS $WARN $INFO $DEBUG);
|
16
|
+
|
17
|
+
use POSIX qw(strftime);
|
18
|
+
|
19
|
+
# tempfiles
|
20
|
+
use File::Temp qw(tempfile tempdir);
|
21
|
+
|
22
|
+
# exported variables
|
23
|
+
$FATAL = "Fatal";
|
24
|
+
$START = "Start";
|
25
|
+
$SUCCESS = "Success";
|
26
|
+
$WARN = "Warning";
|
27
|
+
$INFO = "Info";
|
28
|
+
$DEBUG = "Debug";
|
29
|
+
|
30
|
+
sub new {
|
31
|
+
my $type = shift;
|
32
|
+
my $filename = shift;
|
33
|
+
my $prefix = shift || "setup";
|
34
|
+
my $self = {};
|
35
|
+
my $fh;
|
36
|
+
|
37
|
+
if (!$filename) {
|
38
|
+
($fh, $filename) = tempfile("${prefix}XXXXXX", UNLINK => 0,
|
39
|
+
SUFFIX => ".log", DIR => File::Spec->tmpdir);
|
40
|
+
} else {
|
41
|
+
if (!open(LOGFILE, ">$filename")) {
|
42
|
+
print STDERR "Error: could not open logfile $filename: $!\n";
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
$fh = \*LOGFILE;
|
46
|
+
}
|
47
|
+
$self->{fh} = $fh;
|
48
|
+
$self->{filename} = $filename;
|
49
|
+
$self = bless $self, $type;
|
50
|
+
|
51
|
+
return $self;
|
52
|
+
}
|
53
|
+
|
54
|
+
sub logMessage {
|
55
|
+
my ($self, $level, $who, $msg, @rest) = @_;
|
56
|
+
if (!$self->{fh}) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
|
60
|
+
my $string = strftime "[%y/%m/%d:%H:%M:%S] - ", localtime;
|
61
|
+
$string .= "[$who] $level ";
|
62
|
+
$string .= sprintf $msg, @rest;
|
63
|
+
print { $self->{fh} } $string;
|
64
|
+
}
|
65
|
+
|
66
|
+
sub logDebug {
|
67
|
+
my ($self, @msg) = @_;
|
68
|
+
if (!$self->{fh}) {
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
print { $self->{fh} } @msg;
|
72
|
+
}
|
73
|
+
|
74
|
+
sub levels {
|
75
|
+
my $self = shift;
|
76
|
+
return ($FATAL, $START, $SUCCESS, $WARN, $INFO, $DEBUG);
|
77
|
+
}
|
78
|
+
|
79
|
+
#############################################################################
|
80
|
+
# Mandatory TRUE return value.
|
81
|
+
#
|
82
|
+
1;
|
@@ -32,7 +32,7 @@ require "mu"
|
|
32
32
|
|
33
33
|
def baskets
|
34
34
|
baskets = {}
|
35
|
-
if Dir.
|
35
|
+
if Dir.exist?("/opt/mu/var/deployments")
|
36
36
|
Dir.glob("/opt/mu/var/deployments/*/basket_of_kittens.json").each { |basket_json|
|
37
37
|
basket_json =~ /^\/opt\/mu\/var\/deployments\/([^\/]+)\/basket_of_kittens.json$/
|
38
38
|
baskets[Regexp.last_match[1]] = JSON.parse(File.read(basket_json))
|
@@ -43,7 +43,7 @@ end
|
|
43
43
|
|
44
44
|
def deployments
|
45
45
|
deploys = {}
|
46
|
-
if Dir.
|
46
|
+
if Dir.exist?("/opt/mu/var/deployments")
|
47
47
|
Dir.glob("/opt/mu/var/deployments/*/deployment.json").each { |dep_json|
|
48
48
|
dep_json =~ /^\/opt\/mu\/var\/deployments\/([^\/]+)\/deployment.json$/
|
49
49
|
deploys[Regexp.last_match[1]] = JSON.parse(File.read(dep_json))
|