No need to check localrc for password. Also use TOP_DIR as described by smoser.

This commit is contained in:
Anthony Young 2011-10-12 14:08:08 -07:00
parent 66b8bbcbd8
commit b4db225494

View file

@ -43,8 +43,8 @@ if [ ! -d $FILES ]; then
exit 1 exit 1
fi fi
# Keep track of the current working directory. # Keep track of the current devstack directory.
CWD=`pwd` TOP_DIR=$(cd $(dirname "$0") && pwd)
# OpenStack is designed to be run as a regular user (Dashboard will fail to run # OpenStack is designed to be run as a regular user (Dashboard will fail to run
# as root, since apache refused to startup serve content from root user). If # as root, since apache refused to startup serve content from root user). If
@ -155,34 +155,32 @@ function read_password {
var=$1; msg=$2 var=$1; msg=$2
pw=${!var} pw=${!var}
localrc=$CWD/localrc localrc=$TOP_DIR/localrc
# If the password is not defined yet, proceed to prompt user for a password. # If the password is not defined yet, proceed to prompt user for a password.
if [ ! $pw ]; then if [ ! $pw ]; then
# If there is no localrc file, create one # If there is no localrc file, create one
if [ ! -e localrc ]; then if [ ! -e $localrc ]; then
touch localrc touch $localrc
fi fi
# Presumably if we got this far it can only be that our localrc is missing # Presumably if we got this far it can only be that our localrc is missing
# the required password. Prompt user for a password and write to localrc. # the required password. Prompt user for a password and write to localrc.
if ! grep -q $1 localrc; then echo ''
echo '' echo '################################################################################'
echo '################################################################################' echo $msg
echo $msg echo '################################################################################'
echo '################################################################################' echo "This value will be written to your localrc file so you don't have to enter it again."
echo "This value will be written to your localrc file so you don't have to enter it again." echo "It is probably best to avoid spaces and weird characters."
echo "It is probably best to avoid spaces and weird characters." echo "If you leave this blank, a random default value will be used."
echo "If you leave this blank, a random default value will be used." echo "Enter a password now:"
echo "Enter a password now:" read $var
read $var pw=${!var}
pw=${!var} if [ ! $pw ]; then
if [ ! $pw ]; then pw=`openssl rand -hex 10`
pw=`openssl rand -hex 10`
fi
eval "$var=$pw"
echo "$var=$pw" >> localrc
fi fi
eval "$var=$pw"
echo "$var=$pw" >> $localrc
fi fi
set -o xtrace set -o xtrace
} }