class Commands::Init::SystemSettingsModel
Attributes
configure_settings[R]
security_level[R]
unicode[R]
Public Class Methods
abstract()
click to toggle source
# File lib/commands/init/system_settings_model.rb, line 33 def self.abstract true end
new()
click to toggle source
# File lib/commands/init/system_settings_model.rb, line 39 def initialize @unicode = self.class.unicode @security_level = self.class.security_level @configure_settings = self.class.configure_settings end
Public Instance Methods
execute(p4, super_user)
click to toggle source
If the security level is > 0, we generate the super_user first, change security, then reset the super’s password. The p4 connection is established here with whatever credentials we end up with the super user as.
# File lib/commands/init/system_settings_model.rb, line 49 def execute(p4, super_user) puts 'initializing system settings' set_unicode_mode(p4) set_security_and_super_user(p4, super_user) create_default_protections(p4) end
Private Instance Methods
create_default_protections(p4)
click to toggle source
# File lib/commands/init/system_settings_model.rb, line 116 def create_default_protections(p4) # This actually will establish the defaults with our super user as the # only entry results = p4.run_protect('-o') end
set_security_and_super_user(p4, super_user)
click to toggle source
# File lib/commands/init/system_settings_model.rb, line 85 def set_security_and_super_user(p4, super_user) # update security mode if needed if security_level > 0 # On some security levels, you *must* reset passwords when updating # even if the base password is strong. super_pwd = super_user.password super_user.password = '' super_user.execute(p4) p4.run('configure', 'set', "security=#{security_level}") p4.user = super_user.login p4.password = super_user.password p4.run_password(super_user.password, super_pwd) super_user.password = super_pwd p4.password = super_user.password results = p4.run_login('-p') p4.password = results.first else # Just create the user super_user.execute(p4) if super_user.password p4.password = super_user.password results = p4.run_login('-p') p4.password = results.first end end end
set_unicode_mode(p4)
click to toggle source
# File lib/commands/init/system_settings_model.rb, line 58 def set_unicode_mode(p4) if unicode p4.disconnect # Halt any exiting perforce server Commands.kill # Execute the upgrade of the p4d instance Commands.unicode_upgrade # Restart: this assumes the cwd of the init call is the same as the # 'start' call. This is a pretty safe assumption, since our .init # function will call start if it's not running. Commands.start while !Commands.p4d_running? sleep 0.2 end # I'm not sure this should be anything else for the purposes of # initialization p4.charset = 'auto' p4.connect end end