forked from ungleich-public/cdist
fixed mysql_database type
can now install a database, and create a user who manages that database
This commit is contained in:
parent
cfaee39e70
commit
c67c0cf12d
1 changed files with 12 additions and 5 deletions
|
@ -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
|
||||
EOFF
|
||||
else
|
||||
mysql -u root -p <<-EOF
|
||||
password=""
|
||||
cat <<-EOFF
|
||||
mysql -u root <<-EOF
|
||||
GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost';
|
||||
EOF
|
||||
EOFF
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue