-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathcreate_db.sh
More file actions
executable file
·38 lines (28 loc) · 974 Bytes
/
Copy pathcreate_db.sh
File metadata and controls
executable file
·38 lines (28 loc) · 974 Bytes
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
#!/usr/bin/env bash
set -e -u
function exit_err() {
if [ ! -z "$1" ]
then
echo $1 > /dev/stderr
fi
exit 1
}
dbconn="-u root -h boulder-mysql --port 3306"
if [ -d /var/lib/mysql/boulder_sa ]; then
echo "Database boulder_sa already exists, so not creating it"
# Always update the user grants just to be safe...
file="/opt/boulder/sa/db/02-users.sql"
echo "Executing script ${file}..."
mysql ${dbconn} < ${file} || exit_err "failed to run script ${file}"
else
echo "Creating database boulder_sa..."
if ! mysql ${dbconn} -e "select 1" >/dev/null 2>&1; then
exit_err "unable to connect to boulder-mysql:3306"
fi
mysql ${dbconn} -e "SET GLOBAL binlog_format = 'MIXED';"
mysql ${dbconn} -e "SET GLOBAL max_connections = 500;"
for file in `ls -1 /opt/boulder/sa/db/*.sql`; do
echo "Executing script ${file}..."
mysql ${dbconn} < ${file} || exit_err "failed to run script ${file}"
done
fi