
This is currently breaking my local devtest (and probably CI once we try running with it). MysqlRootPassword is defined in the Heat template as a Resource, and passing it in as a parameter causes the error: ERROR: The Parameter (MysqlRootPassword) was not defined in template. Closes-Bug: 1358914 This reverts commit 8b049e4ed31c5c7797bf7b867a0d8c90cee40a79. Change-Id: Ie17decadef997e3ee0b19f951347797c13e02c65
96 lines
2.4 KiB
Bash
Executable File
96 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright 2013 Red Hat, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
set -e
|
|
set -o pipefail
|
|
|
|
SCRIPT_NAME=$(basename $0)
|
|
SCRIPT_HOME=$(dirname $0)
|
|
|
|
function show_options () {
|
|
echo "Usage: $SCRIPT_NAME [options] FILENAME"
|
|
echo
|
|
echo "Generate passwords for devtest and write them out to a file"
|
|
echo "that can be sourced."
|
|
echo
|
|
echo "Options:"
|
|
echo " -f, --file -- Noop. For backwards compatibility only"
|
|
echo " -o, --overwrite -- Overwrite file if it already exists."
|
|
exit $1
|
|
}
|
|
|
|
FILE=
|
|
|
|
TEMP=`getopt -o hof -l help,overwrite,file -n $SCRIPT_NAME -- "$@"`
|
|
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
|
|
|
# Note the quotes around `$TEMP': they are essential!
|
|
eval set -- "$TEMP"
|
|
|
|
while true ; do
|
|
case "$1" in
|
|
-f | --file) shift 1 ;;
|
|
-o | --overwrite) OVERWRITE=--overwrite; shift 1 ;;
|
|
-h | --help) show_options 0;;
|
|
--) shift ; break ;;
|
|
*) echo "Error: unsupported option $1." ; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
FILE=${FILE:-$1}
|
|
|
|
if [ -z "$FILE" ]; then
|
|
echo "ERROR: Must provide a filename"
|
|
exit 1
|
|
fi
|
|
|
|
OVERWRITE=${OVERWRITE:-""}
|
|
|
|
touch $FILE
|
|
# Make the file secure as reasonably possible.
|
|
chmod 0600 $FILE
|
|
if [ -n "$OVERWRITE" ]; then
|
|
echo -n "" > $FILE
|
|
fi
|
|
|
|
generate_password() {
|
|
local name=$1
|
|
if [ -z "$(grep "^$name=" $FILE)" ]; then
|
|
echo "$name=$(os-make-password)" >> $FILE
|
|
else
|
|
echo "Password $name in $FILE already exists, not overwriting."
|
|
echo "To overwrite all passwords in $FILE specify -o."
|
|
fi
|
|
}
|
|
|
|
PASSWORD_LIST="OVERCLOUD_ADMIN_PASSWORD
|
|
OVERCLOUD_ADMIN_TOKEN
|
|
OVERCLOUD_CEILOMETER_PASSWORD
|
|
OVERCLOUD_CEILOMETER_SECRET
|
|
OVERCLOUD_CINDER_PASSWORD
|
|
OVERCLOUD_DEMO_PASSWORD
|
|
OVERCLOUD_GLANCE_PASSWORD
|
|
OVERCLOUD_HEAT_PASSWORD
|
|
OVERCLOUD_NEUTRON_PASSWORD
|
|
OVERCLOUD_NOVA_PASSWORD
|
|
OVERCLOUD_SWIFT_HASH
|
|
OVERCLOUD_SWIFT_PASSWORD"
|
|
|
|
for name in $PASSWORD_LIST; do
|
|
generate_password $name
|
|
done
|