summaryrefslogtreecommitdiff
path: root/devobsserver/script/initdb.sh
diff options
context:
space:
mode:
authorYonghee Han <onstudy@samsung.com>2015-08-24 09:54:28 +0900
committerYonghee Han <onstudy@samsung.com>2015-08-24 09:54:28 +0900
commit1cc792770d897a412406c4e394c8980bd7e4cb2d (patch)
tree57b64d2ebf0dc157571acff00821010f7dc351da /devobsserver/script/initdb.sh
parent08f3e2976ea26ae7db0668a65e0d0bf09c78a4be (diff)
downloaddocker-script-obsserver-2.4.tar.gz
docker-script-obsserver-2.4.tar.bz2
docker-script-obsserver-2.4.zip
Initial OBS Server v2.4 with docker2.4.0.7obsserver-2.4
Change-Id: Ia5a62c215190104e4f141cdefe3e972f1fbc9a84
Diffstat (limited to 'devobsserver/script/initdb.sh')
-rwxr-xr-xdevobsserver/script/initdb.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/devobsserver/script/initdb.sh b/devobsserver/script/initdb.sh
new file mode 100755
index 0000000..1ec2e5d
--- /dev/null
+++ b/devobsserver/script/initdb.sh
@@ -0,0 +1,54 @@
+#!/bin/bash
+#===============================================================================
+# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+# Author onstudy@samsung.com
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#===============================================================================
+set -e
+
+echo "initdb.sh start"
+
+if [[ ! -d $MYSQL_DATA_DIR_DEFAULT/$MYSQL_API_DATABASE ]]; then
+ if [ -z "$MYSQL_ROOT_PASSWORD" ]; then
+ echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set'
+ echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?'
+ exit 1
+ fi
+
+ /usr/sbin/rcmysql start
+ # Allow some time for the service to start
+ sleep 5
+
+ echo "create database start"
+
+ echo "change root password"
+ mysql -u root <<-EOFMYSQL
+ DELETE FROM mysql.user ;
+ CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
+ GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
+ DROP DATABASE IF EXISTS test ;
+ CREATE DATABASE IF NOT EXISTS $MYSQL_API_DATABASE ;
+ CREATE DATABASE IF NOT EXISTS $MYSQL_WEBUI_DATABASE ;
+ CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;
+ CREATE USER '$MYSQL_USER'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD' ;
+ GRANT ALL ON $MYSQL_API_DATABASE.* TO '$MYSQL_USER'@'%','$MYSQL_USER'@'localhost' ;
+ GRANT ALL ON $MYSQL_WEBUI_DATABASE.* TO '$MYSQL_USER'@'%','$MYSQL_USER'@'localhost' ;
+ FLUSH PRIVILEGES ;
+ EOFMYSQL
+ echo "create database end"
+ /usr/sbin/rcmysql stop
+ # Allow some time for the service to start
+ sleep 5
+fi
+
+chown -R mysql:mysql /var/lib/mysql
+
+echo "initdb.sh end"