Browse code

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

Anthony Young authored on 2011/10/13 06:08:08
Showing 1 changed files
... ...
@@ -43,8 +43,8 @@ if [ ! -d $FILES ]; then
43 43
     exit 1
44 44
 fi
45 45
 
46
-# Keep track of the current working directory.
47
-CWD=`pwd`
46
+# Keep track of the current devstack directory.
47
+TOP_DIR=$(cd $(dirname "$0") && pwd)
48 48
 
49 49
 # OpenStack is designed to be run as a regular user (Dashboard will fail to run
50 50
 # as root, since apache refused to startup serve content from root user).  If
... ...
@@ -155,34 +155,32 @@ function read_password {
155 155
     var=$1; msg=$2
156 156
     pw=${!var}
157 157
 
158
-    localrc=$CWD/localrc
158
+    localrc=$TOP_DIR/localrc
159 159
 
160 160
     # If the password is not defined yet, proceed to prompt user for a password.
161 161
     if [ ! $pw ]; then
162 162
         # If there is no localrc file, create one
163
-        if [ ! -e localrc ]; then
164
-            touch localrc
163
+        if [ ! -e $localrc ]; then
164
+            touch $localrc
165 165
         fi
166 166
 
167 167
         # Presumably if we got this far it can only be that our localrc is missing 
168 168
         # the required password.  Prompt user for a password and write to localrc.
169
-        if ! grep -q $1 localrc; then
170
-            echo ''
171
-            echo '################################################################################'
172
-            echo $msg
173
-            echo '################################################################################'
174
-            echo "This value will be written to your localrc file so you don't have to enter it again."
175
-            echo "It is probably best to avoid spaces and weird characters."
176
-            echo "If you leave this blank, a random default value will be used."
177
-            echo "Enter a password now:"
178
-            read $var
179
-            pw=${!var}
180
-            if [ ! $pw ]; then
181
-                pw=`openssl rand -hex 10`
182
-            fi
183
-            eval "$var=$pw"
184
-            echo "$var=$pw" >> localrc
169
+        echo ''
170
+        echo '################################################################################'
171
+        echo $msg
172
+        echo '################################################################################'
173
+        echo "This value will be written to your localrc file so you don't have to enter it again."
174
+        echo "It is probably best to avoid spaces and weird characters."
175
+        echo "If you leave this blank, a random default value will be used."
176
+        echo "Enter a password now:"
177
+        read $var
178
+        pw=${!var}
179
+        if [ ! $pw ]; then
180
+            pw=`openssl rand -hex 10`
185 181
         fi
182
+        eval "$var=$pw"
183
+        echo "$var=$pw" >> $localrc
186 184
     fi
187 185
     set -o xtrace
188 186
 }