Commit 9b566547 authored by QA-甘 盛聪's avatar QA-甘 盛聪

cp shell

parent 14369d32
#!/bin/bash
expect -c "
expect \"]#\"
send \"yum -y install rpcbind \r\"
set timeout 30
expect *[y/N]* { send y\r }
set timeout 30
expect *[y/N]* { send y\r }
expect eof;"
#
expect -c "
expect \"]#\"
send \"yum install nfs-utils\r\"
set timeout 30
expect *[y/N]* { send y\r }
set timeout 30
expect *[y/N]* { send y\r }
expect eof;"
expect -c "
expect \"]#\"
send \"/etc/init.d/rpcbind restart\r\"
set timeout -1
expect \"]#\"
send \"/etc/init.d/nfs restart\r\"
set timeout -1
expect \"]#\"
send \"chkconfig nfs on\r\"
set timeout -1
expect \"]#\"
send \"chkconfig rpcbind on\r\"
set timeout -1
expect eof;"
#yum -y install rpcbind
#yum -y install nfs-utils
#/etc/init.d/rpcbind start
#/etc/init.d/nfs start
#/etc/init.d/rpcbind restart
#/etc/init.d/nfs restart
#chkconfig nfs on
\ No newline at end of file
#!/bin/bash
config_files=/home/config_files
umount $config_files
rm -rf $config_files
mkdir $config_files
ip_add=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
mount -t nfs 192.168.4.3:/home/sub_config_file_dont_rm/${ip_add}/ $config_files
\ No newline at end of file
#!/bin/bash
project_name=$1
git_branch=$2
pwd_path="/home/qa_shell_script"
config_server="$pwd_path/config_server"
project_path=`cat $config_server/project_path.sh`
config_path=`cat $config_server/config_path.sh`
cd $project_path
project_folder=`find ./ -maxdepth 1 -name "$project_name"`
if [ -n "$project_folder" ];then
desc=`node $config_server/get_project_config.js -name $project_name -attr desc`
sh $config_server/show_info.sh $project_name pull代码 $desc
cd ./$project_name
git checkout ./
if [ -n "$git_branch" ]; then
echo "checkout specified branch $git_branch"
git checkout $git_branch
if [ $? = 0 ]; then
echo "checkout branch $git_branch is ok".
git pull
else
echo "Fail to checkout branch $git_branch".
exit -1
fi
else
echo "checkout default branch master"
git checkout master
git pull
fi
else
desc=`node $config_server/get_project_config.js -name $project_name -attr desc`
sh $config_server/show_info.sh $project_name clone代码 $desc
git_path=`node $config_server/get_project_config.js -name $project_name -attr git_path`
git clone $git_path
fi
#!/bin/bash
project_type=$1
git_branch=$2
pwd_path="/home/qa_shell_script"
config_server="$pwd_path/config_server"
project_path=`cat $config_server/project_path.sh`
config_path=`cat $config_server/config_path.sh`
function getCode()
{
projects=(`node $config_server/get_project_config.js -type $1 -attr name`)
for project in ${projects[@]}
do
desc=`node $config_server/get_project_config.js -name $project -attr desc`
cd $project_path
project_folder=`find ./ -maxdepth 1 -name "$project"`
if [ -n "$project_folder" ];then
sh $config_server/show_info.sh $project pull代码 $desc
cd ./$project
git checkout ./
if [ -n "$git_branch" ]; then
git checkout $git_branch
fi
git pull
else
sh $config_server/show_info.sh $project clone代码 $desc
git_path=`node $config_server/get_project_config.js -name $project -attr git_path`
git clone $git_path
fi
done
}
if [ "$project_type" = "java" ]
then
getCode java
elif [ "$project_type" = "ui" ]
then
getCode ui
elif [ "$project_type" = "node" ]
then
getCode node
elif [ "$project_type" = "python" ]
then
getCode python
else
getCode java
getCode ui
getCode node
getCode python
fi
\ No newline at end of file
#!/bin/bash
project=$1
is_public_ip=$2
pwd_path="/home/qa_shell_script"
config_server="$pwd_path/config_server"
project_path=`cat $config_server/project_path.sh`
config_path=`cat $config_server/config_path.sh`
if [ "$project" = "nginx" ]
then
sh $config_server/show_info.sh nginx.conf_d 连接配置文件 nginx配置文件
rm -rf /etc/nginx/conf.d
ln -s $config_path/nginx_conf.d /etc/nginx/conf.d
nginx -t; nginx -s reload
else
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 连接配置文件 $desc
project_type=`node $config_server/get_project_config.js -name $project -attr type`
file=`node $config_server/get_project_config.js -name $project -attr config_file`
if [ "$project_type" = "java" ]
then
mkdir /home/quant_group/${project}/target
fi
rm -rf /home/quant_group/$project/$file
if [ "$project_type" = "ui" ]
then
if $is_public_ip && [ -n "$is_public_ip" ]
then
echo "-------link-$project--$config_path/public/$project_type/$project.*----/home/quant_group/$project/$file "
cp $config_path/public/$project_type/${project}.* /home/quant_group/${project}/$file
else
echo "-------link-$project--$config_path/$project_type/$project.*----/home/quant_group/$project/$file "
cp $config_path/$project_type/${project}.* /home/quant_group/${project}/$file
fi
else
if $is_public_ip && [ -n "$is_public_ip" ]
then
ln -s $config_path/public/$project_type/${project}.* /home/quant_group/${project}/$file
else
ln -s $config_path/$project_type/${project}.* /home/quant_group/${project}/$file
fi
if [ "$project" = "xyqb-mall" ]
then
ln -s $config_path/pem_file /home/quant_group/xyqb-mall/baitiao
fi
fi
fi
#!/bin/bash
project_type=$1
is_public_ip=$2
pwd_path="/home/qa_shell_script"
config_server="$pwd_path/config_server"
project_path=`cat $config_server/project_path.sh`
config_path=`cat $config_server/config_path.sh`
java_projects=(`node $config_server/get_project_config.js -type java -attr name`)
ui_projects=(`node $config_server/get_project_config.js -type ui -attr name`)
node_projects=(`node $config_server/get_project_config.js -type node -attr name`)
python_projects=(`node $config_server/get_project_config.js -type python -attr name`)
function linkProjectConfig()
{
project=$1
project_type=$2
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 连接配置文件 $desc
file=`node $config_server/get_project_config.js -name ${project} -attr config_file`
echo "----rm -rf /home/quant_group/${project}/$file"
if [ "$project_type" = "java" ]
then
mkdir /home/quant_group/${project}/target
fi
rm -rf /home/quant_group/${project}/$file
if $is_public_ip && [ -n "$is_public_ip" ]
then
echo "---ln -s $config_path/public/$project_type/${project}.* /home/quant_group/${project}/$file"
ln -s $config_path/public/$project_type/${project}.* /home/quant_group/${project}/$file
else
echo "---ln -s $config_path/$project_type/${project}.* /home/quant_group/${project}/$file"
ln -s $config_path/$project_type/${project}.* /home/quant_group/${project}/$file
fi
if [ "$project" = "xyqb-mall" ]
then
ln -s $config_path/pem_file /home/quant_group/xyqb-mall/baitiao
fi
}
function cpProjectConfig()
{
project=$1
project_type=$2
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 连接配置文件 $desc
file=`node $config_server/get_project_config.js -name ${project} -attr config_file`
echo "----rm -rf /home/quant_group/${project}/$file"
rm -rf /home/quant_group/${project}/$file
if $is_public_ip && [ -n "$is_public_ip" ]
then
echo "---cp $config_path/public/$project_type/${project}.* /home/quant_group/${project}/$file "
cp $config_path/public/$project_type/${project}.* /home/quant_group/${project}/$file
else
echo "---cp $config_path/$project_type/${project}.* /home/quant_group/${project}/$file "
cp $config_path/$project_type/${project}.* /home/quant_group/${project}/$file
fi
}
function linkNginxConfdProject()
{
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh nginx_config.d 连接配置文件 $desc
rm -rf /etc/nginx/conf.d
ln -s $config_path/nginx_conf.d /etc/nginx/conf.d
nginx -t; nginx -s reload
}
if [ "$project_type" = "java" ]
then
for project in ${java_projects[@]}
do
linkProjectConfig $project java
done
elif [ "$project_type" = "ui" ]
then
for project in ${ui_projects[@]}
do
cpProjectConfig $project ui
done
linkNginxConfdProject
elif [ "$project_type" = "python" ]
then
for project in ${python_projects[@]}
do
linkProjectConfig $project python
done
elif [ "$project_type" = "node" ]
then
for project in ${node_projects[@]}
do
linkProjectConfig $project node
done
else
for project in ${java_projects[@]}
do
linkProjectConfig $project java
done
for project in ${ui_projects[@]}
do
cpProjectConfig $project ui
done
for project in ${node_projects[@]}
do
linkProjectConfig $project node
done
for project in ${python_projects[@]}
do
linkProjectConfig $project python
done
linkNginxConfdProject
fi
#!/bin/bash
project_name=$1
is_public_ip=$2
pwd_path="/home/qa_shell_script"
config_server="$pwd_path/config_server"
project_path=`cat $config_server/project_path.sh`
project_type=`node $config_server/get_project_config.js -name $project_name -attr type`
config_path=`cat $config_server/config_path.sh`
node4_path=`cat $config_server/node_4_path.sh`
node7_path=`cat $config_server/node_7_path.sh`
profile=test
host=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
echo "host=$host"
hosts=(${host//\./ })
suffix=${hosts[3]}
function buildJavaProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project BUILD $desc
cd $project_path/$project
rm -rf ./target/*.jar
if [[ "$project" = "xyqb" || "$project" = "gu-bei" || "$project" = "han-gu-guan" || "$project" = "di-ting" || "$project" = "xyqb-offline" || "$project" = "xyqb-user" ]]; then
echo "module is $project, need replace sms jar version from 1.0.x to 1.0.2"
num=`grep -n -A12 "<id>test</id>" $project_path/$project/pom.xml| grep "<version>" | awk -F- '{print $1}'`
echo "----$project-----pom.xml file line: $num------------"
sed -i "${num}s/1.0.[0-9]-SNAPSHOT/1.0.6-SNAPSHOT/" $project_path/$project/pom.xml
fi
if [[ "$project" = "du-jiang-yan" ]]; then
num=`grep -n -A3 "<artifactId>fund-manage-sdk</artifactId>" $project_path/$project/pom.xml| grep "<version>" | awk -F- '{print $1}'`
echo "----$project-----pom.xml file line: $num------------"
sed -i "${num}s/1.0.[0-9]-SNAPSHOT/1.0.0.${suffix}-SNAPSHOT/" $project_path/$project/pom.xml
sed -i "${num}s/1.0.[0-9].[0-9]/1.0.0.${suffix}-SNAPSHOT/" $project_path/$project/pom.xml
fi
# cd ./target
echo "mvn clean package -P${profile} -Dmaven.test.skip=true"
mvn clean package -P${profile} -Dmaven.test.skip=true
mv $project_path/$project/target/*.jar $project_path/$project/$project.jar
rm -rf ./target/*.jar.*
}
function buildUiProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project BUILD $desc
config_file=`node $config_server/get_project_config.js -name $project -attr config_file`
command=`node $config_server/get_project_config.js -name $project -attr command`
node_version=`node $config_server/get_project_config.js -name $project -attr node_version`
# 第一步 将nginx项目的所有文件进行打包
cd $project_path/$project
rm -rf ./$config_file
if $is_public_ip && [ -n "$is_public_ip" ]
then
cp $config_path/public/ui/$project.* $project_path/$project/$config_file
else
cp $config_path/ui/$project.* $project_path/$project/$config_file
fi
imagemin_dist=`grep -n -A3 "imagemin" *.js|awk '{print $1}'`
if [ -n "$imagemin_dist" ];then
echo "npm install gruntjs/grunt-contrib-imagemin"
${node4_path}/npm --registry http://192.168.3.7:4873 install gruntjs/grunt-contrib-imagemin
else
echo "dont install imagemin"
fi
if [ "$node_version" = "node4" ] ;then
echo "----node-V4---${node4_path}/npm --registry http://192.168.3.7:4873 install"
${node4_path}/npm --registry http://192.168.3.7:4873 install
else
npm --registry http://192.168.3.7:4873 install
fi
bower_json=`find ./ -maxdepth 1 -name "bower.json"`
if [ -n "$bower_json" ];then
echo "bower install --allow-root"
bower install --allow-root
else
echo "don't have bower.json"
fi
$command
# 第二步 不关机使得nginx生效
nginx -t; nginx -s reload
}
function buildNodeProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project BUILD $desc
config_file=`node $config_server/get_project_config.js -name $project -attr config_file`
command=`node $config_server/get_project_config.js -name $project -attr command`
node_version=`node $config_server/get_project_config.js -name $project -attr node_version`
# 第一步 将nginx项目的所有文件进行打包
cd $project_path/$project
#第二步 关联配置文件
rm -rf ./$config_file
echo " ------------ln -s $config_path/node/$project.* ./$config_file"
ln -s $config_path/node/$project.* ./$config_file
npm --registry http://192.168.3.7:4873 install
}
function buildPythonProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project BUILD $desc
config_file=`node $config_server/get_project_config.js -name $project -attr config_file`
cd $project_path/$project
setup_path_temp=`find ./ -name "setup.py"`
python ${setup_path_temp} install
#第四步 关联配置文件
rm -rf $config_file
ln -s $config_path/python/$project.* $config_file
}
if [ "$project_type" = "java" ]; then
buildJavaProject $project_name
elif [ "$project_type" = "ui" ]; then
buildUiProject $project_name
elif [ "$project_type" = "node" ]; then
buildNodeProject $project_name
elif [ "$project_type" = "python" ]; then
buildPythonProject $project_name
fi
#!/bin/bash
project_type=$1
is_public_ip=$2
pwd_path="/home/qa_shell_script"
config_server="$pwd_path/config_server"
project_path=`cat $config_server/project_path.sh`
config_path=`cat $config_server/config_path.sh`
node4_path=`cat $config_server/node_4_path.sh`
node7_path=`cat $config_server/node_7_path.sh`
profile=test
host=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
hosts=(${host//\./ })
suffix=${hosts[3]}
function buildJavaProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project BUILD $desc
cd $project_path/$project
rm -rf ./target/*.jar
if [[ "$project" = "xyqb" || "$project" = "gu-bei" || "$project" = "han-gu-guan" || "$project" = "di-ting" || "$project" = "xyqb-offline" || "$project" = "xyqb-user" ]]; then
echo "module is $project, need replace sms jar version from 1.0.x to 1.0.2"
num=`grep -n -A12 "<id>test</id>" $project_path/$project/pom.xml| grep "<version>" | awk -F- '{print $1}'`
sed -i "${num}s/1.0.[0-9]-SNAPSHOT/1.0.6-SNAPSHOT/" $project_path/$project/pom.xml
fi
if [[ "$project" = "du-jiang-yan" ]]; then
num=`grep -n -A3 "<artifactId>fund-manage-sdk</artifactId>" $project_path/$project/pom.xml| grep "<version>" | awk -F- '{print $1}'`
sed -i "${num}s/1.0.[0-9]-SNAPSHOT/1.0.0.${suffix}-SNAPSHOT/" $project_path/$project/pom.xml
sed -i "${num}s/1.0.[0-9].[0-9]/1.0.0.${suffix}-SNAPSHOT/" $project_path/$project/pom.xml
fi
# cd ./target
echo "mvn clean package -P${profile} -Dmaven.test.skip=true"
mvn clean package -P${profile} -Dmaven.test.skip=true
mv $project_path/$project/target/*.jar $project_path/$project/$project.jar
}
function buildUiProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project BUILD $desc
config_file=`node $config_server/get_project_config.js -name $project -attr config_file`
command=`node $config_server/get_project_config.js -name $project -attr command`
node_version=`node $config_server/get_project_config.js -name $project -attr node_version`
# 第一步 将nginx项目的所有文件进行打包
cd $project_path/$project
rm -rf ./$config_file
if $is_public_ip && [ -n "$is_public_ip" ]
then
cp $config_path/public/ui/$project.* $project_path/$project/$config_file
else
cp $config_path/ui/$project.* $project_path/$project/$config_file
fi
imagemin_dist=`grep -n -A3 "imagemin" *.js|awk '{print $1}'`
if [ -n "$imagemin_dist" ];then
echo "npm install gruntjs/grunt-contrib-imagemin"
${node4_path}/npm --registry http://192.168.3.7:4873 install gruntjs/grunt-contrib-imagemin
else
echo "dont install imagemin"
fi
if [ "$node_version" = "node4" ] ;then
echo "----node-V4---${node4_path}/npm --registry http://192.168.3.7:4873 install"
${node4_path}/npm --registry http://192.168.3.7:4873 install
else
npm --registry http://192.168.3.7:4873 install
fi
bower_json=`find ./ -maxdepth 1 -name "bower.json"`
if [ -n "$bower_json" ];then
echo "bower install --allow-root"
bower install --allow-root
else
echo "don't have bower.json"
fi
$command
}
function buildNginx()
{
# 第二步 不关机使得nginx生效
sh $config_server/show_info.sh nginx.config_d BUILD nginx配置文件生效
nginx -t; nginx -s reload
}
function buildNodeProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project BUILD $desc
config_file=`node $config_server/get_project_config.js -name $project -attr config_file`
command=`node $config_server/get_project_config.js -name $project -attr command`
node_version=`node $config_server/get_project_config.js -name $project -attr node_version`
# 第一步 将nginx项目的所有文件进行打包
cd $project_path/$project
#第二步 关联配置文件
rm -rf ./$config_file
echo " ------------ln -s $config_path/node/$project.* ./$config_file"
ln -s $config_path/node/$project.* ./$config_file
npm --registry http://192.168.3.7:4873 install
}
function buildPythonProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project BUILD $desc
config_file=`node $config_server/get_project_config.js -name $project -attr config_file`
cd $project_path/$project
setup_path_temp=`find ./ -name "setup.py"`
python ${setup_path_temp} install
#第四步 关联配置文件
rm -rf $config_file
ln -s $config_path/python/$project.* $config_file
}
if [ "$project_type" = "java" ]; then
java_projects=(`node $config_server/get_project_config.js -type java -attr name`)
for project in ${java_projects[@]}
do
buildJavaProject $project
done
elif [ "$project_type" = "ui" ]; then
ui_projects=(`node $config_server/get_project_config.js -type ui -attr name`)
for project in ${ui_projects[@]}
do
buildUiProject $project
done
buildNginx
elif [ "$project_type" = "node" ]; then
node_projects=(`node $config_server/get_project_config.js -type node -attr name`)
for project in ${node_projects[@]}
do
buildNodeProject $project
done
elif [ "$project_type" = "python" ]; then
python_projects=(`node $config_server/get_project_config.js -type python -attr name`)
for project in ${python_projects[@]}
do
buildPythonProject $project
done
else
java_projects=(`node $config_server/get_project_config.js -type java -attr name`)
for project in ${java_projects[@]}
do
buildJavaProject $project
done
ui_projects=(`node $config_server/get_project_config.js -type ui -attr name`)
for project in ${ui_projects[@]}
do
buildUiProject $project
done
node_projects=(`node $config_server/get_project_config.js -type node -attr name`)
for project in ${node_projects[@]}
do
buildNodeProject $project
done
python_projects=(`node $config_server/get_project_config.js -type python -attr name`)
for project in ${python_projects[@]}
do
buildPythonProject $project
done
buildNginx
fi
#!/bin/bash
project_type=$1
pwd_path="/home/qa_shell_script"
config_server="$pwd_path/config_server"
project_path=`cat $config_server/project_path.sh`
config_path=`cat $config_server/config_path.sh`
node4_path=`cat $config_server/node_4_path.sh`
node7_path=`cat $config_server/node_7_path.sh`
profile=test
function restartJavaProject()
{
projects=(`node $config_server/get_project_config.js -type java -attr name`)
for project in ${projects[@]}
do
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 关闭 $desc
cd $project_path/$project
cd ./target
P_UUID=`ps -ef|grep ${project}.jar |grep -v 'grep'|awk '{print $2}'`
if [ -n "${P_UUID}" ];then
echo "-----KILL $project PPID=${P_UUID}"
echo `kill -9 ${P_UUID}`
fi
done
}
function restartNodeProject()
{
projects=(`node $config_server/get_project_config.js -type node -attr name`)
for project in ${projects[@]}
do
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 关闭 $desc
cd $project_path/$project
forever stop $project
forever stop $project-www
done
}
function restartPythonProject()
{
projects=(`node $config_server/get_project_config.js -type python -attr name`)
for project in ${projects[@]}
do
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 关闭 $desc
cd $project_path/$project
setup_path_temp=`find ./ -name "run.py"`
python_project_path=$project_path/$project${setup_path_temp/\.\//\/}
P_UUID=`ps -ef|grep $project |grep -v 'grep'|awk '{print $2}'`
if [[ "${P_UUID}" != "" ]];then
echo "-----KILL $project PPID=${P_UUID}"
echo `kill -9 ${P_UUID}`
fi
done
}
function restartUiProject()
{
nginx -t; nginx -s reload
}
if [ "$project_type" = "java" ]; then
restartJavaProject
elif [ "$project_type" = "node" ]; then
restartNodeProject
elif [ "$project_type" = "python" ]; then
restartPythonProject
elif [ "$project_type" = "ui" ]; then
restartUiProject
else
restartJavaProject
restartNodeProject
restartPythonProject
restartUiProject
fi
#!/bin/bash
project_name=$1
is_public_ip=$2
pwd_path="/home/qa_shell_script"
config_shell_path="$pwd_path"
config_server="$pwd_path/config_server"
project_type=`node $config_server/get_project_config.js -name $project_name -attr type`
project_path=`cat $config_server/project_path.sh`
config_path=`cat $config_server/config_path.sh`
node4_path=`cat $config_server/node_4_path.sh`
node7_path=`cat $config_server/node_7_path.sh`
profile=test
time=`date +%Y_%m_%d_%H_%M_%S`
function restartJavaProject()
{
max_wait_log_generate_time=50
max_wait_ack_time=500
ack_phrase="Started\ Bootstrap"
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 重新启动 $desc
cd $project_path/$project
P_UUID=`ps -ef|grep ${project}.jar |grep -v 'grep'|awk '{print $2}'`
if [ -n "${P_UUID}" ];then
echo "-----KILL $project PPID=${P_UUID}"
echo `kill -9 ${P_UUID}`
sleep 2s
fi
config_file=`find ./ -maxdepth 2 -name "application.properties"`
if [ -n "$config_file" ]
then
echo "have"
else
echo "no have"
if $is_public_ip && [ -n "$is_public_ip" ]
then
echo "ln -s $config_path/public/java/${project}.* /home/quant_group/${project}/application.properties"
ln -s $config_path/public/java/${project}.* /home/quant_group/${project}/application.properties
else
echo "ln -s $config_path/java/${project}.* /home/quant_group/${project}/application.properties"
ln -s $config_path/java/${project}.* /home/quant_group/${project}/application.properties
fi
fi
if [ "$project" = "xyqb-mall" ]
then
echo `ln -s $config_path/pem_file /home/quant_group/xyqb-mall/baitiao`
fi
echo "-----project:$project while be run command: java -Xmx256m -XX:PermSize64m -Xloggc:/tmp/${project}.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -jar ${project}.jar --worker 1 --currentWorker 1 -t > /dev/null 2>&1 &"
log_name=`node $config_server/get_project_config.js -name $project -attr log_name`
mv $project_path/logs/$log_name $project_path/logs/logs_back/$project-$time.log
echo `java -Xmx512m -XX:PermSize64m -Xloggc:/tmp/${project}.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -jar ${project}.jar --worker 1 --currentWorker 1 -t > /dev/null 2>&1 &`
#sleep 30s
ack "$ack_phrase" $project_path/logs/$log_name ${max_wait_log_generate_time} ${max_wait_ack_time}
}
function restartNodeProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 重新启动 $desc
cd $project_path/$project
forever stop $project
forever stop $project-www
setup_path_temp=`find ./ -maxdepth 2 -path "./node_modules" -prune -o -type f -name "app.js" -print`
echo "------setup_path_temp:$setup_path_temp"
echo `forever start -a -s --uid $project ${setup_path_temp}`
setup_path_temp_for_appbackent=`find ./ -maxdepth 2 -path "./node_modules" -prune -o -type f -name "www" -print`
if [ -n "$setup_path_temp_for_appbackent" ];then
echo "-----project:$project while be run command: python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &"
echo `forever start -a -s --uid $project-www ${setup_path_temp_for_appbackent}`
fi
}
function restartPythonProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
port=`node $config_server/get_project_config.js -name $project -attr port`
sh $config_server/show_info.sh $project 重新启动 $desc
cd $project_path/$project
setup_path_temp=`find ./ -name "run.py"`
python_project_path=$project_path/$project${setup_path_temp/\.\//\/}
P_UUID=`ps -ef|grep port=$port |grep -v 'grep'|awk '{print $2}'`
if [[ "${P_UUID}" != "" ]];then
echo "-----KILL $project PPID=${P_UUID}"
echo `kill -9 ${P_UUID}`
sleep 3
fi
echo "-----project:$project while be run command: python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &"
echo `python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &`
}
function restartUiProject()
{
nginx -t; nginx -s reload
}
#acknowledge whether the deploy start OK
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
}
if [ "$project_type" = "java" ]; then
restartJavaProject $project_name
elif [ "$project_type" = "node" ]; then
restartNodeProject $project_name
elif [ "$project_type" = "python" ]; then
restartPythonProject $project_name
elif [ "$project_type" = "ui" ]; then
restartUiProject $project_name
fi
#!/bin/bash
project_type=$1
is_public_ip=$2
pwd_path="/home/qa_shell_script"
config_shell_path="$pwd_path"
config_server="$pwd_path/config_server"
project_path=`cat $config_server/project_path.sh`
config_path=`cat $config_server/config_path.sh`
node4_path=`cat $config_server/node_4_path.sh`
node7_path=`cat $config_server/node_7_path.sh`
profile=test
max_wait_log_generate_time=50
max_wait_ack_time=500
ack_phrase="Started\ Bootstrap"
time=`date +%Y_%m_%d_%H_%M_%S`
function restartJavaProject()
{
projects=(`node $config_server/get_project_config.js -type java -attr name`)
echo ${projects[@]}
for project in ${projects[@]}
do
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 重新启动 $desc
cd $project_path/$project
P_UUID=`ps -ef|grep ${project}.jar |grep -v 'grep'|awk '{print $2}'`
if [ -n "${P_UUID}" ];then
echo "-----KILL $project PPID=${P_UUID}"
echo `kill -9 ${P_UUID}`
sleep 2s
fi
log_name=`node $config_server/get_project_config.js -name $project -attr log_name`
mv $project_path/logs/$log_name $project_path/logs/logs_back/$project-$time.log
config_file=`find ./ -maxdepth 2 -name "application.properties"`
if [ -n "$config_file" ]
then
echo "have"
else
echo "no have"
if $is_public_ip && [ -n "$is_public_ip" ]
then
echo "ln -s $config_path/public/java/${project}.* /home/quant_group/${project}/application.properties"
ln -s $config_path/public/java/${project}.* /home/quant_group/${project}/application.properties
else
echo "ln -s $config_path/java/${project}.* /home/quant_group/${project}/application.properties"
ln -s $config_path/java/${project}.* /home/quant_group/${project}/application.properties
fi
fi
if [ "$project" = "xyqb-mall" ]
then
echo `ln -s $config_path/pem_file /home/quant_group/xyqb-mall/baitiao`
fi
echo "-----project:$project while be run command: java -Xmx256m -XX:PermSize64m -Xloggc:/tmp/${project}.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -jar ${project}.jar --worker 1 --currentWorker 1 -t > /dev/null 2>&1 &"
echo `java -Xmx512m -XX:PermSize64m -Xloggc:/tmp/${project}.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -jar ${project}.jar --worker 1 --currentWorker 1 -t > /dev/null 2>&1 &`
#sleep 30s
ack "$ack_phrase" $project_path/logs/$log_name ${max_wait_log_generate_time} ${max_wait_ack_time}
done
}
function restartNodeProject()
{
projects=(`node $config_server/get_project_config.js -type node -attr name`)
for project in ${projects[@]}
do
desc=`node $config_server/get_project_config.js -name $project -attr desc`
sh $config_server/show_info.sh $project 重新启动 $desc
cd $project_path/$project
forever stop $project
forever stop $project-www
setup_path_temp=`find ./ -maxdepth 2 -path "./node_modules" -prune -o -type f -name "app.js" -print`
echo "------setup_path_temp:$setup_path_temp"
echo `forever start -a -s --uid $project ${setup_path_temp}`
setup_path_temp_for_appbackent=`find ./ -maxdepth 2 -path "./node_modules" -prune -o -type f -name "www" -print`
if [ -n "$setup_path_temp_for_appbackent" ];then
echo "-----project:$project while be run command: python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &"
echo `forever start -a -s --uid $project-www ${setup_path_temp_for_appbackent}`
fi
done
}
function restartPythonProject()
{
projects=(`node $config_server/get_project_config.js -type python -attr name`)
for project in ${projects[@]}
do
desc=`node $config_server/get_project_config.js -name $project -attr desc`
port=`node $config_server/get_project_config.js -name $project -attr port`
sh $config_server/show_info.sh $project 重新启动 $desc
cd $project_path/$project
setup_path_temp=`find ./ -name "run.py"`
python_project_path=$project_path/$project${setup_path_temp/\.\//\/}
P_UUID=`ps -ef|grep port=$port |grep -v 'grep'|awk '{print $2}'`
if [[ "${P_UUID}" != "" ]];then
echo "-----KILL $project PPID=${P_UUID}"
echo `kill -9 ${P_UUID}`
sleep 3
fi
echo "-----project:$project while be run command: python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &"
echo `python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &`
done
}
function restartUiProject()
{
nginx -t; nginx -s reload
}
#acknowledge whether the deploy start OK
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~ log_path:$log_path"
break
else
echo "server not startup in ${max_wait_ack_time} seconds.. log_path:$log_path"
exit -1
fi
done
}
if [ "$project_type" = "java" ]; then
restartJavaProject
elif [ "$project_type" = "node" ]; then
restartNodeProject
elif [ "$project_type" = "python" ]; then
restartPythonProject
elif [ "$project_type" = "ui" ]; then
restartUiProject
else
restartJavaProject
restartNodeProject
restartPythonProject
restartUiProject
fi
#!/bin/bash
backupdir=/home/config_files_backup
time=_` date +%Y_%m_%d_%H_%M_%S `
tar cfz $backupdir/config_$time.tar.gz /home/config_files/
find $backupdir -name $db_name"*.tar.gz" -type f -mtime +7 -exec rm -rf {} \; > /dev/null 2>&1
/home/config_files
\ No newline at end of file
var project_name, project_attr, projects = {},
java_projects = [],
node_projects = [],
python_projects = [],
ui_projects = [];
var param = {
type: "",
name: "",
attr: ""
}
var users = [{}, {
name: "dekun.dai",
pwd: "quantgroup.com"
}, {
name: "shengcong.gan",
pwd: "12345678"
}];
var pClass = function() {};
pClass.prototype = {
init: function(isActive, projectType, port, projectName, gitPath, logName, configFile, command, nodeVersion, userIndex, desc,auth) {
this.name = projectName;
this.type = projectType;
this.git_path = "http://" + users[userIndex].name + ":" + users[userIndex].pwd + "@gitabc.xyqb.com/" + gitPath + "/" + projectName + ".git"
this.log_name = logName;
this.config_file = configFile;
this.command = command;
this.node_version = nodeVersion;
this.port = port;
this.desc = desc;
this.is_active = isActive;
this.auth = auth;
projects[projectName] = this;
switch (projectType) {
case "java":
java_projects.push(this);
break;
case "node":
node_projects.push(this);
break;
case "ui":
ui_projects.push(this);
break;
case "python":
python_projects.push(this);
break;
}
}
}
// projectName,projectType,port,gitPath,logName,configFile,command,nodeVersion
new pClass().init(true, "java", "7003", "xyqb", "QG", "xyqb.log", "application.properties", null, null, 2, "现金贷和白条-server");
new pClass().init(true, "java", "7019", "xyqb-mall", "QG", "mall.log", "application.properties", null, null, 2, "商城后台-server");
new pClass().init(true, "java", "7010", "xyqb-offline", "QG", "xyqb_offline.log", "application.properties", null, null, 2, "线下业务-server");
new pClass().init(true, "java", "7042", "xyqb-user2", "head_group", "xyqb_user.log", "application.properties", null, null, 2, "用户注册登录-V2-server");
new pClass().init(true, "java", "7005", "di-ting", "QG", "di_ting.log", "application.properties", null, null, 2, "风控审计-server");
new pClass().init(true, "java", "7013", "han-gu-guan", "QG", "han-gu-guan.log", "application.properties", null, null, 2, "用户注册登录-V1-server");
new pClass().init(true, "java", "7015", "jian-men-guan", "QG", "jian_men_guan.log", "application.properties", null, null, 2, "信审服务-server");
new pClass().init(true, "java", "7014", "du-jiang-yan", "QG", "du_jiang_yan.log", "application.properties", null, null, 2, "第三方对接-server");
new pClass().init(true, "java", "7028", "black-hole", "QG", "black-hole.log", "application.properties", null, null, 2, "合同中心-server");
new pClass().init(true, "java", "7037", "cash-loan-flow", "QG", "cash_loan_flow.log", "application.properties", null, null, 2, "现金贷流量对接-server");
new pClass().init(true, "java", "7012", "financial-system", "QG", "financial_system.log", "application.properties", null, null, 2, "财务系统-server");
new pClass().init(true, "java", "7034", "fund-manage", "QG", "fund_manage.log", "application.properties", null, null, 2, "债转系统-server");
new pClass().init(true, "java", "7029", "gyxd", "QG", "gyxd.log", "application.properties", null, null, 2, "广源小贷-server");
new pClass().init(true, "java", "7038", "merchant-backend", "QG", "merchant.log", "application.properties", null, null, 2, "商户后台-server","凌子华/陈东亮");
new pClass().init(true, "java", "7021", "spider-center", "QG", "spider-center.log", "application.properties", null, null, 2, "爬虫-server"); //名称需要改一下
new pClass().init(true, "java", "7006", "gu-bei", "QG", "pay-center.log", "application.properties", null, null, 2, "支付中心-server"); //支付中心
new pClass().init(true, "java", "7023", "xyqb-quartz", "QG", "quartz.log", "application.properties", null, null, 2, "定时任务-server");
new pClass().init(true, "java", "7031", "redpacket", "QG", "redpacket.log", "application.properties", null, null, 2, "红包系统-server");
new pClass().init(true, "java", "7044", "finance-api", "bo.wang", "finance-api.log", "application.properties", null, null, 2, "财务系统-server");
// new pClass(true,"java","7027","sms-center","QG","sms-center.log",null,null,null,"短信中心-server");
// ui----
// projectName,projectType,port,gitPath,logName,configFile,command,nodeVersion
new pClass().init(true, "ui", "7032", "op-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "运营系统-ui");
new pClass().init(true, "ui", "7040", "activity-ui", "QG", null, "src/app/config.js", "npm run build", "node7", 1, "活动中心-ui");
new pClass().init(true, "ui", "7011", "financial-system-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "财务系统-ui");
new pClass().init(true, "ui", "7030", "gyxd-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "广源小贷-ui");
new pClass().init(true, "ui", "7008", "offline-ui", "QG", null, "src/app/config/env.config.js", "npm run build", "node7", 1, "线下白条-ui");
new pClass().init(true, "ui", "7035", "funding-corp-op-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "白条债转系统-ui");
new pClass().init(true, "ui", "7007", "paycenter-ui", "QG", null, "src/app/config/env.config.js", "npm run build", "node7", 1, "支付中心-ui");
new pClass().init(true, "ui", "7043", "xyqb-user-ui", "head_group", null, "src/app/config.js", "npm run qa", "node7", 1, "用户注册登录-V2-ui");
new pClass().init(true, "ui", "7039", "merchant-op-ui", "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "商户系统-ui");
new pClass().init(true, "ui", "7004", "di-ting-ui", "QG", null, "client/app/config.js", "grunt build", "node4", 1, "信审-ui");
new pClass().init(true, "ui", "7020", "spider-center-ui", "QG", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "授信中心-ui");
new pClass().init(true, "ui", "7002", "qgbc-ui", "QG", null, "src/app/config/env.config.js", "npm run build_production", "node7", 1, "现金贷和白条-白条-ui");
new pClass().init(true, "ui", "7001", "xyqb-ui", "QG", null, "client/app/config.js", "grunt build", "node4", 1, "现金贷和白条-现金贷-ui");
// node
new pClass().init(true, "node", "7018", "AppBackend", "QG", null, "config/environment/test.js", null, null, 1, "APP后台服务-server");
new pClass().init(true, "node", "7041", "activity-op", "QG", null, "src/config.js", null, null, 1, "优惠券中心-server");
new pClass().init(true, "node", "9050", "op-api", "OP", null, "src/config.js", null, null, 1, "系统Api Gateway-server");
//python
new pClass().init(true, "python", "7022", "qin-qiong", "QG", null, "config/beta/config.properties", null, null, 1, "加密解密-server");
new pClass().init(true, "python", "7033", "xyqb-query", "QG", null, "server/config/beta/config.ini", null, null, 1, "query-server");
var temp = "";
process.argv.forEach(function(val, index, array) {
if (index >= 2) {
if (index % 2 == 0) {
temp = val.replace(/\-/, "");
param[temp] = "";
} else {
param[temp] = val;
}
}
});
function getListAttr(projects, attr) {
var list = [];
for (var i = 0; i < projects.length; i++) {
list.push(projects[i][attr])
}
return list.join(" ");
}
var configFunction = function() {};
configFunction.prototype = {
getProjectAttr: function(pName, pAttr) {
if (typeof projects[pName] == "undefined") {
console.log("")
} else {
if (typeof projects[pName][pAttr] == "undefined") {
console.log("")
} else {
if(projects[pName][pAttr]){
console.log(projects[pName][pAttr])
}else{
console.log("")
}
}
}
},
getProjectsAttr: function(type, attr) {
switch (type) {
case "java":
console.log(getListAttr(java_projects, attr));
break;
case "ui":
console.log(getListAttr(ui_projects, attr));
break;
case "python":
console.log(getListAttr(python_projects, attr));
break;
case "node":
console.log(getListAttr(node_projects, attr));
break;
}
}
}
var F = new configFunction();
if (param["type"] == "") {
F.getProjectAttr(param["name"], param["attr"]);
} else {
F.getProjectsAttr(param["type"], param["attr"]);
}
/home/BaseApp/node-v4.4.7-linux-x64/bin
\ No newline at end of file
/home/BaseApp/node-v7.2.1/bin
\ No newline at end of file
/home/quant_group
\ No newline at end of file
/home/qa_shell_script
\ No newline at end of file
#!/bin/bash
echo "\"--------------------------------------------\""
echo "\"--------项目 $1 将要 $2\""
echo "\"--------项目描述: $3\""
echo "\"--------------------------------------------\""
\ No newline at end of file
#!/bin/bash
init_shell_script=$1
ip_last=$2
project_name=$3
branch_name=$4
project_type=$5
public_ip=$6
set timeout 1200
ip=192.168.4.$ip_last
echo "参数为:
init_shell_script: ${init_shell_script}
ip : ${ip}
project_name : ${project_name}
branch_name : ${branch_name}
project_type : ${project_type}
public_ip : ${public_ip}
"
#初始化脚本环境
if $init_shell_script ;then
expect -c "
set timeout 10
spawn ssh root@${ip}
expect *ssword* { send !QAZ2wsx\r }
expect \"]#\"
send \"rm -rf /home/qa_shell_script\r\"
expect \"]#\"
send \"cd /home\r\"
expect \"]#\"
send \"git clone https://qa_quantgroup:12345678@git.coding.net/tywldx/qa_shell_script.git\r\"
expect \"]#\"
send \"exit\r\"
expect eof;"
fi
if [ -n "$project_name" ] && [ -n "$branch_name" ]; then
expect -c "
set timeout 10
spawn ssh root@${ip}
expect *ssword* { send !QAZ2wsx\r }
expect \"]#\"
send \"cd /home/qa_shell_script\r\"
expect \"]#\"
send \"sh 1_mount_config_files.sh\r\"
set timeout -1
expect \"]#\"
send \"sh 2_get_code_by_name.sh $project_name $branch_name\r\"
set timeout -1
expect \"]#\"
send \"sh 3_link_config_file_by_name.sh $project_name $public_ip\r\"
set timeout -1
expect \"]#\"
send \"sh 4_build_by_name.sh $project_name $public_ip\r\"
set timeout -1
expect \"]#\"
send \"sh 5_restart_by_name.sh $project_name $public_ip\r\"
set timeout -1
expect \"]#\"
send \"exit\r\"
expect eof;"
else
expect -c "
set timeout 10
spawn ssh root@${ip}
expect *ssword* { send !QAZ2wsx\r }
expect \"]#\"
send \"cd /home/qa_shell_script\r\"
expect \"]#\"
send \"sh 1_mount_config_files.sh\r\"
set timeout -1
expect \"]#\"
send \"sh 2_get_code_by_type.sh $project_type $branch_name\r\"
set timeout -1
expect \"]#\"
send \"sh 3_link_config_file_by_type.sh $project_type $public_ip\r\"
set timeout -1
expect \"]#\"
send \"sh 4_build_by_type.sh $project_type $public_ip\r\"
set timeout -1
expect \"]#\"
send \"sh 5_restart_by_type.sh $project_type $public_ip\r\"
set timeout -1
expect \"]#\"
send \"exit\r\"
expect eof;"
fi
#!/bin/bash
init_shell_script=$1
ip_last=$2
project_name=$3
is_reload_config=$4
project_type=$5
set timeout 1200
ip=192.168.4.$ip_last
echo "参数为:
init_shell_script: ${init_shell_script}
ip : ${ip}
project_name : ${project_name}
is_reload_config : ${is_reload_config}
project_type : ${project_type}
"
#初始化脚本环境
if $init_shell_script ;then
expect -c "
set timeout 10
spawn ssh root@${ip}
expect *ssword* { send !QAZ2wsx\r }
expect \"]#\"
send \"rm -rf /home/qa_shell_script\r\"
expect \"]#\"
send \"cd /home\r\"
expect \"]#\"
send \"git clone https://qa_quantgroup:12345678@git.coding.net/tywldx/qa_shell_script.git\r\"
expect \"]#\"
send \"exit\r\"
expect eof;"
fi
if [ -n "$project_name" ]; then
expect -c "
set timeout 10
spawn ssh root@${ip}
expect *ssword* { send !QAZ2wsx\r }
expect \"]#\"
send \"cd /home/qa_shell_script\r\"
expect \"]#\"
send \"sh 1_mount_config_files.sh\r\"
set timeout -1
expect \"]#\"
send \"sh 2_get_code_by_name.sh $project_name $branch_name\r\"
set timeout -1
expect \"]#\"
send \"sh 3_link_config_file_by_name.sh $project_name\r\"
set timeout -1
expect \"]#\"
send \"sh 4_build_by_name.sh $project_name\r\"
set timeout -1
expect \"]#\"
send \"sh 5_restart_by_name.sh $project_name\r\"
set timeout -1
expect \"]#\"
send \"exit\r\"
expect eof;"
else
expect -c "
set timeout 10
spawn ssh root@${ip}
expect *ssword* { send !QAZ2wsx\r }
expect \"]#\"
send \"cd /home/qa_shell_script\r\"
expect \"]#\"
send \"sh 1_mount_config_files.sh\r\"
set timeout -1
expect \"]#\"
send \"sh 2_get_code_by_type.sh $project_type $branch_name\r\"
set timeout -1
expect \"]#\"
send \"sh 3_link_config_file_by_type.sh $project_type\r\"
set timeout -1
expect \"]#\"
send \"sh 4_build_by_type.sh $project_type\r\"
set timeout -1
expect \"]#\"
send \"sh 5_restart_by_type.sh $project_type\r\"
set timeout -1
expect \"]#\"
send \"exit\r\"
expect eof;"
fi
#!/bin/bash
IP_host_first="192.168.4."
public_ip="139.198.2.95"
mkdir /home/sub_config_file_dont_rm
for ip_last_num in 12 13 14 15 16 17 151
do
cd /home/sub_config_file_dont_rm
mkdir ${IP_host_first}${ip_last_num}
cd ${IP_host_first}${ip_last_num}
dir=`pwd`
#java项目发布
rm -rf $dir/java
mkdir $dir/java
rm -rf $dir/public
mkdir $dir/public
rm $dir/public/java
mkdir $dir/public/java
cp -rf /home/config_files/java/* $dir/java/
cp -rf /home/config_files/java/* $dir/public/java/
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/java/*
if [ $ip_last_num -lt 100 ]; then
sed -i "s/target_host_name:7/${public_ip}:${ip_last_num}/g" $dir/public/java/*
else
sed -i "s/target_host_name:70/${public_ip}:${ip_last_num}/g" $dir/public/java/*
fi
sed -i "s/target_host_name/${public_ip}/g" $dir/public/java/*
sed -i "s/${public_ip}:3306/${IP_host_first}${ip_last_num}:3306/g" $dir/public/java/*
sed -i "s/redis.master.host=${public_ip}/redis.master.host=${IP_host_first}${ip_last_num}/g" $dir/public/java/*
sed -i "s/zk.connect.url=${public_ip}/zk.connect.url=${IP_host_first}${ip_last_num}/g" $dir/public/java/*
#python项目发布
rm -rf $dir/python
mkdir $dir/python
cp -rf /home/config_files/python/* $dir/python/
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/python/*
#node项目发布
rm -rf $dir/node
mkdir $dir/node
cp -rf /home/config_files/node/* $dir/node/
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/node/*
#ui配置发布
rm -rf $dir/ui
mkdir $dir/ui
mkdir $dir/public
rm $dir/public/ui
mkdir $dir/public/ui
cp -rf /home/config_files/ui/* $dir/ui/
cp -rf /home/config_files/ui/* $dir/public/ui/
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/ui/*
if [ $ip_last_num -lt 100 ]; then
sed -i "s/target_host_name:7/${public_ip}:${ip_last_num}/g" $dir/public/ui/*
else
sed -i "s/target_host_name:70/${public_ip}:${ip_last_num}/g" $dir/public/ui/*
fi
sed -i "s/target_host_name/${public_ip}/g" $dir/public/ui/*
sed -i "s/${public_ip}:3306/${IP_host_first}${ip_last_num}:3306/g" $dir/public/ui/*
#ngxin conf.d发布
rm -rf $dir/nginx_conf.d
mkdir $dir/nginx_conf.d
cp -rf /home/config_files/nginx_conf.d/* $dir/nginx_conf.d/
#baitiao pem发布
rm -rf $dir/pem_file
mkdir $dir/pem_file
cp -rf /home/config_files/pem_file/* $dir/pem_file/
# sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/nginx_conf.d/*
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment