Skip to content

Instantly share code, notes, and snippets.

@sturadnidge
Last active November 28, 2017 00:27
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/372ae30ce91683041cbede10d4c05197 to your computer and use it in GitHub Desktop.
Save sturadnidge/372ae30ce91683041cbede10d4c05197 to your computer and use it in GitHub Desktop.
Cleans a PCF MySQL host
#!/bin/bash
if [ $# -ne 3 ]
then
echo "Usage: $0 {pcf-version} {mysql-host.fqdn} {mysql-user}"
echo "Cleans 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 "dropping & creating ${db} database..."
mysql -h ${HOST} -u ${USER} -p${PASSWD} -e "drop database ${db}; create database ${db}"
done
echo "Finished cleaning databases on $HOST"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment