Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-deploy-utils
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qa-deploy-utils
Commits
1fc30555
Commit
1fc30555
authored
Jan 17, 2017
by
QA-甘 盛聪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copy sh-utils
parent
cf53ec4e
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
1632 additions
and
0 deletions
+1632
-0
.DS_Store
execu-utils/center/.DS_Store
+0
-0
1_branch_checkout.sh
execu-utils/center/1_branch_checkout.sh
+28
-0
2_build_java.sh
execu-utils/center/2_build_java.sh
+67
-0
2_build_ui.sh
execu-utils/center/2_build_ui.sh
+113
-0
3_remote_copy.sh
execu-utils/center/3_remote_copy.sh
+58
-0
4_java_restart.sh
execu-utils/center/4_java_restart.sh
+75
-0
copy_java.sh
execu-utils/center/copy_java.sh
+28
-0
copy_ui.sh
execu-utils/center/copy_ui.sh
+36
-0
copy_utils.sh
execu-utils/center/copy_utils.sh
+49
-0
database_backup.sh
execu-utils/center/database_backup.sh
+111
-0
database_import.sh
execu-utils/center/database_import.sh
+37
-0
database_replace_ip.sh
execu-utils/center/database_replace_ip.sh
+86
-0
generate_properties.sh
execu-utils/center/generate_properties.sh
+32
-0
prepare_for_copy_java.sh
execu-utils/center/prepare_for_copy_java.sh
+28
-0
check_file_diff.js
execu-utils/deploy/check_file_diff.js
+85
-0
database_sync.sh
execu-utils/deploy/database_sync.sh
+63
-0
java_deploy.sh
execu-utils/deploy/java_deploy.sh
+89
-0
multiple_deploy.sh
execu-utils/deploy/multiple_deploy.sh
+58
-0
other_deploy.sh
execu-utils/deploy/other_deploy.sh
+70
-0
ui_deploy.sh
execu-utils/deploy/ui_deploy.sh
+59
-0
java_start.sh
execu-utils/worker/java_start.sh
+93
-0
java_stop.sh
execu-utils/worker/java_stop.sh
+11
-0
log_backup.sh
execu-utils/worker/log_backup.sh
+24
-0
log_check.sh
execu-utils/worker/log_check.sh
+44
-0
other_restart.sh
execu-utils/worker/other_restart.sh
+91
-0
post_for_copy_java.sh
execu-utils/worker/post_for_copy_java.sh
+33
-0
post_for_copy_ui.sh
execu-utils/worker/post_for_copy_ui.sh
+32
-0
prepare_for_copy.sh
execu-utils/worker/prepare_for_copy.sh
+38
-0
process_stop.sh
execu-utils/worker/process_stop.sh
+12
-0
ui_replace_ip.sh
execu-utils/worker/ui_replace_ip.sh
+64
-0
unzip_utils.sh
execu-utils/worker/unzip_utils.sh
+18
-0
No files found.
execu-utils/center/.DS_Store
0 → 100644
View file @
1fc30555
File added
execu-utils/center/1_branch_checkout.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
# -------------------------------------------------------------------------------
# Filename: java_deploy.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本根据git的分支名称(branch name)导出(checkout)不同的分支。
# Usage:used by ../deploy/*_deploy.sh
# -------------------------------------------------------------------------------
branch_name
=
$1
profile
=
test
if
[
-z
${
branch_name
}
]
;
then
echo
"checkout default branch master"
git pull
else
echo
"checkout specified branch
$1
"
which git
git checkout
${
branch_name
}
if
[
$?
=
0
]
;
then
echo
"checkout branch
$1
is ok"
.
git pull
else
echo
"Fail to checkout branch
$1
"
.
exit
-1
fi
fi
execu-utils/center/2_build_java.sh
0 → 100644
View file @
1fc30555
# -------------------------------------------------------------------------------
# Filename: java_deploy.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本负责build java项目。
# Usage:used by ../deploy/java_deploy.sh
# -------------------------------------------------------------------------------
source
/etc/profile
config_profile
=
$1
module
=
$2
host
=
$3
close_captcha
=
$4
echo
$close_captcha
if
[[
"
${
host
}
"
=
"192.168.10.2"
]]
then
suffix
=
''
echo
"skip get suffix"
else
suffix
=
$((${
host
:10
}))
echo
$host
$suffix
fi
if
[
-z
$config_profile
]
;
then
echo
"Does not set config profile, use the default value: test"
${
config_profile
}
=
test
else
echo
"use specified profile
$config_profile
"
fi
if
[[
"
$module
"
=
"han-gu-guan"
]]
&&
$close_captcha
;
then
echo
"关闭验证码"
num
=
`
grep
-n
"Boolean validCaptcha"
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaValidateAdvisor.java|awk
-F
':'
'{print $1}'
`
sed
-i
"
${
num
}
s/false/true/"
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaValidateAdvisor.java
num1
=
`
expr
${
num
}
+ 1
`
num6
=
`
expr
${
num
}
+ 7
`
echo
"注释掉第
${
num1
}
行到
${
num6
}
行"
sed
-i
"
${
num1
}
i/*"
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaValidateAdvisor.java
sed
-i
"
${
num6
}
i*/"
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaValidateAdvisor.java
fi
if
[[
"
$module
"
=
"xyqb"
||
"
$module
"
=
"pay-center"
||
"
$module
"
=
"han-gu-guan"
||
"
$module
"
=
"di-ting"
||
"
$module
"
=
"xyqb-offline"
||
"
$module
"
=
"xyqb-user"
]]
;
then
echo
"module is
${
module
}
, need replace sms jar version from 1.0.x to 1.0.2"
num
=
`
grep
-n
-A12
"<id>test</id>"
pom.xml|
grep
"<version>"
|
awk
-F-
'{print $1}'
`
if
[[
"
$host
"
=
"192.168.10.2"
]]
;
then
sed
-i
''
$num
's/1.0.[0-9]-SNAPSHOT/1.0.2-SNAPSHOT/'
pom.xml
else
sed
-i
"
${
num
}
s/1.0.[0-9]-SNAPSHOT/1.0.6-SNAPSHOT/"
pom.xml
fi
fi
if
[[
"
$module
"
=
"du-jiang-yan"
]]
;
then
num
=
`
grep
-n
-A3
"<artifactId>fund-manage-sdk</artifactId>"
pom.xml|
grep
"<version>"
|
awk
-F-
'{print $1}'
`
sed
-i
"
${
num
}
s/1.0.[0-9]-SNAPSHOT/1.0.0.
${
suffix
}
-SNAPSHOT/"
pom.xml
sed
-i
"
${
num
}
s/1.0.[0-9].[0-9]/1.0.0.
${
suffix
}
-SNAPSHOT/"
pom.xml
fi
echo
"mvn clean package -P
${
config_profile
}
-Dmaven.test.skip=true"
mvn clean package
-P
${
config_profile
}
-Dmaven
.test.skip
=
true
mkdir
-p
/home/quant_group/deploy_backup
\c
p
-f
target/
*
.jar /home/quant_group/deploy_backup/
exit
$?
execu-utils/center/2_build_ui.sh
0 → 100644
View file @
1fc30555
# -------------------------------------------------------------------------------
# Filename: java_deploy.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本负责build UI项目。
# Usage:used by ../deploy/ui_deploy.sh
# -------------------------------------------------------------------------------
source
~/.bash_profile
module_name
=
$1
npm_install
=
$2
ui_sys_type
=
$3
bower_install
=
false
build_cmd
=
"npm run build"
conf_file
=
src/js/config.env.js
# xyqb-ui do bower install --allow-root 需要手动选择版本号
# 所有的“系统”,如:谛听,财务等,都需要bower install
if
[[
"
${
ui_sys_type
}
"
=
"management_sys"
]]
;
then
bower_install
=
true
if
[[
"
${
module_name
}
"
=
"di-ting-ui"
]]
;
then
conf_file
=
client/app/config.js
build_cmd
=
"grunt build"
else
conf_file
=
src/js/env.config.js
build_cmd
=
"npm run build"
fi
elif
[[
"
${
ui_sys_type
}
"
=
"business_sys"
]]
;
then
if
[[
"
${
module_name
}
"
=
"xyqb-ui"
]]
;
then
bower_install
=
true
conf_file
=
client/app/config.js
build_cmd
=
"grunt build"
elif
[[
"
${
module_name
}
"
=
"qgbc-ui"
]]
;
then
bower_install
=
false
conf_file
=
src/app/config/env.config.js
build_cmd
=
"npm run build_production"
elif
[[
"
${
module_name
}
"
=
"spider-center-ui"
]]
;
then
bower_install
=
false
conf_file
=
src/app/config/env.config.js
build_cmd
=
"npm run qa"
elif
[[
"
${
module_name
}
"
=
"xyqb-user-ui"
]]
;
then
bower_install
=
false
conf_file
=
src/app/config.js
build_cmd
=
"npm run qa"
elif
[[
"
${
module_name
}
"
=
"activity-ui"
]]
;
then
# vue2.0 will use the same config of activity-ui
bower_install
=
false
conf_file
=
src/app/config.js
build_cmd
=
"npm run build"
else
bower_install
=
false
conf_file
=
src/app/config/env.config.js
build_cmd
=
"npm run build"
fi
else
echo
"Error! Please config ui_sys_type: business_sys or management_sys."
fi
echo
"module_name is
${
module_name
}
"
ts
=
`
date
+%s
`
echo
"curl http://oeazjz3gi.bkt.clouddn.com/qa.
${
module_name
}
.config.js?random=
${
ts
}
-o new.config.js"
curl http://oeazjz3gi.bkt.clouddn.com/qa.
${
module_name
}
.config.js?random
=
${
ts
}
-o
new.config.js
if
[
$?
=
0
]
;
then
echo
"get config file is ok."
else
echo
"Error: Fail to get config file."
exit
-1
fi
mv
-f
new.config.js
$conf_file
if
[
"
$npm_install
"
=
true
]
;
then
echo
"npm_install is
${
npm_install
}
"
npm
install
if
[
$?
=
0
]
;
then
echo
npm package ok!
else
echo
npm package have something wrong
!!!!!!!!
exit
-1
fi
if
[[
"
$bower_install
"
=
true
]]
;
then
echo
"bower_install is
${
bower_install
}
"
bower
-v
bower
install
--allow-root
fi
else
echo
"skip npm install"
fi
echo
"use
$build_cmd
to build ui"
$build_cmd
echo
"Create tgz package"
tar
cfz ./
${
module_name
}
_dist.tar.gz ./dist
if
[
$?
=
0
]
;
then
echo
"tar package ok!"
else
echo
"Error: fail to tar package."
exit
-1
fi
echo
"mkdir -p /home/quant_group/deploy_backup"
mkdir
-p
/home/quant_group/deploy_backup
echo
"rm -f /home/quant_group/deploy_backup/
${
module_name
}
_dist.tar.gz"
rm
-f
/home/quant_group/deploy_backup/
${
module_name
}
_dist.tar.gz
echo
"cp
${
module_name
}
_dist.tar.gz /home/quant_group/deploy_backup/"
cp
${
module_name
}
_dist.tar.gz /home/quant_group/deploy_backup/
exit
$?
execu-utils/center/3_remote_copy.sh
0 → 100644
View file @
1fc30555
# -------------------------------------------------------------------------------
# Filename: java_deploy.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本远程copy ui,js, 和java项目。
# Usage:used by ../deploy/*_deploy.sh
# -------------------------------------------------------------------------------
module_name
=
$1
target_host
=
$2
module_type
=
$3
if
[[
"
${
module_name
}
"
=
"han-gu-guan"
]]
then
package_name
=
"xyqb-openauth-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"di-ting"
]]
then
package_name
=
"xyqb-di_ting-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"jian-men-guan"
]]
then
package_name
=
"risk-control-auth-1.0-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"du-jiang-yan"
]]
then
package_name
=
"du-jiang-yan-1.0-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"financial-system"
]]
then
package_name
=
"xyqb-financial_system-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"mall"
]]
then
package_name
=
"xyqb-mall-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"quartz"
]]
then
package_name
=
"xyqb-quartz-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"xyqb-user"
]]
then
package_name
=
"xyqb-user2-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"red-packet"
]]
then
package_name
=
"redpacket-0.0.1-SNAPSHOT.jar"
else
if
[[
"
${
module_type
}
"
=
"java"
]]
then
package_name
=
"
${
module_name
}
-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_type
}
"
=
"ui"
]]
then
package_name
=
"
${
module_name
}
_dist.tar.gz"
else
echo
"ERROR: module type:
${
module_type
}
does not exist!"
exit
-1
fi
fi
echo
"copy module:
${
package_name
}
to host:
$target_host
"
scp /home/quant_group/deploy_backup/
${
package_name
}
root@
${
target_host
}
:/home/quant_group/deploy_backup/
echo
"ssh root@
${
target_host
}
mkdir -p /home/quant_group/
${
module_name
}
"
ssh root@
${
target_host
}
mkdir
-p
/home/quant_group/
${
module_name
}
echo
"ssh root@
${
target_host
}
cp /home/quant_group/deploy_backup/
${
package_name
}
/home/quant_group/
${
module_name
}
/"
ssh root@
${
target_host
}
cp
/home/quant_group/deploy_backup/
${
package_name
}
/home/quant_group/
${
module_name
}
/
execu-utils/center/4_java_restart.sh
0 → 100644
View file @
1fc30555
# -------------------------------------------------------------------------------
# Filename: java_deploy.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本通过远程调用工作机器的脚本,来实现java项目的start和stop。
# Usage:used by ../deploy/java_deploy.sh
# -------------------------------------------------------------------------------
echo
"java_restart.sh parameter: module_name:
${
1
}
, host:
${
2
}
, re_load_config:
${
3
}
"
module_name
=
$1
host
=
$2
re_load_config
=
$3
use_pulic_ip
=
$4
port
=
22
user
=
"root"
password
=
"!QAZ2wsx"
package_path
=
"/home/quant_group/
${
module_name
}
"
shutils_path
=
"/home/quant_group/qa-deploy-utils/sh-utils"
ack_phrase
=
"Started
\
Bootstrap"
max_wait_log_generate_time
=
50
max_wait_ack_time
=
500
if
[[
"
${
module_name
}
"
=
"di-ting"
]]
then
log_path
=
/home/quant_group/logs/di_ting.log
elif
[[
"
${
module_name
}
"
=
"jian-men-guan"
]]
then
log_path
=
/home/quant_group/logs/jian_men_guan.log
elif
[[
"
${
module_name
}
"
=
"du-jiang-yan"
]]
then
log_path
=
/home/quant_group/logs/du_jiang_yan.log
elif
[[
"
${
module_name
}
"
=
"financial-system"
]]
then
log_path
=
/home/quant_group/logs/financial_system.log
elif
[[
"
${
module_name
}
"
=
"xyqb-offline"
]]
then
log_path
=
/home/quant_group/logs/xyqb_offline.log
elif
[[
"
${
module_name
}
"
=
"red-packet"
]]
then
log_path
=
/home/quant_group/logs/redpacket.log
elif
[[
"
${
module_name
}
"
=
"fund-manage"
]]
then
log_path
=
/home/quant_group/logs/fund_manage.log
elif
[[
"
${
module_name
}
"
=
"cash-loan-flow"
]]
then
log_path
=
/home/quant_group/logs/cash_loan_flow.log
elif
[[
"
${
module_name
}
"
=
"xyqb-user"
]]
then
log_path
=
/home/quant_group/logs/xyqb_user.log
else
log_path
=
/home/quant_group/logs/
${
module_name
}
.log
fi
echo
"Step 4.1 stop java"
ssh root@
${
host
}
sh
${
shutils_path
}
/worker/java_stop.sh
${
module_name
}
sleep
5
if
[
$?
-ne
0
]
then
echo
"Fail to stop"
fi
timestamp_log
=
`
date
+%Y-%m-%d.%H%M%S
`
echo
"Step 4.2 backup log"
ssh root@
${
host
}
mv
${
log_path
}
${
log_path
}
.
${
timestamp_log
}
echo
"Step 4.3 start java"
ssh root@
${
host
}
sh
${
shutils_path
}
/worker/java_start.sh
${
module_name
}
$host
"
${
re_load_config
}
"
"
${
use_pulic_ip
}
"
if
[
$?
-ne
0
]
then
echo
"Fail to start"
fi
echo
"Step 4.4 check logs:waiting for
${
ack_phrase
}
"
ssh root@
${
host
}
sh
${
shutils_path
}
/worker/log_check.sh
"
${
ack_phrase
}
"
${
log_path
}
${
max_wait_log_generate_time
}
${
max_wait_ack_time
}
execu-utils/center/copy_java.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
jenkins_host
=
192.168.192.191
target_host
=
$1
function
copy_to
()
{
module
=
$1
scp /home/quant_group/jenkins/workspace/update_test-config-manager/
${
module
}
.
${
target_host
}
.tgz root@
${
target_host
}
:/home/quant_group/deploy_backup/
${
module
}
/
scp /home/quant_group/jenkins/workspace/build_
${
module
}
/target/
*
.jar root@
${
target_host
}
:/home/quant_group/deploy_backup/
${
module
}
/
}
if
[[
"
${
module_name
}
"
=
"ALL"
]]
then
modules
=
'di-ting du-jiang-yan han-gu-guan jian-men-guan mall pay-center quartz xyqb'
for
module
in
$modules
do
copy_to
${
module
}
echo
${
module
}
done
elif
[[
"
${
module_name
}
"
=
""
]]
then
echo
'Fail module name is empty'
exit
-1
else
copy_to
${
module_name
}
echo
${
module_name
}
fi
\ No newline at end of file
execu-utils/center/copy_ui.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
module_name
=
$1
target_host
=
$2
jenkins_host
=
192.168.192.191
target_host
=
$target_host
function
copy_to
()
{
module
=
$1
module_path
=
/home/quant_group/jenkins/workspace/build_
${
module
}
/dist.tar.gz
if
[[
-f
${
module_path
}
]]
then
scp /home/quant_group/jenkins/workspace/build_
${
module
}
/dist.tar.gz root@
${
target_host
}
:/home/quant_group/deploy_backup/
${
module
}
/
else
echo
'${module}/dist.tar.gz does not exit'
exit
-1
fi
}
if
[[
"
${
module_name
}
"
=
"ALL"
]]
then
modules
=
'di-ting-ui xyqb-ui pay-center-ui'
for
module
in
$modules
do
copy_to
${
module
}
echo
${
module
}
done
elif
[[
"
${
module_name
}
"
=
""
]]
then
echo
'Fail module name is empty'
exit
-1
else
copy_to
${
module_name
}
echo
${
module_name
}
fi
\ No newline at end of file
execu-utils/center/copy_utils.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
jenkins_host
=
192.168.192.191
target_host
=
$target_host
module_name
=
test-utils
mkdir
-p
/home/quant_group/deploy_backup
backup_path
=
/home/quant_group/deploy_backup
echo
job name is
${
module_name
}
if
[
-f
${
backup_path
}
/
${
module_name
}
.tar.gz
]
then
rm
${
backup_path
}
/
${
module_name
}
.tar.gz
fi
#
echo tar
cfz
${
backup_path
}
/
${
module_name
}
.tar.gz ../
${
JOB_NAME
}
tar
cfz
${
backup_path
}
/
${
module_name
}
.tar.gz ../
${
JOB_NAME
}
if
[
-f
${
backup_path
}
/
${
JOB_NAME
}
]
then
rm
-rf
${
backup_path
}
/
${
JOB_NAME
}
fi
tar
zxf
${
backup_path
}
/
${
JOB_NAME
}
.tar.gz
-C
${
backup_path
}
/
${
JOB_NAME
}
function
copy_to
()
{
host
=
$1
scp /home/quant_group/deploy_backup/
${
module_name
}
.tar.gz root@
${
host
}
:/home/quant_group/deploy_backup/
}
if
[[
"
${
target_host
}
"
=
"ALL"
]]
then
hosts
=
'di-ting du-jiang-yan han-gu-guan jian-men-guan mall pay-center quartz xyqb'
for
host
in
$hosts
do
copy_to
${
host
}
echo
${
host
}
done
elif
[[
"
${
target_host
}
"
=
""
]]
then
echo
'Fail module name is empty'
exit
-1
else
copy_to
${
target_host
}
echo
${
target_host
}
fi
\ No newline at end of file
execu-utils/center/database_backup.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
# -------------------------------------------------------------------------------
# Filename: database_backup.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本从线上从库备份数据库。
# Usage:used by ../deploy/database_sync.sh
# -------------------------------------------------------------------------------
source
~/.bash_profile
database_name
=
$1
user_name
=
'xyqb_query'
password
=
'Uiwb@o^fR&nHOa5t'
host
=
'192.168.4.253'
db_backup
=
$2
date_str
=
`
date
"+%Y-%m-%d-%H"
`
backfilename
=
${
database_name
}
_back_
${
date_str
}
.sql
ingore_tables_str
=
''
mkdir
-p
$db_backup
if
[[
$database_name
=
'xyqb'
]]
;
then
# 信用钱包database
# repay v_manifest v_repay 是view类型的
# secure_proxy 表里面的数据需要被同步
sys_table_list
=
'baitiao_merchant baitiao_secure_key channel funding_contract funding_corp loan_product merchant_channel payeco_return_url_info red_packet t_phonenum zmxy_return_url configuration repay v_manifest v_repay secure_proxy'
port
=
'3306'
elif
[[
$database_name
=
'xyqb_app'
]]
;
then
# app-backend使用的数据库
sys_table_list
=
'activities app_banners app_config app_versions banners blanknote_entries credit_questions hot_games loan_banners loan_questions migrations sharings widgets'
port
=
'3307'
elif
[[
$database_name
=
'payment_center'
]]
;
then
# 支付中心
sys_table_list
=
'card_switcher merchant merchant_config pay_approach_config'
port
=
'3308'
elif
[[
$database_name
=
'risk_control'
]]
;
then
# 谛听database
sys_table_list
=
'company product_strategy_dispatcher quantify_product red_packet_info socketio_init_parameters user'
port
=
'3309'
elif
[[
$database_name
=
'dujiangyan'
]]
;
then
# dujiangyan
sys_table_list
=
'baitiao_secure_key external_coopr'
port
=
'3310'
elif
[[
$database_name
=
'mall'
]]
;
then
# 白条商城
sys_table_list
=
'activity_3c_product ad_detail new_3c_product supplier 3c_product 3c_product_spec apix_phone_recharge_detail apix_recharge_project apix_recharge_project_bak category configuration course_detail_info course_info merchant pay19_recharge_project product'
port
=
'3310'
elif
[[
$database_name
=
'qinqiong'
]]
;
then
# qinqiong
sys_table_list
=
'secure_key secure_proxy'
port
=
'3310'
elif
[[
$database_name
=
'quartz'
]]
;
then
# 定时任务
sys_table_list
=
'certain_time_job'
port
=
'3310'
elif
[[
$database_name
=
'contract'
]]
;
then
# 合同
sys_table_list
=
''
port
=
'3311'
elif
[[
$database_name
=
'financial_system'
]]
;
then
# 财务系统
sys_table_list
=
'collection_user sys_dictionary sys_status_edge sys_status_transfer_data_record sys_status_transfer_record sys_status_vertice'
port
=
'3311'
elif
[[
$database_name
=
'gyxd'
]]
;
then
# 广源小贷系统
sys_table_list
=
'collection_user sys_dictionary sys_status_edge sys_status_transfer_data_record sys_status_transfer_record sys_status_vertice'
port
=
'3311'
elif
[[
$database_name
=
'offline'
]]
;
then
# 线下白条
sys_table_list
=
'goods_detail merchant operator_user'
port
=
'3311'
elif
[[
$database_name
=
'sms-center'
]]
;
then
# 短信中心
sys_table_list
=
'current_index merchant merchant_config sms_content sms_platform'
port
=
'3311'
elif
[[
$database_name
=
'spider_center'
]]
;
then
# 授信中心
sys_table_list
=
'merchant merchant_config'
port
=
'3312'
elif
[[
$database_name
=
'xyqb_user'
]]
;
then
# 用户中心
sys_table_list
=
'merchant merchant_config'
port
=
'3312'
fi
if
[
!
-f
"
$backfilename
"
]
;
then
echo
"
$backfilename
does not exit, skip remove
$backfilename
"
else
echo
"rm -f
$backfilename
"
rm
-f
$backfilename
fi
for
table_name
in
$sys_table_list
do
if
[[
$table_name
=
'repay'
||
$table_name
=
'v_manifest'
||
$table_name
=
'v_repay'
]]
;
then
echo
"skip view table
$table_name
"
else
mysqldump
-u
${
user_name
}
-p
${
password
}
-h
${
host
}
-P
${
port
}
--skip-lock-tables
--databases
$database_name
--tables
$table_name
>>
${
db_backup
}
/
${
backfilename
}
fi
ingore_tables_str+
=
" --ignore-table=
${
database_name
}
.
${
table_name
}
"
done
echo
$ingore_tables_str
echo
"mysqldump -u
${
user_name
}
-p
${
password
}
-h
${
host
}
-P
${
port
}
--databases
$database_name
--no-data
$ingore_tables_str
>>
$backfilename
"
mysqldump
-u
${
user_name
}
-p
${
password
}
-h
${
host
}
-P
${
port
}
--skip-lock-tables
--databases
$database_name
--no-data
$ingore_tables_str
--skip-add-locks
>>
${
db_backup
}
/
${
backfilename
}
\c
p
-f
${
db_backup
}
/
${
backfilename
}
${
db_backup
}
/
${
database_name
}
_latest.sql
execu-utils/center/database_import.sh
0 → 100644
View file @
1fc30555
# -------------------------------------------------------------------------------
# Filename: database_replace_ip.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: sync数据库。
# Usage:used by ../deploy/database_sync.sh
# -------------------------------------------------------------------------------
database_name
=
$1
mysql_host
=
$2
db_backup
=
$3
if
[
!
-f
${
db_backup
}
/
${
database_name
}
_
${
mysql_host
}
.sql
]
;
then
echo
"ERROR: skip import DB, because
${
database_name
}
_
${
mysql_host
}
.sql does not exit!"
exit
-1
else
cd
$db_backup
if
[[
"
${
database_name
}
"
=
"sms-center"
]]
then
echo
"DROP DATABASE
\`
sms-center
\`
"
>
${
database_name
}
_drop.sql
echo
"CREATE DATABASE IF NOT EXISTS
\`
sms-center
\`
DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
>
${
database_name
}
_create.sql
else
echo
"DROP DATABASE
${
database_name
}
"
>
${
database_name
}
_drop.sql
echo
"CREATE DATABASE IF NOT EXISTS
${
database_name
}
DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
>
${
database_name
}
_create.sql
fi
echo
"mysql -h
$mysql_host
-u qa -pqatest
$database_name
<
${
database_name
}
_drop.sql"
mysql
-h
$mysql_host
-u
qa
-pqatest
$database_name
<
${
database_name
}
_drop.sql
echo
"mysql -h
$mysql_host
-u qa -pqatest <
${
database_name
}
_create.sql"
mysql
-h
$mysql_host
-u
qa
-pqatest
<
${
database_name
}
_create.sql
echo
"mysql -h
$mysql_host
-u qa -pqatest
$database_name
<
${
database_name
}
_
${
mysql_host
}
.sql"
mysql
-h
$mysql_host
-u
qa
-pqatest
$database_name
<
${
database_name
}
_
${
mysql_host
}
.sql
fi
execu-utils/center/database_replace_ip.sh
0 → 100644
View file @
1fc30555
# -------------------------------------------------------------------------------
# Filename: database_replace_ip.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本根据备份sql称特定环境使用的sql,例如:xyqb_192.168.4.3。
# Usage:used by ../deploy/database_sync.sh
# -------------------------------------------------------------------------------
database_name
=
$1
mysql_host
=
$2
prefix
=
$((${
mysql_host
:10
}))
server_host
=
192.168.4.
${
prefix
}
db_backup
=
$3
use_public_ip
=
$4
public_ip
=
"139.198.2.95"
echo
$server_host
cd
$db_backup
cp
${
database_name
}
_latest.sql
${
database_name
}
_
${
mysql_host
}
.sql
# mac
# sed -i '' "s/http\:\/\/m.xyqb.com/http\:\/\/${server_host}:7001/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/bt.xyqb.com/http\:\/\/${server_host}:7002/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/api.xyqb.com/http\:\/\/${server_host}:7003/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/r.xyqb.com/http\:\/\/${server_host}:7004/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/rapi.xyqb.com/http\:\/\/${server_host}:7005/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/payapi.xyqb.com/http\:\/\/${server_host}:7006/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/pay.xyqb.com/http\:\/\/${server_host}:7007/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/off.xyqb.com/http\:\/\/${server_host}:7008/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/offapi.xyqb.com/http\:\/\/${server_host}:7010/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/financial.xyqb.com/http\:\/\/${server_host}:7011/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/fsapi.xyqb.com/http\:\/\/${server_host}:7012/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/auth.xyqb.com/http\:\/\/${server_host}:7013/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/qapi.xyqb.com/http\:\/\/${server_host}:7014/g" ${database_name}_${mysql_host}.sql
# sed -i '' "s/http\:\/\/mallapi.xyqb.com/http\:\/\/${server_host}:7019/g" ${database_name}_${mysql_host}.sql
# linux
sed
-i
"s/http
\:\/\/
m.xyqb.com/http
\:\/\/
${
server_host
}
:7001/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
m.xyqb.com/http
\:\/\/
${
server_host
}
:7001/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
bt.xyqb.com/http
\:\/\/
${
server_host
}
:7002/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
bt.xyqb.com/http
\:\/\/
${
server_host
}
:7002/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
api.xyqb.com/http
\:\/\/
${
server_host
}
:7003/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
api.xyqb.com/http
\:\/\/
${
server_host
}
:7003/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
r.xyqb.com/http
\:\/\/
${
server_host
}
:7004/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
r.xyqb.com/http
\:\/\/
${
server_host
}
:7004/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
rapi.xyqb.com/http
\:\/\/
${
server_host
}
:7005/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
rapi.xyqb.com/http
\:\/\/
${
server_host
}
:7005/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
payapi.xyqb.com/http
\:\/\/
${
server_host
}
:7006/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
payapi.xyqb.com/http
\:\/\/
${
server_host
}
:7006/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
pay.xyqb.com/http
\:\/\/
${
server_host
}
:7007/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
pay.xyqb.com/http
\:\/\/
${
server_host
}
:7007/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
off.xyqb.com/http
\:\/\/
${
server_host
}
:7008/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
off.xyqb.com/http
\:\/\/
${
server_host
}
:7008/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
offapi.xyqb.com/http
\:\/\/
${
server_host
}
:7010/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
offapi.xyqb.com/http
\:\/\/
${
server_host
}
:7010/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
financial.xyqb.com/http
\:\/\/
${
server_host
}
:7011/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
financial.xyqb.com/http
\:\/\/
${
server_host
}
:7011/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
fsapi.xyqb.com/http
\:\/\/
${
server_host
}
:7012/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
fsapi.xyqb.com/http
\:\/\/
${
server_host
}
:7012/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
auth.xyqb.com/http
\:\/\/
${
server_host
}
:7013/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
auth.xyqb.com/http
\:\/\/
${
server_host
}
:7013/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
qapi.xyqb.com/http
\:\/\/
${
server_host
}
:7014/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
qapi.xyqb.com/http
\:\/\/
${
server_host
}
:7014/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
mallapi.xyqb.com/http
\:\/\/
${
server_host
}
:7019/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
mallapi.xyqb.com/http
\:\/\/
${
server_host
}
:7019/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
scapi.xyqb.com/http
\:\/\/
${
server_host
}
:7021/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
scapi.xyqb.com/http
\:\/\/
${
server_host
}
:7021/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/http
\:\/\/
gyxdapi.xyqb.com/http
\:\/\/
${
server_host
}
:7029/g"
${
database_name
}
_
${
mysql_host
}
.sql
sed
-i
"s/https
\:\/\/
gyxdapi.xyqb.com/http
\:\/\/
${
server_host
}
:7029/g"
${
database_name
}
_
${
mysql_host
}
.sql
if
[[
"
${
use_public_ip
}
"
=
true
]]
;
then
echo
"replace private ip to public ip"
if
[
$prefix
-lt
100
]
;
then
echo
"prefix < 100,
${
prefix
}
"
sed
-i
"s/
${
server_host
}
:7/
${
public_ip
}
:
${
prefix
}
/g"
${
database_name
}
_
${
mysql_host
}
.sql
else
echo
"prefix >= 100,
${
prefix
}
"
sed
-i
"s/
${
server_host
}
:70/
${
public_ip
}
:
${
prefix
}
/g"
${
database_name
}
_
${
mysql_host
}
.sql
fi
else
echo
"use_public_ip is false, skip replace ip to public ip."
fi
execu-utils/center/generate_properties.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
server_host
=
$1
# server_host=172.16.10.1
# module_name=xyqb
module_name
=
$2
public_host
=
139.198.2.239
basic_host
=
172.16.10.2
mysql_host
=
172.16.10.5
cd
/home/quant_group/jenkins/workspace/update_test-config-manager/
rm
-rf
${
module_name
}
.
${
server_host
}
cp
-rf
${
module_name
}
${
module_name
}
.
${
server_host
}
cd
${
module_name
}
.
${
server_host
}
# 替换mysql数据库账户
sed
-i
"s/192.168.192.191/
${
mysql_host
}
/g"
*
.properties
sed
-i
"s/spring.datasource.username=root/spring.datasource.username=quantgroup/g"
*
.properties
sed
-i
"s/spring.datasource.password=qatest/spring.datasource.password=quaNtGroup2011/g"
*
.properties
# 替换redis数据库账户
sed
-i
"s/redis.master.host=192.168.192.206/redis.master.host=
${
basic_host
}
/g"
*
.properties
sed
-i
"s/redis.master.port=6370/redis.master.port=6371/g"
*
.properties
# 替换rabbitmq账户
sed
-i
"s/rabbitmq.connection.host=192.168.192.243/rabbitmq.connection.host=
${
basic_host
}
/g"
*
.properties
sed
-i
"s/rabbitmq.connection.port=5672/rabbitmq.connection.port=5671/g"
*
.properties
sed
-i
"s/rabbitmq.connection.user=rabbit_admin/rabbitmq.connection.user=qa/g"
*
.properties
sed
-i
"s/rabbitmq.connection.password=abc1234/rabbitmq.connection.password=qatest/g"
*
.properties
sed
-i
"s/192.168.192.190/
${
server_host
}
/g"
*
.properties
sed
-i
"s/61.50.125.14/
${
public_host
}
/g"
*
.properties
cd
..
rm
-rf
${
module_name
}
.
${
server_host
}
.tgz
tar
zcf
${
module_name
}
.
${
server_host
}
.tgz
${
module_name
}
.
${
server_host
}
\ No newline at end of file
execu-utils/center/prepare_for_copy_java.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
mkdir
-p
/home/quant_group/deploy_backup
function
clean_backup
()
{
module
=
$1
mkdir
-p
/home/quant_group/deploy_backup/
${
module
}
echo cd
/home/quant_group/deploy_backup/
${
module
}
cd
/home/quant_group/deploy_backup/
${
module
}
rm
-rf
*
}
if
[[
"
${
module_name
}
"
=
"ALL"
]]
then
modules
=
'di-ting du-jiang-yan han-gu-guan jian-men-guan mall pay-center quartz xyqb'
for
module
in
$modules
do
clean_backup
${
module
}
echo
${
module
}
done
elif
[[
"
${
module_name
}
"
=
""
]]
then
echo
'Fail module name is empty'
exit
-1
else
clean_backup
${
module_name
}
echo
${
module_name
}
fi
\ No newline at end of file
execu-utils/deploy/check_file_diff.js
0 → 100644
View file @
1fc30555
var
source_file
,
java_config_path
,
L
,
key
,
value
,
FL
var
IP_REG
=
new
RegExp
(
/
((?:(?:
25
[
0-5
]
|2
[
0-4
]\d
|
((
1
\d{2})
|
([
1-9
]?\d)))\.){3}(?:
25
[
0-5
]
|2
[
0-4
]\d
|
((
1
\d{2})
|
([
1-9
]?\d))))
/g
);
process
.
argv
.
forEach
(
function
(
val
,
index
,
array
)
{
if
(
index
==
2
){
source_file
=
val
;
}
else
{
java_config_path
=
val
;
}
});
console
.
log
(
"
本地配置文件:%s
"
,
source_file
)
console
.
log
(
"
项目配置文件:%s
"
,
java_config_path
)
function
getNowFormatDate
()
{
var
date
=
new
Date
();
var
seperator1
=
"
-
"
;
var
seperator2
=
"
:
"
;
var
month
=
date
.
getMonth
()
+
1
;
var
strDate
=
date
.
getDate
();
if
(
month
>=
1
&&
month
<=
9
)
{
month
=
"
0
"
+
month
;
}
if
(
strDate
>=
0
&&
strDate
<=
9
)
{
strDate
=
"
0
"
+
strDate
;
}
var
currentdate
=
date
.
getFullYear
()
+
seperator1
+
month
+
seperator1
+
strDate
+
"
"
+
date
.
getHours
()
+
seperator2
+
date
.
getMinutes
()
+
seperator2
+
date
.
getSeconds
();
return
currentdate
;
}
var
list_source_file_keys
=
{},
diff_list
=
[],
value_of_diff_change
;
var
java_config_data
,
java_config_data_lines
;
var
fs
=
require
(
"
fs
"
);
var
path
=
require
(
'
path
'
);
var
list_source_file_data
=
fs
.
readFileSync
(
source_file
,
'
utf-8
'
);
var
lines
=
list_source_file_data
.
split
(
"
\n
"
)
for
(
var
i
=
0
;
i
<
lines
.
length
;
++
i
)
{
L
=
lines
[
i
].
split
(
"
=
"
)
key
=
L
[
0
]
value
=
L
[
1
]
FL
=
L
[
0
].
replace
(
/
\s
/g
,
""
);
if
(
FL
[
0
]
!=
"
#
"
&&
FL
.
length
!=
0
){
list_source_file_keys
[
L
[
0
]]
=
L
[
1
];
}
}
fs
.
readdir
(
java_config_path
,
function
(
err
,
files
){
var
count
=
files
.
length
;
files
.
forEach
(
function
(
filename
){
if
(
filename
.
indexOf
(
"
.properties
"
)
!=
-
1
){
var
java_config_data
=
fs
.
readFileSync
(
path
.
join
(
java_config_path
,
filename
),
'
utf-8
'
);
var
java_config_data_lines
=
java_config_data
.
split
(
"
\n
"
)
for
(
var
i
=
0
;
i
<
java_config_data_lines
.
length
;
++
i
)
{
L
=
java_config_data_lines
[
i
].
split
(
"
=
"
)
key
=
L
[
0
]
value
=
L
[
1
]
FL
=
L
[
0
].
replace
(
/
\s
/g
,
""
);
if
(
FL
[
0
]
!=
"
#
"
&&
FL
.
length
!=
0
){
if
(
typeof
list_source_file_keys
[
L
[
0
]]
==
"
undefined
"
){
console
.
log
(
"
Warning!!!:
\"
%s
\"\t
"
,
L
[
0
]);
diff_list
.
push
({
name
:
L
[
0
],
value
:
L
[
1
]})
}
}
}
}
})
if
(
diff_list
.
length
>
0
){
fs
.
appendFile
(
source_file
,
"
#时间:
"
+
getNowFormatDate
()
+
"
,差异追加如下:
\n
"
);
}
for
(
var
i
=
0
;
i
<
diff_list
.
length
;
++
i
){
if
(
IP_REG
.
test
(
diff_list
[
i
].
value
))
{
IP_REG
.
lastIndex
=
0
;
fs
.
appendFile
(
source_file
,
"
#
"
+
diff_list
[
i
].
name
+
"
=
"
+
diff_list
[
i
].
value
+
"
\n
"
);
value_of_diff_change
=
diff_list
[
i
].
value
.
replace
(
/
((?:(?:
25
[
0-5
]
|2
[
0-4
]\d
|
((
1
\d{2})
|
([
1-9
]?\d)))\.){3}(?:
25
[
0-5
]
|2
[
0-4
]\d
|
((
1
\d{2})
|
([
1-9
]?\d))))
/g
,
"
localhost
"
)
fs
.
appendFile
(
source_file
,
diff_list
[
i
].
name
+
"
=
"
+
value_of_diff_change
+
"
\n
"
);
}
else
{
fs
.
appendFile
(
source_file
,
diff_list
[
i
].
name
+
"
=
"
+
diff_list
[
i
].
value
+
"
\n
"
);
}
}
})
execu-utils/deploy/database_sync.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
# -------------------------------------------------------------------------------
# Filename: database_sync.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本调用其他脚本实现测试数据库的同步
# -------------------------------------------------------------------------------
source
~/.bash_profile
echo
"部署参数:database_name:
$1
, mysql_host:
$2
, re_dumpDB?:
$3
, re_replace_ip?:
$4
, re_importDB?
$5
"
database_name
=
$1
mysql_host
=
$2
re_dumpDB
=
$3
re_replace_ip
=
$4
re_importDB
=
$5
use_public_ip
=
$6
work_path
=
/home/quant_group
# work_path=/Users/eileen/QG/dev
db_backup
=
$work_path
/db_backup
utils_path
=
$work_path
/qa-deploy-utils
function
database_ops
()
{
database
=
$1
echo
$database
if
[
"
$re_dumpDB
"
=
true
]
;
then
echo
"Step 1: dumpDB:
$database
"
sh
${
utils_path
}
/sh-utils/center/database_backup.sh
$database
$db_backup
else
echo
"Step 1: skip dumpDB"
fi
if
[
"
$re_replace_ip
"
=
true
]
;
then
echo
"Step 2: replace domain name in tables:
$database
$mysql_host
"
sh
${
utils_path
}
/sh-utils/center/database_replace_ip.sh
$database
$mysql_host
$db_backup
"
${
use_public_ip
}
"
else
echo
"Step 2: skip replace_ip"
fi
if
[
"
$re_importDB
"
=
true
]
;
then
echo
"Step 3: importDB:
$database
$mysql_host
"
sh
${
utils_path
}
/sh-utils/center/database_import.sh
$database
$mysql_host
$db_backup
else
echo
"Step 3: skip importDB"
fi
}
database_list
=
'xyqb_user xyqb xyqb_app payment_center risk_control dujiangyan mall qinqiong quartz contract financial_system gyxd offline sms-center spider_center'
if
[[
"
${
database_name
}
"
=
"all"
]]
then
echo
"all database"
for
database
in
$database_list
do
database_ops
$database
echo
$database
done
else
database_ops
$database_name
fi
execu-utils/deploy/java_deploy.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
# -------------------------------------------------------------------------------
# Filename: java_deploy.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本调用其他脚本实现java项目的自动化部署。deploy_xyqb,deploy_di-ting等jenkins job使用了该脚本。
# -------------------------------------------------------------------------------
source
~/.bash_profile
echo
"部署参数-1:module name:
$1
, branch name:
$2
, host address:
$3
. "
echo
"部署参数-2:checkout branch again?
$4
, build java again?
$5
, remote copy again?
$6
,restart java project?
$7
, reload configure file?
$8
."
echo
"部署参数-3: allow Picture verification code?
${
10
}
"
module
=
$1
branch_name
=
$2
host
=
$3
checkout_branch
=
$4
build_java
=
$5
remote_copy
=
$6
restart_java
=
$7
re_load_config
=
$8
use_pulic_ip
=
$9
profile
=
test
close_captcha
=
${
10
}
utils_path
=
/home/quant_group/qa-deploy-utils
if
[
"
$checkout_branch
"
=
true
]
;
then
echo
"Step 1: checkout branch:
$branch_name
"
sh
${
utils_path
}
/sh-utils/center/1_branch_checkout.sh
$branch_name
else
echo
"Step 1: skip checkout branch:
$branch_name
"
fi
# 增加文件差异对比 2017-01-15 田亚伟
#echo "Step 1.1: checkout properties files: "
#config_path=`pwd`
#expect -c "
#spawn scp root@${host}:/home/quant_group/${module}/*.properties ./
#expect {
#\"*assword\" {
# send \"!QAZ2wsx\n\"
# }
#}
#expect eof"
#echo "------------------------config_fidd:begin------------------------------"
#echo `node ${utils_path}/sh-utils/deploy/check_file_diff.js ${config_path}/application.properties /home/quant_group/jenkins/workspace/deploy_${module}/src/main/resources/config/test/`
#sed $(echo -e "s/\r//") application.properties > application_last.properties
#echo `pwd`
#expect -c "
#spawn scp ${config_path}/application_last.properties root@${host}:/home/quant_group/${module}/application.properties
#expect {
#\"*assword\" {
# send \"!QAZ2wsx\n\"
# }
#}
#expect eof"
#echo "-------------------------config_fidd:end-------------------------------"
# 增加文件差异对比 结束2017-01-15 田亚伟
if
[
"
$build_java
"
=
true
]
;
then
echo
"Step 2: build project:
$branch_name
"
sh
${
utils_path
}
/sh-utils/center/2_build_java.sh
$profile
$module
$host
$close_captcha
else
echo
"Step 2: skip build project:
$branch_name
"
fi
if
[
"
$remote_copy
"
=
true
]
;
then
echo
"Step 3: remote copy project: "
sh
${
utils_path
}
/sh-utils/center/3_remote_copy.sh
$module
$host
java
else
echo
"Step 3: skip remote copy project"
fi
if
[
"
$restart_java
"
=
true
]
;
then
echo
"Step 4: restart project: "
sh
${
utils_path
}
/sh-utils/center/4_java_restart.sh
$module
$host
"
${
re_load_config
}
"
"
${
use_pulic_ip
}
"
else
echo
"Step 4: skip restart project"
fi
execu-utils/deploy/multiple_deploy.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
# -------------------------------------------------------------------------------
# Filename: multiple_deploy.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本调用其他脚本实现java项目的自动化部署。deploy_xyqb,deploy_di-ting等jenkins job使用了该脚本。
# -------------------------------------------------------------------------------
source
~/.bash_profile
module_type
=
$1
target_host
=
$2
use_public_ip
=
$3
utils_path
=
/home/quant_group/qa-deploy-utils
java_module_list
=
'black-hole di-ting du-jiang-yan financial-system gyxd han-gu-guan jian-men-guan mall pay-center quartz spider-center xyqb xyqb-offline'
if
[[
"
${
module_type
}
"
=
"java"
]]
then
echo
"deploy all java modules"
for
module
in
$java_module_list
do
if
[[
"
${
module
}
"
=
"mall"
]]
;
then
project_name
=
'xyqb-mall'
elif
[[
"
${
module
}
"
=
"pay-center"
]]
;
then
project_name
=
'gu-bei'
else
project_name
=
${
module
}
fi
git clone http://gitabc.xyqb.com/QG/
${
project_name
}
.git
cd
$project_name
# xyqb $branch_name $target_host $re_checkout $re_build $re_scp $re_start $re_load_config
sh
${
utils_path
}
/sh-utils/deploy/java_deploy.sh
$module
master
$target_host
true true true true true
"
${
use_public_ip
}
"
done
elif
[[
"
${
module_type
}
"
=
"ui"
]]
;
then
echo
"deploy all ui modules"
for
module
in
$ui_module_list
do
# xyqb $branch_name $target_host $re_checkout $re_build $re_scp $re_start $re_load_config
sh
${
utils_path
}
/sh-utils/deploy/ui_deploy.sh
$module
master
$target_host
true true true true true
done
elif
[[
"
${
module_type
}
"
=
"python"
]]
;
then
echo
"deploy all python modules"
for
module
in
$python_module_list
do
# xyqb $branch_name $target_host $re_checkout $re_build $re_scp $re_start $re_load_config
sh
${
utils_path
}
/sh-utils/deploy/other_deploy.sh
$module
master
$target_host
true true true true true
done
elif
[[
"
${
module_type
}
"
=
"js"
]]
;
then
echo
"deploy all js modules"
for
module
in
$python_module_list
do
# xyqb $branch_name $target_host $re_checkout $re_build $re_scp $re_start $re_load_config
sh
${
utils_path
}
/sh-utils/deploy/other_deploy.sh
$module
master
$target_host
true true true true true
done
fi
execu-utils/deploy/other_deploy.sh
0 → 100755
View file @
1fc30555
#!/usr/bin/env bash
# -------------------------------------------------------------------------------
# Filename: java_deploy.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本调用其他脚本实现js项目的自动化部署。目前只有deploy_app-backend jenkins job使用了该脚本。
# -------------------------------------------------------------------------------
source
~/.bash_profile
repo_url
=
$1
module_name
=
$2
branch_name
=
$3
target_host
=
$4
checkout_branch
=
$5
remote_copy
=
$6
restart
=
$7
re_load_config
=
$8
work_path
=
/home/quant_group
backup_path
=
/home/quant_group/remote_backup
utils_path
=
/home/quant_group/qa-deploy-utils
echo
"job name is
${
JOB_NAME
}
"
if
[
"
$checkout_branch
"
=
true
]
;
then
echo
"Step 2: checkout branch:
$branch_name
"
if
[
-d
${
module_name
}
]
then
echo
"Step 2.2: rm -rf
${
module_name
}
"
rm
-rf
${
module_name
}
fi
echo
"Step 2.3: git clone
$repo_url
"
git clone
$repo_url
cd
$module_name
sh
${
utils_path
}
/sh-utils/center/1_branch_checkout.sh
$branch_name
else
echo
"Step 2: skip checkout branch:
$branch_name
"
fi
if
[
"
$remote_copy
"
=
true
]
;
then
echo
"Step 3: remote copy project"
cd
..
mkdir
-p
${
backup_path
}
if
[
-f
${
backup_path
}
/
${
module_name
}
.tar.gz
]
then
echo
"Step 3.1: rm -f
${
backup_path
}
/
${
module_name
}
.tar.gz"
rm
-f
${
backup_path
}
/
${
module_name
}
.tar.gz
fi
echo
"Step 3.3: tar cfz
${
backup_path
}
/
${
module_name
}
.tar.gz
${
module_name
}
"
tar
cfz
${
backup_path
}
/
${
module_name
}
.tar.gz
${
module_name
}
echo
"Step 3.4: remote copy"
scp
${
backup_path
}
/
${
module_name
}
.tar.gz root@
${
target_host
}
:/home/quant_group/remote_backup/
else
echo
"Step 3: skip remote copy project:
${
module_name
}
.tar.gz"
fi
if
[
"
$restart
"
=
true
]
;
then
echo
"Step 4: restart"
ssh root@
${
target_host
}
sh
${
utils_path
}
/sh-utils/worker/other_restart.sh
${
module_name
}
$target_host
$re_load_config
else
echo
"Step 4: skip restart"
fi
execu-utils/deploy/ui_deploy.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
# -------------------------------------------------------------------------------
# Filename: java_deploy.sh
# Revision: 1.0
# Date: 2016/09
# Author: Xiaolin.zhu
# Description: 该脚本调用其他脚本实现js项目的自动化部署。目前deploy_xyqb-ui,deploy_di-ting-ui等 jenkins job使用了该脚本。
# -------------------------------------------------------------------------------
source
~/.bash_profile
echo
"部署参数:module name:
$1
, branch name:
$2
, host address:
$3
, checkout branch again?
$4
, build UI again?
$5
, npm and bower install?
$6
, remote copy again?
$7
"
module
=
$1
branch_name
=
$2
host
=
$3
checkout_branch
=
$4
build_ui
=
$5
npm_install
=
$6
remote_copy
=
$7
if
[
-z
$8
]
;
then
ui_sys_type
=
"business_sys"
else
ui_sys_type
=
$8
fi
use_public_ip
=
$9
replace
=
true
utils_path
=
/home/quant_group/qa-deploy-utils
if
[
"
$checkout_branch
"
=
true
]
;
then
echo
"Step 1: checkout branch:
$branch_name
"
sh
${
utils_path
}
/sh-utils/center/1_branch_checkout.sh
$branch_name
else
echo
"Step 1: skip checkout branch:
$branch_name
"
fi
if
[
"
$build_ui
"
=
true
]
;
then
echo
"Step 2: build project:
$branch_name
"
sh
${
utils_path
}
/sh-utils/center/2_build_ui.sh
$module
$npm_install
$ui_sys_type
else
echo
"Step 2: skip build project:
$branch_name
"
fi
if
[
"
$remote_copy
"
=
true
]
;
then
echo
"Step 3: remote copy project. "
sh
${
utils_path
}
/sh-utils/center/3_remote_copy.sh
$module
$host
ui
else
echo
"Step 3: skip remote copy project"
fi
if
[
"
$replace
"
=
true
]
;
then
echo
"Step 4: replace static files and replace ip. "
ssh root@
${
host
}
sh
${
utils_path
}
/sh-utils/worker/ui_replace_ip.sh
$module
$host
$ui_sys_type
"
$use_public_ip
"
else
echo
"Step 4: replace static files and replace ip"
fi
execu-utils/worker/java_start.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
source
~/.bash_profile
module_name
=
$1
worker_host
=
$2
re_load_config
=
$3
use_public_ip
=
$4
public_ip
=
"139.198.2.95"
#basic_no="3"
echo
"java_start parameter: module_name:
${
module_name
}
, worker_host:
${
worker_host
}
, re_load_config:
${
re_load_config
}
, use_public_ip:
${
use_public_ip
}
"
echo
"cd /home/quant_group/
${
module_name
}
/"
cd
/home/quant_group/
${
module_name
}
/
if
[[
"
${
re_load_config
}
"
=
true
]]
;
then
web_no
=
$((${
worker_host
:10
}))
basic_no
=
$((${
worker_host
:10
}))
mysql_no
=
$((${
worker_host
:10
}))
echo
"java_start Run
${
module_name
}
start.sh on
${
worker_host
}
, basic_no is
${
basic_no
}
, mysql_no is
${
mysql_no
}
"
echo
"java_start 1. replace application.properties"
ts
=
`
date
+%s
`
echo
"curl http://oeazjz3gi.bkt.clouddn.com/qa.
${
module_name
}
.application.properties?random=
${
ts
}
-o new.application.properties"
curl http://oeazjz3gi.bkt.clouddn.com/qa.
${
module_name
}
.application.properties?random
=
${
ts
}
-o
new.application.properties
mv
-f
new.application.properties application.properties
if
[[
"
${
use_public_ip
}
"
=
false
]]
;
then
echo
"java_start use_public_ip is:
${
use_public_ip
}
!"
sed
-i
"s/192.168.4.3/
${
worker_host
}
/g"
application.properties
else
echo
"java_start use_public_ip is:
${
use_public_ip
}
!"
if
[
$web_no
-lt
100
]
;
then
echo
"web_no < 100,
${
web_no
}
"
sed
-i
"s/192.168.4.3:7/
${
public_ip
}
:
${
web_no
}
/g"
application.properties
else
echo
"web_no >= 100,
${
web_no
}
"
sed
-i
"s/192.168.4.3:70/
${
public_ip
}
:
${
web_no
}
/g"
application.properties
fi
fi
sed
-i
"s/192.168.4.4/192.168.4.
${
basic_no
}
/g"
application.properties
sed
-i
"s/192.168.4.5/192.168.4.
${
mysql_no
}
/g"
application.properties
else
echo
"java_start 1. Skip replace application.properties"
fi
echo
"java_start 2. java -jar start"
if
[[
"
${
module_name
}
"
=
"xyqb"
]]
then
package_name
=
"xyqb-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"pay-center"
]]
then
package_name
=
"pay-center-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"han-gu-guan"
]]
then
package_name
=
"xyqb-openauth-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"di-ting"
]]
then
package_name
=
"xyqb-di_ting-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"jian-men-guan"
]]
then
package_name
=
"risk-control-auth-1.0-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"du-jiang-yan"
]]
then
package_name
=
"du-jiang-yan-1.0-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"financial-system"
]]
then
package_name
=
"xyqb-financial_system-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"mall"
]]
then
package_name
=
"xyqb-mall-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"quartz"
]]
then
package_name
=
"xyqb-quartz-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"red-packet"
]]
then
package_name
=
"redpacket-0.0.1-SNAPSHOT.jar"
elif
[[
"
${
module_name
}
"
=
"xyqb-user"
]]
then
package_name
=
" xyqb-user2-0.0.1-SNAPSHOT.jar"
else
package_name
=
"
${
module_name
}
-0.0.1-SNAPSHOT.jar"
fi
echo
"java -Xmx512m -XX:PermSize64m -Xloggc:/tmp/
${
module_name
}
_gc.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -jar
${
package_name
}
--worker 1 --currentWorker 1 -t > /dev/null 2>&1 & "
java
-Xmx512m
-XX
:PermSize64m
-Xloggc
:/tmp/
${
module_name
}
_gc.log
-XX
:+PrintGCDetails
-XX
:+PrintGCTimeStamps
-jar
${
package_name
}
--worker
1
--currentWorker
1
-t
>
/dev/null 2>&1 &
if
[
$?
-ne
0
]
then
echo
"Fail to start"
echo
$?
fi
execu-utils/worker/java_stop.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
module_name
=
$1
process
=
`
ps
-ef
|grep java|grep
${
module_name
}
_gc|awk
'{print $2}'
`
if
[
"
$process
"
!=
""
]
;
then
echo
"kill -9
$process
"
kill
-9
$process
else
echo
"
${
module_name
}
process does not exist. Skip kill step!"
fi
execu-utils/worker/log_backup.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
# 切分日志,备份老运行代码
#运行示例
# sh backup.sh code_path log_path package_name module_name
function
back_up
()
{
timestamp
=
`
date
+%Y%m%d-%H%M%S
`
timestamp_log
=
`
date
+%Y-%m-%d.%H%M%S
`
code_path
=
$1
log_path
=
$2
package_name
=
$3
module_name
=
$4
echo
"begin backup: module name:
${
module_name
}
, code path:
${
code_path
}
, log path:
${
log_path
}
, package name:
${
package_name
}
"
echo
"timestamp:
${
timestamp
}
, timestamplog:
${
timestamplog
}
"
back_up_path
=
/home/quant_group/ep/backup/
${
module_name
}
mkdir
-p
${
back_up_path
}
mv
${
code_path
}
${
back_up_path
}
/
${
package_name
}
.
${
timestamp
}
mv
${
log_path
}
${
log_path
}
.
${
timestamp_log
}
}
back_up
$@
exit
0
\ No newline at end of file
execu-utils/worker/log_check.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
function
ack
()
{
ack_phrase
=
"
$1
"
log_path
=
"
$2
"
max_wait_log_generate_time
=
"
$3
"
max_wait_ack_time
=
"
$4
"
wait_log_generate_time
=
0
wait_ack_time
=
0
echo
"begin acknowledge whether the deploy start OK, ACK_PHRASE=
${
ack_phrase
}
, log_path=
${
log_path
}
"
while
[
!
-f
${
log_path
}
]
do
echo
"wait_log_generate_time is
${
wait_log_generate_time
}
, max_wait_log_generate_time is
${
max_wait_log_generate_time
}
"
if
((
${
wait_log_generate_time
}
>
${
max_wait_log_generate_time
}
))
then
echo
"the log generated time exceed the limit"
exit
-1
fi
echo
'the log does not exist, wait for 5 seconds'
sleep
5
let
"wait_log_generate_time+=5"
done
echo
"listen for the log ack..."
for
((
i
=
0
;;
))
do
bootstrap_flag
=
`
cat
${
log_path
}
|grep
"
${
ack_phrase
}
"
|
wc
-l
`
if
[
"
${
bootstrap_flag
}
"
=
0
]
&&
[
"
${
max_wait_ack_time
}
"
-gt
"
${
wait_ack_time
}
"
]
then
sleep
5
let
"wait_ack_time+=5"
echo
"waiting for bootstrap flag for
${
wait_ack_time
}
"
elif
[
"
${
bootstrap_flag
}
"
=
1
]
then
echo
"server is start~"
exit
0
else
echo
"server not startup in
${
max_wait_ack_time
}
seconds..."
exit
-1
fi
done
}
ack
"
$1
"
$2
$3
$4
\ No newline at end of file
execu-utils/worker/other_restart.sh
0 → 100755
View file @
1fc30555
#!/bin/sh
source
~/.bash_profile
module_name
=
$1
worker_host
=
$2
re_load_config
=
$3
#basic_no="3"
echo
"[params] module_name:
$1
, worker_host:
$2
, re_load_config:
$3
"
utils_path
=
"/home/quant_group/qa-deploy-utils"
basic_no
=
$((${
worker_host
:10
}))
mysql_no
=
$((${
worker_host
:10
}))
mkdir
-p
/home/quant_group/remote_backup/
${
module_name
}
rm
-rf
/home/quant_group/remote_backup/
${
module_name
}
tar
-zxvf
/home/quant_group/remote_backup/
${
module_name
}
.tar.gz
-C
/home/quant_group/remote_backup
mkdir
-p
/home/quant_group/
${
module_name
}
rm
-rf
/home/quant_group/
${
module_name
}
mv
/home/quant_group/remote_backup/
${
module_name
}
/home/quant_group/
cd
/home/quant_group/
${
module_name
}
/
ts
=
`
date
+%s
`
if
[
${
module_name
}
=
"AppBackend"
]
;
then
sourceConfigFile
=
qa.
${
module_name
}
.config.js
targetConfigFile
=
config/environment/test.js
restartCmd
=
"sh /home/quant_group/
${
module_name
}
/test.sh"
elif
[
${
module_name
}
=
"activity-op"
]
;
then
sourceConfigFile
=
qa.
${
module_name
}
.config.js
targetConfigFile
=
src/config.js
echo
"sh /home/quant_group/
${
module_name
}
/stop.sh"
sh /home/quant_group/
${
module_name
}
/stop.sh
echo
"npm install"
npm
install
restartCmd
=
"sh /home/quant_group/
${
module_name
}
/start.sh"
elif
[
${
module_name
}
=
"qin-qiong"
]
;
then
echo
"sh
${
utils_path
}
/sh-utils/worker/process_stop.sh python port=7022"
sh
${
utils_path
}
/sh-utils/worker/process_stop.sh
"python"
"port=7022"
sleep
5
python /home/quant_group/
${
module_name
}
/setup.py
install
echo
"#!/bin/sh"
>
start.sh
echo
"python /home/quant_group/
${
module_name
}
/run.py --mode=beta --port=7022 > /dev/null 2>&1 &"
>>
start.sh
sourceConfigFile
=
qa.
${
module_name
}
.config.properties
targetConfigFile
=
config/beta/config.properties
restartCmd
=
"sh /home/quant_group/
${
module_name
}
/start.sh"
# restartCmd="python /home/quant_group/qin-qiong/run.py --mode=beta --port=7022 > /dev/null 2>&1 &"
elif
[
${
module_name
}
=
"xyqb-query"
]
;
then
echo
"sh
${
utils_path
}
/sh-utils/worker/process_stop.sh python port=7033"
sh
${
utils_path
}
/sh-utils/worker/process_stop.sh
"python"
"port=7033"
sleep
5
python /home/quant_group/
${
module_name
}
/server/setup.py
install
echo
"#!/bin/sh"
>
start.qa.sh
echo
"python /home/quant_group/
${
module_name
}
/server/run.py --mode=beta --port=7033 > /dev/null 2>&1 &"
>>
start.qa.sh
sourceConfigFile
=
qa.
${
module_name
}
.config.ini
targetConfigFile
=
server/config/beta/config.ini
restartCmd
=
"sh /home/quant_group/
${
module_name
}
/start.qa.sh"
elif
[
${
module_name
}
=
"op-api"
]
;
then
sourceConfigFile
=
qa.
${
module_name
}
.config.js
targetConfigFile
=
src/config.js
echo
"sh /home/quant_group/
${
module_name
}
/stop.sh"
sh /home/quant_group/
${
module_name
}
/stop.sh
echo
"npm install"
npm
install
restartCmd
=
"sh /home/quant_group/
${
module_name
}
/start.sh"
else
echo
"currently only AppBackend, qin-qiong, and xyqb-query, op-api, activity-op are supported by this script"
fi
if
[[
"
${
re_load_config
}
"
=
true
]]
;
then
echo
"Step 1: get config from qiqiu"
echo
"curl http://oeazjz3gi.bkt.clouddn.com/
${
sourceConfigFile
}
?random=
${
ts
}
-o new.config"
curl http://oeazjz3gi.bkt.clouddn.com/
${
sourceConfigFile
}
?random
=
${
ts
}
-o
new.config
mv
-f
new.config
$targetConfigFile
else
echo
"Step 1: Skip reload config"
fi
echo
"Step 2: replace ip"
sed
-i
"s/192.168.4.3/
${
worker_host
}
/g"
$targetConfigFile
sed
-i
"s/192.168.4.4/192.168.4.
${
basic_no
}
/g"
$targetConfigFile
sed
-i
"s/192.168.4.5/192.168.4.
${
mysql_no
}
/g"
$targetConfigFile
echo
"Step 3: restart"
echo
$restartCmd
$restartCmd
execu-utils/worker/post_for_copy_java.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
#
target_host
=
192.168.10.2
modules
=
'di-ting du-jiang-yan han-gu-guan jian-men-guan mall pay-center quartz xyqb'
function
copy_to
()
{
module
=
$1
mkdir
-p
/home/quant_group/
${
module
}
echo cd
/home/quant_group/
${
module
}
cd
/home/quant_group/
${
module
}
rm
-rf
*
tar
zxf /home/quant_group/deploy_backup/
${
module
}
/
${
module
}
.
${
target_host
}
.tgz
-C
/home/quant_group/
${
module
}
/
mv
${
module
}
.
${
target_host
}
/
*
./
cp
/home/quant_group/deploy_backup/
${
module
}
/
*
.jar ./
}
if
[[
"
${
module_name
}
"
=
"ALL"
]]
then
for
module
in
$modules
do
copy_to
${
module
}
echo
${
module
}
done
elif
[[
"
${
module_name
}
"
=
""
]]
then
echo
'Fail module name is empty'
exit
-1
else
copy_to
${
module_name
}
echo
${
module_name
}
fi
\ No newline at end of file
execu-utils/worker/post_for_copy_ui.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
target_host
=
192.168.10.2
modules
=
'di-ting du-jiang-yan han-gu-guan jian-men-guan mall pay-center quartz xyqb'
function
copy_to
()
{
module
=
$1
mkdir
-p
/home/quant_group/
${
module
}
echo cd
/home/quant_group/
${
module
}
cd
/home/quant_group/
${
module
}
rm
-rf
*
tar
zxf /home/quant_group/deploy_backup/
${
module
}
/
${
module
}
.
${
target_host
}
.tgz
-C
/home/quant_group/
${
module
}
/
mv
${
module
}
.
${
target_host
}
/
*
./
cp
/home/quant_group/deploy_backup/
${
module
}
/
*
.jar ./
}
if
[[
"
${
module_name
}
"
=
"ALL"
]]
then
for
module
in
$modules
do
copy_to
${
module
}
echo
${
module
}
done
elif
[[
"
${
module_name
}
"
=
""
]]
then
echo
'Fail module name is empty'
exit
-1
else
copy_to
${
module_name
}
echo
${
module_name
}
fi
\ No newline at end of file
execu-utils/worker/prepare_for_copy.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
java_modules
=
'di-ting du-jiang-yan han-gu-guan jian-men-guan mall pay-center quartz xyqb'
ui_modules
=
'di-ting-ui xyqb-ui pay-center-ui'
if
[[
"
${
module_type
}
"
=
"java"
]]
then
modules
=
$java_modules
else
modules
=
$ui_modules
fi
mkdir
-p
/home/quant_group/deploy_backup
function
clean_backup
()
{
module
=
$1
mkdir
-p
/home/quant_group/deploy_backup/
${
module
}
echo cd
/home/quant_group/deploy_backup/
${
module
}
cd
/home/quant_group/deploy_backup/
${
module
}
rm
-rf
*
}
if
[[
"
${
module_name
}
"
=
"ALL"
]]
then
for
module
in
$modules
do
clean_backup
${
module
}
echo
clean_backup
${
module
}
done
elif
[[
"
${
module_name
}
"
=
""
]]
then
echo
'Fail module name is empty'
exit
-1
else
clean_backup
${
module_name
}
echo
clean_backup
${
module_name
}
fi
\ No newline at end of file
execu-utils/worker/process_stop.sh
0 → 100644
View file @
1fc30555
#!/bin/sh
process_type
=
$1
process_key
=
$2
process
=
`
ps
-ef
|grep
$process_type
|grep
$process_key
|awk
'{print $2}'
`
if
[
"
$process
"
!=
""
]
;
then
echo
"kill -9
$process
"
kill
-9
$process
else
echo
"
$process_type
${
process_key
}
process does not exist. Skip kill step!"
fi
execu-utils/worker/ui_replace_ip.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
# ******** the script is used when jenkins auto deploy modules ********
# ******** used by ../deploy/ui_deploy.sh ********
module_name
=
$1
host
=
$2
ui_sys_type
=
$3
use_public_ip
=
$4
public_ip
=
"139.198.2.95"
if
[[
"
${
host
}
"
=
"192.168.10.2"
]]
then
worker_host
=
119.254.102.73
else
worker_host
=
$host
fi
echo
"rm -rf /home/quant_group/
${
module_name
}
/dist"
rm
-rf
/home/quant_group/
${
module_name
}
/dist
echo
"tar -zxvf /home/quant_group/
${
module_name
}
/
${
module_name
}
_dist.tar.gz -C /home/quant_group/
${
module_name
}
"
tar
-zxvf
/home/quant_group/
${
module_name
}
/
${
module_name
}
_dist.tar.gz
-C
/home/quant_group/
${
module_name
}
if
[[
"
${
ui_sys_type
}
"
=
"management_sys"
]]
;
then
if
[[
"
${
module_name
}
"
=
"di-ting-ui"
]]
;
then
echo
"cd /home/quant_group/
${
module_name
}
/dist/public/app"
cd
/home/quant_group/
${
module_name
}
/dist/public/app
else
echo
"cd /home/quant_group/
${
module_name
}
/dist/js"
cd
/home/quant_group/
${
module_name
}
/dist/js
fi
elif
[[
"
${
ui_sys_type
}
"
=
"business_sys"
]]
;
then
if
[[
"
${
module_name
}
"
=
"xyqb-ui"
]]
;
then
echo
"cd /home/quant_group/
${
module_name
}
/dist/public/app"
cd
/home/quant_group/
${
module_name
}
/dist/public/app
elif
[[
"
${
module_name
}
"
=
"xyqb-user-ui"
]]
;
then
echo
"cd /home/quant_group/
${
module_name
}
/dist/app/js"
cd
/home/quant_group/
${
module_name
}
/dist/app/js
elif
[[
"
${
module_name
}
"
=
"offline-ui"
||
"
${
module_name
}
"
=
"activity-ui"
]]
;
then
echo
"cd /home/quant_group/
${
module_name
}
/dist/app/js"
cd
/home/quant_group/
${
module_name
}
/dist/app/js
else
echo
"cd /home/quant_group/
${
module_name
}
/dist/app"
cd
/home/quant_group/
${
module_name
}
/dist/app
fi
else
echo
"Error! Please config ui_sys_type: business_sys or management_sys."
fi
if
[[
"
${
use_public_ip
}
"
=
false
]]
;
then
echo
"use_public_ip is False:
${
use_public_ip
}
!"
sed
-i
"s/192.168.4.3/
${
worker_host
}
/g"
*
.js
else
echo
"use_public_ip is True:
${
use_public_ip
}
!"
web_no
=
$((${
worker_host
:10
}))
if
[
$web_no
-lt
100
]
;
then
echo
"web_no < 100,
${
web_no
}
"
sed
-i
"s/192.168.4.3:7/
${
public_ip
}
:
${
web_no
}
/g"
*
.js
else
echo
"web_no >= 100,
${
web_no
}
"
sed
-i
"s/192.168.4.3:70/
${
public_ip
}
:
${
web_no
}
/g"
*
.js
fi
fi
execu-utils/worker/unzip_utils.sh
0 → 100644
View file @
1fc30555
#!/usr/bin/env bash
work_path
=
/home/quant_group
cd
${
work_path
}
/remote_backup
if
[
-d
${
work_path
}
/remote_backup/test-utils
]
then
echo
"rm -rf
$$
{work_path}/remote_backup/test-utils"
rm
-rf
${
work_path
}
/remote_backup/test-utils
fi
tar
-zxf
test-utils.tar.gz
if
[
-d
${
work_path
}
/test-utils
]
then
echo
"rm -rf
${
work_path
}
/test-utils"
rm
-rf
${
work_path
}
/test-utils
fi
mv
${
work_path
}
/remote_backup/test-utils
${
work_path
}
/test-utils
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment