diff options
Diffstat (limited to 'main/homer-api/homer_db_init')
-rw-r--r-- | main/homer-api/homer_db_init | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/main/homer-api/homer_db_init b/main/homer-api/homer_db_init new file mode 100644 index 0000000000..c80328ac6a --- /dev/null +++ b/main/homer-api/homer_db_init @@ -0,0 +1,24 @@ +#!/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 |