Skip to content

Commit

Permalink
Fix create_userrc.sh private key hang
Browse files Browse the repository at this point in the history
tools/create_userrc.sh hangs in a couple of mv commands now that
private keys are created with mode 400.  mv is prompting to
override the permissions, so let's just -f it all.

Change-Id: I8fbb24da6582edcff741653ffdf8bf683b79851a
  • Loading branch information
Dean Troyer committed Feb 20, 2013
1 parent 25ebbcd commit 0f2d954
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tools/create_userrc.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash

#Warning: This script just for development purposes
# **create_userrc.sh**

# Pre-create rc files and credentials for the default users.

# Warning: This script just for development purposes

ACCOUNT_DIR=./accrc

Expand Down Expand Up @@ -164,12 +168,12 @@ function add_entry(){
local ec2_cert="$rcfile-cert.pem"
local ec2_private_key="$rcfile-pk.pem"
# Try to preserve the original file on fail (best effort)
mv "$ec2_private_key" "$ec2_private_key.old" &>/dev/null
mv "$ec2_cert" "$ec2_cert.old" &>/dev/null
mv -f "$ec2_private_key" "$ec2_private_key.old" &>/dev/null
mv -f "$ec2_cert" "$ec2_cert.old" &>/dev/null
# It will not create certs when the password is incorrect
if ! nova --os-password "$user_passwd" --os-username "$user_name" --os-tenant-name "$tenant_name" x509-create-cert "$ec2_private_key" "$ec2_cert"; then
mv "$ec2_private_key.old" "$ec2_private_key" &>/dev/null
mv "$ec2_cert.old" "$ec2_cert" &>/dev/null
mv -f "$ec2_private_key.old" "$ec2_private_key" &>/dev/null
mv -f "$ec2_cert.old" "$ec2_cert" &>/dev/null
fi
cat >"$rcfile" <<EOF
# you can source this file
Expand Down

0 comments on commit 0f2d954

Please sign in to comment.