aboutsummaryrefslogtreecommitdiffstats
path: root/testing/homer-api/homer_db_init
blob: 037d177be51b251eea31186bb8338199b3f1879c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh -e

exec_sql() {
	mysql $2 < /usr/share/homer-db/$1.sql
}

exec_sql homer_databases
exec_sql homer_user

for db in configuration data statistic; do
	exec_sql schema_$db homer_$db
done

homer_rotate

[ "$1" = -r ] || exit 0

mysql <<EOF
CREATE USER 'homer_user' IDENTIFIED BY 'homer_password';
GRANT SELECT ON homer_data.* TO 'homer_user';
GRANT SELECT ON homer_statistic.* TO 'homer_user';
EOF