Skip to content

Commit

Permalink
upgrade: copy the old NCC/SCC credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Apr 1, 2014
1 parent 586c7c0 commit 6c14a1a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/clients/inst_scc.rb
Expand Up @@ -629,6 +629,17 @@ def display_registered_dialog
end

def registration_check
if Mode.update
::Registration::SwMgmt.copy_old_credentials(Installation.destdir)

if ::Registration::Registration.is_registered?
# TODO FIXME: register the base system using the old credentials

# on failure re-register from scratch
return :register
end
end

return :register unless ::Registration::Registration.is_registered?

display_registered_dialog
Expand Down
33 changes: 33 additions & 0 deletions src/lib/registration/sw_mgmt.rb
Expand Up @@ -55,6 +55,7 @@ def self.init
# structure into a writable temporary directory and override the original
# location by "mount -o bind"
def self.zypp_config_writable!
log.info "#{ZYPP_DIR} writable: #{File.writable?(ZYPP_DIR)}"
return if !(Mode.installation || Mode.update) || File.writable?(ZYPP_DIR)

log.info "Copying libzypp config to a writable place"
Expand Down Expand Up @@ -157,6 +158,38 @@ def self.service_repos(product_services)
repos
end

# copy old NCC/SCC credentials from the old installation to new SCC credentials
def self.copy_old_credentials(target_dir)
log.info "Searching registration credentials in #{target_dir}..."

# check for NCC credentials
dir = SccApi::Credentials::DEFAULT_CREDENTIALS_DIR
ncc_file = File.join(target_dir, dir, "NCCcredentials")
scc_file = File.join(target_dir, dir, "SCCCredentials")
new_file = File.join(dir, "SCCCredentials")

# ensure the zypp directory is writable in inst-sys
zypp_config_writable!

# create the target directory if missing
if !File.exist?(dir)
log.info "Creating directory #{dir}"
::FileUtils.mkdir_p(dir)
end

if File.exist?(ncc_file)
log.info "Copying the old NCC credentials from previous installation"
log.info "Copying #{ncc_file} to #{new_file}"
::FileUtils.cp(ncc_file, new_file)
end

if File.exist?(scc_file)
log.info "Copying the old SCC credentials from previous installation"
log.info "Copying #{scc_file} to #{new_file}"
::FileUtils.cp(scc_file, new_file)
end
end

end
end

0 comments on commit 6c14a1a

Please sign in to comment.