begin
arv = Arvados.new({ :suppress_ssl_warnings => false })
+ logincluster_arv = Arvados.new({ :api_host => (ENV['LOGINCLUSTER_ARVADOS_API_HOST'] || ENV['ARVADOS_API_HOST']),
+ :api_token => (ENV['LOGINCLUSTER_ARVADOS_API_TOKEN'] || ENV['ARVADOS_API_TOKEN']),
+ :suppress_ssl_warnings => false })
vm_uuid = ENV['ARVADOS_VIRTUAL_MACHINE_UUID']
userdotconfig = File.join(homedir, ".config")
if !File.exist?(userdotconfig)
Dir.mkdir(userdotconfig)
- FileUtils.chown_R(l[:username], nil, userdotconfig)
- File.chmod(0700, userdotconfig)
end
configarvados = File.join(userdotconfig, "arvados")
begin
if !File.exist?(tokenfile)
- user_token = arv.api_client_authorization.create(api_client_authorization: {owner_uuid: l[:user_uuid], api_client_id: 0})
+ user_token = logincluster_arv.api_client_authorization.create(api_client_authorization: {owner_uuid: l[:user_uuid], api_client_id: 0})
f = File.new(tokenfile, 'w')
f.write("ARVADOS_API_HOST=#{ENV['ARVADOS_API_HOST']}\n")
f.write("ARVADOS_API_TOKEN=v2/#{user_token[:uuid]}/#{user_token[:api_token]}\n")
f.close()
- File.chmod(0600, tokenfile)
end
rescue => e
STDERR.puts "Error setting token for #{l[:username]}: #{e}"
end
FileUtils.chown_R(l[:username], nil, userdotssh)
- FileUtils.chown_R(l[:username], nil, configarvados)
+ FileUtils.chown_R(l[:username], nil, userdotconfig)
File.chmod(0700, userdotssh)
+ File.chmod(0700, userdotconfig)
+ File.chmod(0700, configarvados)
File.chmod(0750, homedir)
File.chmod(0600, keysfile)
- File.chmod(0700, configarvados)
+ if File.exist?(tokenfile)
+ File.chmod(0600, tokenfile)
+ end
end
rescue Exception => bang