You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.8 KiB
70 lines
1.8 KiB
1 month ago
|
#!/bin/bash
|
||
|
|
||
|
. /3rd/env.env
|
||
|
#执行此脚本之前应该是替换了正确的mysql地址以及db tail 。
|
||
|
MYSQL_PORT="3306"
|
||
|
#需要导入db
|
||
|
|
||
|
IMPORT_REGISTER=$1
|
||
|
DB_SOURCE_URL=http://101.42.52.13:8081/ #日服(老服)地址
|
||
|
DB_TAIL="jp"
|
||
|
case ${IMPORT_REGISTER} in
|
||
|
jp|JP)
|
||
|
echo "import jp from online database"
|
||
|
DB_TAIL="jp2"
|
||
|
;;
|
||
|
en|EN)
|
||
|
echo "import en from online database"
|
||
|
DB_TAIL="en"
|
||
|
;;
|
||
|
zh|ZH)
|
||
|
echo "import zh from online database "
|
||
|
DB_TAIL="zh"
|
||
|
;;
|
||
|
none)
|
||
|
echo "none not needed import database"
|
||
|
exit 0
|
||
|
;;
|
||
|
*)
|
||
|
echo "not needed import database"
|
||
|
exit 0
|
||
|
;;
|
||
|
esac
|
||
|
#存放在下文件的零时路径
|
||
|
TEMP_DIR=/tmp/sql/${DB_TAIL}
|
||
|
mkdir -p ${TEMP_DIR}
|
||
|
cd ${TEMP_DIR}
|
||
|
# shellcheck disable=SC2035
|
||
|
rm -rf *
|
||
|
|
||
|
NEWEST_DB_ACCOUNT=$(curl -s ${DB_SOURCE_URL} | grep -Po '(?<=href=").*?(?=")' | grep "${DB_TAIL}.tgz" | grep "anhei_account" | sort | tail -n 1)
|
||
|
NEWEST_DB_GAME=$(curl -s ${DB_SOURCE_URL} | grep -Po '(?<=href=").*?(?=")' | grep "${DB_TAIL}.tgz" | grep "anhei_game" | sort | tail -n 1)
|
||
|
|
||
|
wget -q "${DB_SOURCE_URL}${NEWEST_DB_ACCOUNT}" || exit 1
|
||
|
wget -q "${DB_SOURCE_URL}${NEWEST_DB_GAME}" || exit 1
|
||
|
|
||
|
tar -zxvf "${NEWEST_DB_ACCOUNT}" -C "${TEMP_DIR}"
|
||
|
tar -zxvf "${NEWEST_DB_GAME}" -C "${TEMP_DIR}"
|
||
|
|
||
|
echo ${NEWEST_DB_ACCOUNT}
|
||
|
echo ${NEWEST_DB_GAME}
|
||
|
|
||
|
ACCOUNT_SQL=$( ls *.sql |grep account)
|
||
|
GAME_SQL=$( ls *.sql |grep game)
|
||
|
|
||
|
echo ${ACCOUNT_SQL}
|
||
|
echo ${GAME_SQL}
|
||
|
|
||
|
mv ${ACCOUNT_SQL} dbaccount.sql
|
||
|
mv ${GAME_SQL} dbgame.sql
|
||
|
#把下载的文件拷贝到自定目录下面
|
||
|
DATABASE_PATCH=/data/mmogrun/publish/tools/sql
|
||
|
cp -r dbaccount.sql ${DATABASE_PATCH}
|
||
|
cp -r dbgame.sql ${DATABASE_PATCH}
|
||
|
# shellcheck disable=SC2164
|
||
|
cd ${DATABASE_PATCH}
|
||
|
sed -i "s#anhei_account#anhei_account_${CONTAINER_CODE}#g" dbaccount.sql
|
||
|
sed -i "s#anhei_game#anhei_game_${CONTAINER_CODE}#g" dbgame.sql
|
||
|
|
||
|
|