Module: ChefWorkstationInitialize::SelfBootstrap::NoChef::CommandlineHelpers
Instance Method Summary
collapse
#analyse_object, #check_install_dir, #debug_worklog, #default_chefzero_portrange, #default_hostname, #default_install_dir, #define_resource_requirements, #error_worklog, #generate_default_install_dir, #generate_directory, #get_out_of_cache_path, #get_out_of_folder, #get_out_of_local_chef_path, #get_path, #is_chef_constant_enabled?, #parent_nil?, #require_implement_method, #search_local_project_folder, #warning_worklog, #worklog, #worklog_counter
Instance Method Details
#base_command(command, args = [], run_opts = {}) ⇒ Object
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
|
# File 'lib/selfbootstrap/nochef/commandline.rb', line 31
def base_command(command, args = [], run_opts = {})
final_command, final_run_options = main_command(command, args, run_opts)
if respond_to?('shell_out!')
warning_worklog('Using shell_out! as executer')
[shell_out!(final_command, final_run_options)]
elsif is_mixlib_disabled?
if run_opts[:as_system]
warning_worklog "Using system to run command #{final_command}"
exit_status = system(final_command)
if exit_status.nil?
1
elsif exit_status.is_a?(Integer)
exit_status
else
2
end
else
error_worklog('Cannot continue without at least a Chef workstation setup to run command ' + final_command)
restart_bootstrap
exit 1
end
else
shell_command = Mixlib::ShellOut.new(final_command, final_run_options)
shell_command.run_command
shell_command.stdout
end
end
|
#get_homedir(user) ⇒ String
Returns the home directory of the user
from @Chef_16.6.14/provider/git
79
80
81
82
83
84
85
86
87
|
# File 'lib/selfbootstrap/nochef/commandline.rb', line 79
def get_homedir(user)
require 'etc' unless defined?(Etc)
case user
when Integer
Etc.getpwuid(user).dir
else
Etc.getpwnam(user.to_s).dir
end
end
|
#is_mixlib_disabled? ⇒ Boolean
20
21
22
|
# File 'lib/selfbootstrap/nochef/commandline.rb', line 20
def is_mixlib_disabled?
!is_chef_constant_enabled? :Mixlib
end
|
#main_command(command, args = [], run_opts = {}) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/selfbootstrap/nochef/commandline.rb', line 24
def main_command(command, args = [], run_opts = {})
command = 'sudo ' + command.to_s if run_opts[:sudo]
main_command = [command, args].compact.join(' ')
worklog "running \"#{main_command}\" from a shell terminal" [main_command, run_options(run_opts)]
end
|
#run_options(run_opts = {}) ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/selfbootstrap/nochef/commandline.rb', line 65
def run_options(run_opts = {})
run_opts[:live_stream] = $stdout if run_opts[:live]
run_opts.delete :sudo if run_opts.key? :sudo
run_opts.delete :live if run_opts.key? :live
run_opts.delete :debug if run_opts.key? :debug
run_opts
end
|