class SysAdminToolbox::System::Setup
Public Instance Methods
run()
click to toggle source
# File lib/SysAdminToolbox/system/setup.rb, line 10 def run SysAdminToolbox::App.clear_console puts "Welcome to initial system setup!" puts "This should only be performed on new (virgin) systems" puts SysAdminToolbox::App.quit if ask("Are you ready to start? (anything but 'yes' will cancel) ").downcase.strip != 'yes' # Root user puts "\nSecuring root account" begin root_password = password "Root Password: " raise RetryableError, 'Root password must be 8-20 charecters long!' if !root_password.length.between?(8,20) root_password2 = password "(again) " raise RetryableError, 'Passwords do not match!' if root_password != root_password2 p = Open4::popen4("passwd --stdin root") do |pid, stdin, stdout, stderr| stdin.puts root_password stdin.close end raise SystemCallError, 'Failed to change root password!' if p.exitstatus rescue RetryableError => e puts "\n"+e.message retry rescue => e puts "\n"+e.message SysAdminToolbox::App.quit end end