mirror of
https://github.com/ThunixdotNet/makeuser.git
synced 2026-01-24 05:30:18 +00:00
Adding db provisioning tool
This commit is contained in:
7
dbemail.tmpl
Normal file
7
dbemail.tmpl
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Hello _username_;
|
||||||
|
|
||||||
|
Your database has been provisioned. Information below should be used to connect to it:
|
||||||
|
|
||||||
|
Database name: _username_
|
||||||
|
Database user: _username_
|
||||||
|
Password: _password_
|
||||||
15
makedb
Executable file
15
makedb
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
USER=$1
|
||||||
|
PASSWORD=`pwgen -1B 24`
|
||||||
|
ADMIN_EMAIL='root@thunix.net'
|
||||||
|
|
||||||
|
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" $USER@thunix.net
|
||||||
|
sed -e "s/_username_/$USER/g" -e "s/_password_/$PASSWORD/g" dbemail.tmpl | sudo mail -s "Your database has been provisioned" $ADMIN_EMAIL
|
||||||
|
|
||||||
Reference in New Issue
Block a user