Skip to content

Instantly share code, notes, and snippets.

@sturadnidge
Last active November 28, 2017 00:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturadnidge/9942c9c78613f33e945af074d4596bba to your computer and use it in GitHub Desktop.
Save sturadnidge/9942c9c78613f33e945af074d4596bba to your computer and use it in GitHub Desktop.
Creates the MySQL databases required for a PCF install
#!/bin/bash
if [ $# -ne 3 ]
then
echo "Usage: $0 {pcf-version} {mysql-host.fqdn} {mysql-user}"
echo "Creates PCF databases on a MySQL host"
exit 1
fi
VERSION="$1"
HOST="$2"
USER="$3"
read -s -p "MySQL Password: " PASSWD
case ${VERSION} in
1.8)
DATABASES=(app_usage_service autoscale ccdb console notifications routing uaa)
;;
1.9)
DATABASES=(app_usage_service autoscale ccdb diego notifications routing uaa)
;;
1.10)
DATABASES=(account app_usage_service autoscale ccdb diego networkpolicyserver nfsvolume notifications routing uaa)
;;
1.12)
;&
1.11)
DATABASES=(account app_usage_service autoscale ccdb diego locket networkpolicyserver nfsvolume notifications routing silk uaa)
;;
*)
echo "Unknown or unsupported PCF version, use <major>.<minor> format (e.g. 1.9)"
exit 1
esac
for db in ${DATABASES[@]}
do
echo "creating ${db} database..."
mysql -h ${HOST} -u ${USER} -p${PASSWD} -e "create database ${db}"
done
echo "Finished creating databases on $HOST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment