forked from ungleich-public/cdist
Merge remote-tracking branch 'benedikt/type-mysql_database'
This commit is contained in:
commit
08ce990207
3 changed files with 107 additions and 0 deletions
55
conf/type/__mysql_database/gencode-remote
Executable file
55
conf/type/__mysql_database/gencode-remote
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2012 Benedikt Koeppel (code@benediktkoeppel.ch)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
# if --database was specified
|
||||||
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
database="$(cat "$__object/parameter/name")"
|
||||||
|
else # otherwise use the object id as database name
|
||||||
|
database="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<-EOFF
|
||||||
|
mysql -u root <<-EOF
|
||||||
|
CREATE DATABASE IF NOT EXISTS $database
|
||||||
|
EOF
|
||||||
|
EOFF
|
||||||
|
|
||||||
|
# if --user was specified
|
||||||
|
if [ -f "$__object/parameter/user" ]; then
|
||||||
|
user="$(cat "$__object/parameter/user")"
|
||||||
|
|
||||||
|
# if --password was specified
|
||||||
|
if [ -f "$__object/parameter/password" ]; then
|
||||||
|
password="$(cat "$__object/parameter/password")"
|
||||||
|
cat <<-EOFF
|
||||||
|
mysql -u root <<-EOF
|
||||||
|
GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost' IDENTIFIED BY '$password';
|
||||||
|
EOF
|
||||||
|
EOFF
|
||||||
|
else
|
||||||
|
password=""
|
||||||
|
cat <<-EOFF
|
||||||
|
mysql -u root <<-EOF
|
||||||
|
GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost';
|
||||||
|
EOF
|
||||||
|
EOFF
|
||||||
|
fi
|
||||||
|
fi
|
49
conf/type/__mysql_database/man.text
Normal file
49
conf/type/__mysql_database/man.text
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
cdist-type__mysql_database(7)
|
||||||
|
=============================
|
||||||
|
Benedikt Koeppel <code@benediktkoeppel.ch>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__mysql_database - Manage a MySQL database
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This cdist type allows you to install a MySQL database.
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
None.
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
name::
|
||||||
|
The name of the database to install
|
||||||
|
defaults to the object id
|
||||||
|
|
||||||
|
user::
|
||||||
|
A user that should have access to the database
|
||||||
|
|
||||||
|
password::
|
||||||
|
The password for the user who manages the database
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
__mysql_database "cdist" --name "cdist" --user "myuser" --password "mypwd"
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2012 Benedikt Koeppel. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
3
conf/type/__mysql_database/parameter/optional
Normal file
3
conf/type/__mysql_database/parameter/optional
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
name
|
||||||
|
user
|
||||||
|
password
|
Loading…
Reference in a new issue