Git更新脚本
约 1515 字大约 5 分钟
8.git更新脚本
git-shiju.sh
#!/bin/bash
## -------------------------------------------------------------------------
export PATH=/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:$PATH
export TERM="xterm-256color"
export WORKDIR="$( cd $(dirname "$0") && pwd )"
cd "${WORKDIR}" || exit 1
## -------------------------------------------------------------------------
info() {
date +"$( tput bold ; tput setaf 2)%F %T Info: $@$( tput sgr0)"
}
warn() {
date +"$( tput bold ; tput setaf 3)%F %T Warning: $@$( tput sgr0)"
}
error() {
date +"$( tput bold ; tput setaf 1)%F %T Error: $@$( tput sgr0)"
}
err_exit() {
date +"$( tput bold ; tput setaf 1)%F %T Error: $@$( tput sgr0)"
exit 1
}
## -------------------------------------------------------------------------
help_msg(){
echo -e "\033[40;32;1m ####################<测试环境--主干>#########################\033[0m"
echo -e "\033[40;32;1m app_h5_test app-h5服务\033[0m"
echo -e "\033[40;32;1m app_h5_vue_test app-h5-vue服务\033[0m"
echo -e "\033[40;32;1m egc_file egc-file服务\033[0m"
echo -e "\033[40;32;1m egc_web_test egc-web服务\033[0m"
echo -e "\033[40;32;1m egc_user_test egc-user服务 \033[0m"
echo -e "\033[40;32;1m egc_adapter_test egc-adapter服务\033[0m"
echo -e "\033[40;32;1m egc_gateway_test egc-gateway服务\033[0m"
echo -e "\033[40;32;1m egc-precase_test egc-precase服务 \033[0m"
echo -e "\033[40;32;1m egc_decision_test egc-decision服务\033[0m"
echo -e "\033[40;32;1m egc_guarantee_test egc-guarantee服务\033[0m"
echo -e "\033[40;32;1m egc_timertask_test egc-timertask服务\033[0m"
echo -e "\033[40;32;1m egc_comprehensive_test egc-comprehensive服务\033[0m"
echo -e "\033[40;32;1m egc_comm_dispatcher_test egc-comm-dispatcher服务\033[0m"
echo -e "\033[40;32;1m ####################<测试环境--主干>#########################\033[0m"
}
## -------------------------------------------------------------------------
## 主干代码路径
egc_env(){
egc_root_path="/data/git/mpmt"
egc_web_git="${egc_root_path}/egc-web"
egc_app_h5_git="${egc_root_path}/egc-app-h5"
egc_app_vue_git="${egc_root_path}/egc-app-vue"
egc_file_git="${egc_root_path}/egc-file"
egc_user_git="${egc_root_path}/egc-egc-user"
egc_adapter_git="${egc_root_path}/egc-adapter"
egc_gateway_git="${egc_root_path}/egc-gateway"
egc_decision_git="${egc_root_path}/egc-decision"
egc_guarantee_git="${egc_root_path}/egc-guarantee"
egc_timertask_git="${egc_root_path}/egc-timertask"
egc_comprehensive_git="${egc_root_path}/egc-comprehensive"
egc_comm_dispatcher_git="${egc_root_path}/egc-comm-dispatcher"
egc_precase_git="${egc_root_path}/egc-precase"
egc_common_git="${egc_root_path}/egc-common"
egc_base_server_git="${egc_root_path}/egc-base-server"
}
## -------------------------------------------------------------------------
## 服务包部署路径
package_deploy_path(){
egc_app_h5_path="/data/pkgs/yibot_szpt_tools_v1.0/tomcat-service/egc-comm-dispatcher"
egc_app_vue_path="/data/pkgs/yibot_szpt_tools_v1.0/tomcat-service/egc-file"
egc_web_path="/data/pkgs/yibot_szpt_tools_v1.0/tomcat-service/egc-admin-job"
egc_file_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-file/pkgs"
egc_gateway_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-gateway/pkgs"
egc_user_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-user/pkgs"
egc_adapter_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-adapter/pkgs"
egc_decision_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-decision/pkgs"
egc_guarantee_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-guarantee/pkgs"
egc_timertask_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-timertask/pkgs"
egc_comprehensive_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-comprehensive/pkgs"
egc_precase_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-precase/pkgs"
egc_comm_dispatcher_path="/data/pkgs/yibot_yjgl_tools_v1.0/tomcat-service/egc-comm-dispatcher/pkgs"
}
## -------------------------------------------------------------------------
egc_env
egc_branch_env
package_deploy_path
date=`date +%Y%m%d%H%M`
wait_time(){
echo "准备倒数5秒:"
for i in $(seq 5 -1 1)
do
echo -e "$i";sleep 1
done
echo -e "开始"
}
########################################################## 主干 #########################################################
admin_web_test(){
wait_time
cd $egc_admin_web_git
echo -e "\033[34m 更新主干egc-admin-web \033[0m"
git up
find $egc_admin_web_git/src/main/webapp -type f -name '*.html' | xargs sed -i "s/\?v=[0-9]\{10,15\}/\?v=$date/g"
\cp -rf $egc_admin_web_git/src/main/webapp/* /usr/share/nginx/html/egc-admin-test
}
web_test(){
wait_time
cd $egc_web_git
echo -e "\033[34m 更新主干egc-web \033[0m"
git up
find $egc_web_git/src/main/webapp/webinfo -type f -name '*.html' | xargs sed -i "s/\?v=[0-9]\{10,15\}/\?v=$date/g"
\cp -rf $egc_web_git/src/main/webapp/webinfo/* /usr/share/nginx/html/egc-test/webinfo
}
app_test(){
wait_time
cd $egc_web_git
echo -e "\033[34m 更新主干app-web \033[0m"
git up
find $egc_web_git/src/main/webapp/app -type f -name '*.html' | xargs sed -i "s/\?v=[0-9]\{10,15\}/\?v=$date/g"
\cp -rf $egc_web_git/src/main/webapp/app/* /usr/share/nginx/html/egc-test/app
}
ns_test(){
wait_time
cd $ns_git
echo -e "\033[34m 更新主干南山web服务 \033[0m"
git up
/usr/bin/mvn clean package -Pnsga-fz-tencent -Dmaven.test.skip=true
kill -9 `ps -ef | grep java | grep tomcat-nanshan | grep -v grep | awk '{print $2}' `
rm -rf $ns_path/webapps/*
\cp -rf $ns_git/target/ns_possecu.war $ns_path/webapps/
cd $ns_path/bin && ./startup.sh
}
comm_dispatcher_test(){
wait_time
info "\033[34m 更新主干egc-comm-dispatcher \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_comm_dispatcher_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_comm_dispatcher_git/target/egc-comm-dispatcher-1.0.0-SNAPSHOT.jar $egc_dispatcher_path/pkgs
cd $egc_dispatcher_path && bash op.sh restart
}
file_test(){
wait_time
info "\033[34m 更新主干egc-file \033[0m"
cd $egc_file_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_file_git/target/egc-file-1.0.0-SNAPSHOT.jar $egc_file_path/pkgs
cd $egc_file_path && bash op.sh restart
}
admin_job_test(){
wait_time
info "\033[34m 更新主干egc-admin-job \033[0m"
cd $egc_admin_job_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_admin_job_git/target/xxl-job-admin-2.1.2.jar $egc_admin_job_path/pkgs
cd $egc_admin_job_path && bash op.sh restart
}
gateway_test(){
wait_time
info "\033[34m 更新主干egc-gateway \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_gateway_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_gateway_git/target/egc-gateway-1.0.0-SNAPSHOT.jar $egc_gateway_path
cd $egc_gateway_path && bash gateway.sh
}
user_test(){
wait_time
info "\033[34m 更新主干egc-user \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_user_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_user_git/target/egc-user-1.0.0-SNAPSHOT.jar $egc_user_path
cd $egc_user_path && bash user.sh
}
system_test(){
wait_time
info "\033[34m 更新主干egc-system \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_system_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_system_git/target/egc-system-1.0.0-SNAPSHOT.jar $egc_system_path
cd $egc_system_path && bash system.sh
}
patrol_test(){
wait_time
info "\033[34m 更新主干egc-patrol \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_patrol_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_patrol_git/target/egc-patrol-1.0.0-SNAPSHOT.jar $egc_patrol_path
cd $egc_patrol_path && bash patrol.sh
}
collection_test(){
wait_time
info "\033[34m 更新主干egc-collection \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_collection_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_collection_git/target/egc-collection-1.0.0-SNAPSHOT.jar $egc_collection_path
cd $egc_collection_path && bash collection.sh
}
patrol_test(){
wait_time
info "\033[34m 更新主干egc-patrol \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_patrol_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_patrol_git/target/egc-patrol-1.0.0-SNAPSHOT.jar $egc_patrol_path
cd $egc_patrol_path && bash patrol.sh
}
timertask_test(){
wait_time
info "\033[34m 更新主干egc-timertask \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_timertask_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_timertask_git/target/egc-timertask-1.0.0-SNAPSHOT.jar $egc_timertask_path
cd $egc_timertask_path && bash timertask.sh
}
adapter_test(){
wait_time
info "\033[34m 更新主干egc-adapter \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_adapter_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_adapter_git/target/egc-adapter-1.0.0-SNAPSHOT.jar $egc_adapter_path
cd $egc_adapter_path && bash adapter.sh
}
facade_test(){
wait_time
info "\033[34m 更新主干egc-facade \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_facade_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_facade_git/target/egc-facade-1.0.0-SNAPSHOT.jar $egc_facade_path
cd $egc_facade_path && bash facade.sh
}
college_test(){
wait_time
info "\033[34m 更新主干egc-college \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_college_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_college_git/target/egc-college-1.0.0-SNAPSHOT.jar $egc_college_path
cd $egc_college_path && bash college.sh
}
message_test(){
wait_time
info "\033[34m 更新主干egc-message \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_message_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_message_git/target/egc-message-1.0.0-SNAPSHOT.jar $egc_message_path
cd $egc_message_path && bash message.sh
}
mytask_test(){
wait_time
info "\033[34m 更新主干egc-mytask \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_mytask_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_mytask_git/target/egc-mytask-1.0.0-SNAPSHOT.jar $egc_mytask_path
cd $egc_mytask_path && bash mytask.sh
}
calculate_test(){
wait_time
info "\033[34m 更新主干egc-calculate \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_calculate_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_calculate_git/target/egc-calculate-1.0.0-SNAPSHOT.jar $egc_calculate_path
cd $egc_calculate_path && bash calculate.sh
}
device_test(){
wait_time
info "\033[34m 更新主干egc-device \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_device_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_device_git/target/egc-device-1.0.0-SNAPSHOT.jar $egc_device_path
cd $egc_device_path && bash device.sh
}
scheduler_test(){
wait_time
info "\033[34m 更新主干egc-scheduler \033[0m"
info "编译common"
cd $egc_common_git
git up
/usr/bin/mvn clean install
cd $egc_scheduler_git
git up
/usr/bin/mvn -U clean package -Dmaven.test.skip=true
\cp -rf $egc_scheduler_git/target/egc-scheduler-1.0.0-SNAPSHOT.jar $egc_scheduler_path
cd $egc_scheduler_path && bash scheduler.sh
}
## ---------------------------------------------------------------------------------------------------------------
case $1 in
admin_web_test )
admin_web_test
;;
web_test )
web_test
;;
app_test )
app_test
;;
comm_dispatcher_test )
comm_dispatcher_test
;;
file_test )
file_test
;;
admin_job_test )
admin_job_test
;;
gateway_test )
gateway_test
;;
user_test )
user_test
;;
timertask_test )
timertask_test
;;
collection_test )
collection_test
;;
patrol_test )
patrol_test
;;
adapter_test )
adapter_test
;;
facade_test )
facade_test
;;
college_test )
college_test
;;
message_test )
message_test
;;
mytask_test )
mytask_test
;;
calculate_test )
calculate_test
;;
system_test )
system_test
;;
device_test )
device_test
;;
scheduler_test )
scheduler_test
;;
ns_test )
ns_test
;;
* )
help_msg
;;
esac