aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-db-createdb-mysql.sql34
-rw-r--r--catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-insert-extend-mysql.sql17
-rw-r--r--catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-insert-mysql.sql20
-rw-r--r--catalog-core/distribution/catalog-standalone/src/main/assembly/dbscripts/mysql/openo-common_tosca-catalog-createobj.sql (renamed from catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-createObj-mysql.sql)20
-rw-r--r--catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.bat42
-rw-r--r--catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.sh29
6 files changed, 53 insertions, 109 deletions
diff --git a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-db-createdb-mysql.sql b/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-db-createdb-mysql.sql
deleted file mode 100644
index 9b7ed341..00000000
--- a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-db-createdb-mysql.sql
+++ /dev/null
@@ -1,34 +0,0 @@
---
--- Copyright 2016 [ZTE] and others.
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
-
-/******************drop old database and user***************************/
-use mysql;
-drop database IF EXISTS catalog;
-delete from user where User='catalog';
-FLUSH PRIVILEGES;
-
-/******************create new database and user***************************/
-create database catalog CHARACTER SET utf8;
-
-GRANT ALL PRIVILEGES ON catalog.* TO 'catalog'@'%' IDENTIFIED BY 'catalog' WITH GRANT OPTION;
-GRANT ALL PRIVILEGES ON mysql.* TO 'catalog'@'%' IDENTIFIED BY 'catalog' WITH GRANT OPTION;
-
-GRANT ALL PRIVILEGES ON catalog.* TO 'catalog'@'localhost' IDENTIFIED BY 'catalog' WITH GRANT OPTION;
-GRANT ALL PRIVILEGES ON mysql.* TO 'catalog'@'localhost' IDENTIFIED BY 'catalog' WITH GRANT OPTION;
-FLUSH PRIVILEGES;
-
-use catalog;
-set Names 'utf8';
diff --git a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-insert-extend-mysql.sql b/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-insert-extend-mysql.sql
deleted file mode 100644
index 50b0c190..00000000
--- a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-insert-extend-mysql.sql
+++ /dev/null
@@ -1,17 +0,0 @@
---
--- Copyright 2016 [ZTE] and others.
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
-
--- \ No newline at end of file
diff --git a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-insert-mysql.sql b/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-insert-mysql.sql
deleted file mode 100644
index d0bd6180..00000000
--- a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-insert-mysql.sql
+++ /dev/null
@@ -1,20 +0,0 @@
---
--- Copyright 2016 [ZTE] and others.
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
-
-SET autocommit = 0;
-
-COMMIT;
-SET autocommit = 1; \ No newline at end of file
diff --git a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-createObj-mysql.sql b/catalog-core/distribution/catalog-standalone/src/main/assembly/dbscripts/mysql/openo-common_tosca-catalog-createobj.sql
index d49e60ba..308a416a 100644
--- a/catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog-resource-createObj-mysql.sql
+++ b/catalog-core/distribution/catalog-standalone/src/main/assembly/dbscripts/mysql/openo-common_tosca-catalog-createobj.sql
@@ -14,6 +14,25 @@
-- limitations under the License.
--
+/******************drop old database and user***************************/
+use mysql;
+drop database IF EXISTS catalog;
+delete from user where User='catalog';
+FLUSH PRIVILEGES;
+
+/******************create new database and user***************************/
+create database catalog CHARACTER SET utf8;
+
+GRANT ALL PRIVILEGES ON catalog.* TO 'catalog'@'%' IDENTIFIED BY 'catalog' WITH GRANT OPTION;
+GRANT ALL PRIVILEGES ON mysql.* TO 'catalog'@'%' IDENTIFIED BY 'catalog' WITH GRANT OPTION;
+
+GRANT ALL PRIVILEGES ON catalog.* TO 'catalog'@'localhost' IDENTIFIED BY 'catalog' WITH GRANT OPTION;
+GRANT ALL PRIVILEGES ON mysql.* TO 'catalog'@'localhost' IDENTIFIED BY 'catalog' WITH GRANT OPTION;
+FLUSH PRIVILEGES;
+
+use catalog;
+set Names 'utf8';
+/******************delete old table and create new***************************/
use catalog;
DROP TABLE IF EXISTS catalog_package_table;
@@ -73,3 +92,4 @@ CREATE TABLE catalog_model_substitution_mapping_table (
CONSTRAINT catalog_model_substitution_mapping_table PRIMARY KEY(MAPPINGID)
);
+
diff --git a/catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.bat b/catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.bat
index 61a00e69..6663e3d7 100644
--- a/catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.bat
+++ b/catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.bat
@@ -1,4 +1,5 @@
@REM
+@REM
@REM Copyright 2016 [ZTE] and others.
@REM
@REM Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,28 +16,19 @@
@REM
@echo off
-title init catalog db
-
-set RUNHOME=%~dp0
-echo ### RUNHOME: %RUNHOME%
-
-echo ### init catalog db
-rem cd /d %RUNHOME%
-
-set JAVA="%JAVA_HOME%\bin\java.exe"
-set port=8777
-set jvm_opts=-Xms50m -Xmx128m
-rem set jvm_opts=%jvm_opts% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=%port%,server=y,suspend=n
-set class_path=%RUNHOME%;%RUNHOME%catalog-service.jar
-echo ### jvm_opts: %jvm_opts%
-echo ### class_path: %class_path%
-
-%JAVA% -classpath %class_path% %jvm_opts% org.openo.commontosca.catalog.CatalogApp db migrate %RUNHOME%conf\catalog.yml
-
-IF ERRORLEVEL 1 goto showerror
-exit
-:showerror
-echo WARNING: Error occurred during startup or Server abnormally stopped by way of killing the process,Please check!
-echo After checking, press any key to close
-pause
-exit \ No newline at end of file
+set HOME=%~dp0
+set user=%1
+set password=%2
+set port=%3
+set host=%4
+echo start init catalog db
+echo HOME=$HOME
+cd /d %HOME%
+mysql -u%user% -p%password% -P%port% -h%host% < dbscripts\mysql\openo-common_tosca-catalog-createobj.sql
+set "err=%errorlevel%"
+if "%err%"=="0" (
+ echo init catalog db success
+ ) else (
+ echo failed init catalog db
+ pause
+ ) \ No newline at end of file
diff --git a/catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.sh b/catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.sh
index b950f88c..2e5cd323 100644
--- a/catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.sh
+++ b/catalog-core/distribution/catalog-standalone/src/main/assembly/initDB.sh
@@ -1,3 +1,5 @@
+#!/bin/bash
+#
#
# Copyright 2016 [ZTE] and others.
#
@@ -15,17 +17,18 @@
#
DIRNAME=`dirname $0`
-RUNHOME=`cd $DIRNAME/; pwd`
-echo @RUNHOME@ $RUNHOME
-
-title catalog Database setup
-
-echo ### Starting catalog Database setup
-echo @JAVA_HOME@ $JAVA_HOME
-JAVA="$JAVA_HOME/bin/java"
-echo @JAVA@ $JAVA
-
-class_path="$RUNHOME/:$RUNHOME/catalog-service.jar"
-echo @class_path@ $class_path
+HOME=`cd $DIRNAME/; pwd`
+user=$1
+password=$2
+port=$3
+host=$4
+echo "start init catalog db"
+mysql -u$user -p$password -P$port -h$host <dbscripts/mysql/openo-common_tosca-catalog-createobj.sql
+sql_result=$?
+if [ $sql_result != 0 ] ; then
+ echo "failed to init catalog database!"
+ exit 1
+fi
+echo "init catalog database success!"
+exit 0
-"$JAVA" -classpath "$class_path" org.openo.commontosca.catalog.CatalogApp db migrate "$RUNHOME/conf/catalog.yml"