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
|
# 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'
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
|