From c67c0cf12dd76a87de17e8812f8948f2b7ac094d Mon Sep 17 00:00:00 2001 From: Benedikt Koeppel Date: Sat, 18 Feb 2012 23:10:56 +0100 Subject: [PATCH] fixed mysql_database type can now install a database, and create a user who manages that database --- conf/type/__mysql_database/gencode-remote | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/conf/type/__mysql_database/gencode-remote b/conf/type/__mysql_database/gencode-remote index fdfb1501..9001ac99 100755 --- a/conf/type/__mysql_database/gencode-remote +++ b/conf/type/__mysql_database/gencode-remote @@ -26,9 +26,11 @@ else # otherwise use the object id as database name database="$__object_id" fi -mysql -u root -p <<-EOF +cat <<-EOFF +mysql -u root <<-EOF CREATE DATABASE IF NOT EXISTS $database EOF +EOFF # if --user was specified if [ -f "$__object/parameter/user" ]; then @@ -37,12 +39,17 @@ if [ -f "$__object/parameter/user" ]; then # if --password was specified if [ -f "$__object/parameter/password" ]; then password="$(cat "$__object/parameter/password")" - mysql -u root -p <<-EOF + cat <<-EOFF + mysql -u root <<-EOF GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost' IDENTIFIED BY '$password'; - EOF +EOF +EOFF else - mysql -u root -p <<-EOF + password="" + cat <<-EOFF + mysql -u root <<-EOF GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost'; - EOF +EOF +EOFF fi fi