Adding db provisioning tool

This commit is contained in:
Ubergeek
2019-06-28 13:17:48 +00:00
parent cbcb6d2e0e
commit 9bf8982535
2 changed files with 22 additions and 0 deletions
Executable
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
USER=$1
PASSWORD=`pwgen -1B 24`
ADMIN_EMAIL='[email protected]'
sudo mysql -u root << _EOF
CREATE DATABASE $USER;
GRANT ALL PRIVILEGES ON $USER.* TO '$USER'@'localhost' IDENTIFIED BY '$PASSWORD';
FLUSH PRIVILEGES;
_EOF
sed -e "s/_username_/$USER/g" -e "s/_password_/$PASSWORD/g" dbemail.tmpl | sudo mail -s "Your database has been provisioned" [email protected]
sed -e "s/_username_/$USER/g" -e "s/_password_/$PASSWORD/g" dbemail.tmpl | sudo mail -s "Your database has been provisioned" $ADMIN_EMAIL