1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-23 03:05:48 +03:00
aports/community/homer-api/homer_db_init
2017-09-19 17:17:04 +03:00

24 lines
421 B
Bash

#!/bin/sh -e
# HOMER database setup script
# Copyright (c) 2017 Kaarle Ritvanen
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';
EOF