deb-heat/tools/heat-db-drop
Steven Hardy 9a8f083276 heat tools : heat-db-drop prompt for missing password
heat-db-drop fails to drop databases when called via
tools/openstack erase, so prompt for password when
not passed as a CLI argument.

Change-Id: I4930b8457e0f3e1488187b35be9737578595c387
Signed-off-by: Steven Hardy <shardy@redhat.com>
2012-07-05 10:46:53 +01:00

34 lines
660 B
Bash
Executable File

#!/bin/bash
DATABASE=heat
while [ $# -gt 0 ]; do
case $1 in
heat|nova|keystone|glance)
DATABASE=$1
;;
-r|--rootpw)
shift
MYSQL_ROOT_PW_ARG="--password=$1"
;;
*)
;;
esac
shift
done
if [ ! "${MYSQL_ROOT_PW_ARG+defined}" ] ; then
printf "Please enter the password for the 'root' MySQL user: "
read -s MYSQL_ROOT_PW
MYSQL_ROOT_PW_ARG="--password=${MYSQL_ROOT_PW}"
echo
fi
cat << EOF | mysql -u root ${MYSQL_ROOT_PW_ARG}
DROP USER '${DATABASE}'@'localhost';
DROP USER '${DATABASE}'@'%';
DROP DATABASE ${DATABASE};
flush privileges;
EOF