Fix create_userrc.sh private key hang

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
This commit is contained in:
Dean Troyer 2013-02-20 17:51:19 -06:00
parent 25ebbcd1a7
commit 0f2d954b82

View File

@ -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
@ -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