Skip to content

Commit

Permalink
fixed copying of the old credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Mar 28, 2014
1 parent 43e0625 commit 1638ec7
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/lib/registration/sw_mgmt.rb
Expand Up @@ -55,7 +55,8 @@ def self.init
# structure into a writable temporary directory and override the original
# location by "mount -o bind"
def self.zypp_config_writable!
return if !Mode.installation || !Mode.update || File.writable?(ZYPP_DIR)
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 @@ -159,22 +160,33 @@ def self.service_repos(product_services)

# 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.debug "Copying #{ncc_file} to #{new_file}"
File.cp(ncc_file, new_file)
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.debug "Copying #{scc_file} to #{new_file}"
File.cp(scc_file, new_file)
log.info "Copying #{scc_file} to #{new_file}"
::FileUtils.cp(scc_file, new_file)
end
end

Expand Down

0 comments on commit 1638ec7

Please sign in to comment.