forked from theforeman/forklift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.rb
executable file
·110 lines (86 loc) · 3.63 KB
/
setup.rb
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
#!/usr/bin/env ruby
require 'optparse'
require './lib/kernel'
require './lib/katello_deploy'
# default options
options = {
:metapackage => 'katello',
:installer => 'katello-installer',
:version => 'nightly',
:install_type => 'katello',
:skip_installer => false,
:koji_task => [],
:module_prs => []
}
OptionParser.new do |opts|
opts.banner = "Usage: ./setup.rb [options]"
opts.on("--os [OS]", "Set OS manually") do |os|
options[:os] = os.downcase
end
opts.on("--install-type [INSTALL_TYPE]", [:katello, :devel, :sam], "Installation type") do |type|
options[:install_type] = type
end
opts.on("--devel-user [USERNAME]", "User to setup development environment for") do |devuser|
options[:devel_user] = devuser
end
opts.on("--installer-options [OPTIONS]", "Options to pass to katello-installer") do |installer_opts|
options[:installer_options] = installer_opts
end
opts.on("--skip-installer", "Skip the final installer command and print instead") do |devel|
options[:skip_installer] = true
end
opts.on("--deployment-dir [DIRECTORY]", "Set a custom path for installing to (defaults to /home/USERNAME)") do |dir|
options[:deployment_dir] = dir
end
opts.on("--version [VERSION]", [:nightly, '2.2', '2.3', '2.4'], "Set the version of Katello to install nightly|2.2|2.3|2.4") do |version|
options[:version] = version
end
opts.on("--koji-repos", "Use the repos on Koji instead of the release repos") do |koji|
options[:koji_repos] = true
end
opts.on("--koji-task [TASK ID]", Array, "ID of a Koji build task to download RPMs from") do |task|
task = task.is_a?(Array) ? task : [task]
options[:koji_task] = task
end
opts.on("--disable-selinux", "Disable selinux prior to install") do
options[:disable_selinux] = true
end
opts.on("--module-prs [MODULE/PR]", Array, "Array of module and PR combinations (e.g. qpid/12)") do |module_prs|
check = module_prs.select { |module_pr| module_pr.split('/').length != 2 }
if !check.empty?
opts.abort("The following module PRs are improperly formatted: #{check}")
end
module_prs = [] if module_prs.nil?
options[:module_prs] = module_prs
end
# Check for unsupported arguments. (parse! removes elements from ARGV.)
opts.parse!
opts.abort("Received unsupported arguments: #{ARGV}") if ARGV.length > 0
end
system('setenforce 0') if options[:version] == "2.1" || options[:devel] || options[:disable_selinux]
operating_system = KatelloDeploy::OperatingSystem.new
options[:os] ||= operating_system.detect
operating_system.supported?(options[:os])
KatelloDeploy::Processors::KojiTaskProcessor.process(options[:koji_task])
KatelloDeploy::Processors::ModulePullRequestProcessor.process(options[:module_prs], File.expand_path(File.dirname(__FILE__)))
repositories = KatelloDeploy::Repositories.new(
:katello_version => options[:version],
:os_version => operating_system.version(options[:os]),
:distro => operating_system.distro(options[:os])
)
configured = repositories.configure(options[:koji_repos])
exit(1) unless configured
installer_options = KatelloDeploy::Processors::InstallerOptionsProcessor.process(
:installer_options => options[:installer_options],
:devel_user => options[:devel_user],
:deployment_dir => options[:deployment_dir]
)
installer = KatelloDeploy::Installer.new(
:installer_options => installer_options,
:skip_installer => options[:skip_installer],
:type => options[:install_type],
:local_path => (File.directory?('./katello-installer') && options[:version] == 'nightly') ? './katello-installer' : nil
)
success = installer.install
KatelloDeploy::Processors::ScriptsProcessor.process
exit(1) unless success