Merge pull request #1024 from reasonerjt/migration_rework

migration-tool rework
This commit is contained in:
Daniel Jiang 2016-11-07 13:12:54 +08:00 committed by GitHub
commit 333c616285
5 changed files with 10 additions and 15 deletions

View File

@ -16,6 +16,4 @@ WORKDIR /harbor-migration
COPY ./ ./
RUN ./prepare.sh
ENTRYPOINT ["./run.sh"]

View File

@ -30,7 +30,7 @@ script_location = migration_harbor
# are written from script.py.mako
# output_encoding = utf-8
sqlalchemy.url = mysql://$db_username:$db_password@localhost:$db_port/$db_name
sqlalchemy.url = mysql://$DB_USR:$DB_PWD@localhost:3306/registry
# Logging configuration
[loggers]

View File

@ -1,4 +0,0 @@
db_username="root"
db_password="root123"
db_port="3306"
db_name="registry"

View File

@ -1,3 +0,0 @@
#!/bin/bash
source ./migration.cfg
source ./alembic.tpl > ./alembic.ini

View File

@ -1,15 +1,19 @@
#!/bin/bash
export PYTHONPATH=$PYTHONPATH:/harbor-migration
if [ -z "$DB_USR" -o -z "$DB_PWD" ]; then
echo "DB_USR or DB_PWD not set, exiting..."
exit 1
fi
source ./migration.cfg
source ./alembic.tpl > ./alembic.ini
WAITTIME=60
DBCNF="-hlocalhost -u${db_username}"
DBCNF="-hlocalhost -u${DB_USR}"
#prevent shell to print insecure message
export MYSQL_PWD="${db_password}"
export MYSQL_PWD="${DB_PWD}"
if [[ $1 = "help" || $1 = "h" || $# = 0 ]]; then
echo "Usage:"
@ -21,7 +25,7 @@ if [[ $1 = "help" || $1 = "h" || $# = 0 ]]; then
exit 0
fi
if [[ $1 = "up" || $1 = "upgrade" ]]; then
if [[ ( $1 = "up" || $1 = "upgrade" ) && ${SKIP_CONFIRM} != "y" ]]; then
echo "Please backup before upgrade."
read -p "Enter y to continue updating or n to abort:" ans
case $ans in
@ -39,7 +43,7 @@ fi
echo 'Trying to start mysql server...'
DBRUN=0
nohup mysqld 2>&1 > ./mysqld.log&
mysqld &
for i in $(seq 1 $WAITTIME); do
echo "$(/usr/sbin/service mysql status)"
if [[ "$(/usr/sbin/service mysql status)" =~ "not running" ]]; then