Initial Chef repository
This commit is contained in:
25
cookbooks/mariadb/templates/default/mariadb_grants.erb
Normal file
25
cookbooks/mariadb/templates/default/mariadb_grants.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
# Generated by CHEF
|
||||
# Local modification will be overriden
|
||||
|
||||
<% if node['mariadb']['allow_root_pass_change'] -%>
|
||||
<% if node['mariadb']['server_root_password'].empty? -%>
|
||||
/usr/bin/mysqladmin -u root password "$1"
|
||||
<% else -%>
|
||||
/usr/bin/mysqladmin -u root -p'<%= node['mariadb']['server_root_password'] %>' password "$1"
|
||||
<% end -%>
|
||||
|
||||
<% end -%>
|
||||
password_flag=""
|
||||
if [ "$1" ]; then
|
||||
password_flag="-p$1"
|
||||
fi
|
||||
|
||||
<% if node['mariadb']['forbid_remote_root'] -%>
|
||||
user_exist=`/usr/bin/mysql -u root ${password_flag} -D mysql -r -B -N -e "SELECT user from user where user = 'root' and host = '%'"`
|
||||
if [ $user_exist == 'root' ]; then
|
||||
/bin/echo "DROP USER 'root'@'%';" | /usr/bin/mysql -u root ${password_flag}
|
||||
fi
|
||||
<% else -%>
|
||||
/bin/echo "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '<%= node['mariadb']['server_root_password'] %>' WITH GRANT OPTION;" | /usr/bin/mysql -u root ${password_flag}
|
||||
<% end -%>
|
||||
Reference in New Issue
Block a user