forked from devopsloft/devopsloft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap-db.sh
executable file
·37 lines (27 loc) · 1.12 KB
/
bootstrap-db.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
echo "Getting updates..."
apt-get update
echo "Setup mysql root password..."
debconf-set-selections <<< 'mysql-server mysql-server/root_password password 12345'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password 12345'
echo "Mysql installation..."
apt-get install -y mysql-server libmysqlclient-dev expect
echo "Mysql service start..."
systemctl restart mysql
unbuffer expect -c "
spawn mysql_config_editor set --login-path=local --host=localhost --user=root --password
expect -nocase \"Enter password:\" {send \"12345\r\"; interact}"
echo "Create application database and users table"
#mysql --login-path=local -e "CREATE DATABASE devopsloft;"
#mysql --login-path=local -e "CREATE TABLE devopsloft.users (first_name varchar(100) NOT NULL,last_name varchar(100) NOT NULL,email VARCHAR(320) NOT NULL);"
echo "script creating database"
uname -r | grep aws
if [ $? -eq 0 ]; then
echo 'aws'
mysql -uroot -p12345 < ./devopsloft/create_db.sql
else
echo 'not aws'
mysql -uroot -p12345 < /vagrant/create_db.sql
fi
echo "db boostrap script completed!"