forked from theforeman/forklift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.rb
executable file
·122 lines (93 loc) · 3.89 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
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env ruby
require 'optparse'
require './lib/kernel'
require './lib/forklift'
# default options
options = {
:scenario => 'katello',
:version => 'nightly',
:skip_installer => false,
:koji_task => [],
:module_prs => [],
:process_scripts => true
}
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("--scenario [INSTALL_TYPE]", ['foreman', 'katello', 'katello-devel'], "Installation type") do |type|
options[:scenario] = 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', '1.7', '1.8', '1.9', '1.10', '1.11', '1.12'], "Set the version of Foreman to install") do |version|
options[:version] = version
end
opts.on("--katello-version [KATELLO_VERSION]", ['nightly', '2.3', '2.4', '3.0', '3.1'], "Set the version of Katello to install") do |version|
options[:katello_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
opts.on("--[no-]scripts", "Run (or do not) any scripts located in the /scripts directory") do |scripts|
options[:process_scripts] = scripts
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[:katello_version] == "2.1" || options[:devel] || options[:disable_selinux]
operating_system = Forklift::OperatingSystem.new
options[:os] ||= operating_system.detect
operating_system.supported?(options[:os])
repositories = Forklift::Repositories.new(
:version => options[:version],
:os_version => operating_system.version(options[:os]),
:scenario => options[:scenario],
:distro => operating_system.distro(options[:os])
)
configured = repositories.configure(options[:koji_repos])
exit(1) unless configured
Forklift::Processors::KojiTaskProcessor.process(options[:koji_task])
installer_options = Forklift::Processors::InstallerOptionsProcessor.process(
:installer_options => options[:installer_options],
:devel_user => options[:devel_user],
:deployment_dir => options[:deployment_dir]
)
installer = Forklift::Installer.new(
:installer_options => installer_options,
:skip_installer => options[:skip_installer],
:scenario => options[:scenario],
:root_dir => Dir.pwd
)
success = installer.setup
Forklift::Processors::ModulePullRequestProcessor.process(options[:module_prs], File.expand_path(File.dirname(__FILE__)))
success = installer.install
Forklift::Processors::ScriptsProcessor.process if options[:process_scripts]
exit(1) unless success