#/bin/bash
#功能: The QA service creates a zone profile based on the template and submits it to SVN.
Source_path=/data/source_code
SVN_PATH=/CODE/PSM #svn发布目录, push to this directory first, and then update the commit
Dir= "/data/source_code/configfiles"
default_conf= "Config.properties"
default_socket_conf= "SOCKET.LP"
Log_file= '/tmp/log.log '
Usage () {
Cat <<eof
Echo_error Instructions for use:
SH $ username create_one_zone_config #根据区参数匹配/data/source_code/configfiles/conf Directory Each partition configuration information generation parameter specifies a single zone profile
SH $ username delete_one_zone_config #根据区参数匹配/data/source_code/configfiles/conf Directory each partition configuration information Delete parameter specify a single zone profile
Eof
Exit 1
}
If [$#-eq 0]; Then
Usage
Fi
Change_config_file () {
#根据/data/source_code/configfiles/conf directory for each partition configuration information generation Area configuration file
Zone_file= "$"
Yunyingshang= ' echo ${zone_file}|awk-f ' _ ' {print $} '
SOURCE ${dir}/conf/${zone_file} #引用模板文件
[!-D ${source_path}/zonefile/${yunyingshang}/${zone_file}/bin/boot] && mkdir-p ${source_path}/zonefile/${ Yunyingshang}/${zone_file}/bin/boot
# # #生成和修改区配置文件
CP-RF ${dir}/${default_conf} ${source_path}/zonefile/${yunyingshang}/${zone_file}/bin/
CP-RF ${dir}/${default_socket_conf} ${source_path}/zonefile/${yunyingshang}/${zone_file}/bin/boot/
Sed-i-E "s#game.serverid=.* #game. serverid=${qa_conf[0]}#" \
-E "s#game.servername=.* #game. servername=${qa_conf[1]}#" \
-E "s#game.serverip=.* #game. serverip=${qa_conf[2]}#" \
-E "s#game.logindomain=.* #game. logindomain=${qa_conf[3]}#" \
-E "s#redis.host=.* #redis. host=${qa_conf[6]}#" \
-E "s#mysql.host=.* #mysql. host=${qa_conf[8]}#" \ # # #使用数组功能.
${SOURCE_PATH}/ZONEFILE/${YUNYINGSHANG}/${ZONE_FILE}/BIN/${DEFAULT_CONF}
Sed-i "s#port=.* #port =${qa_conf[9]}#" ${source_path}/zonefile/${yunyingshang}/${zone_file}/bin/boot/${default_ SOCKET_CONF}
echo "One configuration file has been generated"
# # #从生成目录同步区配置到SVN发布目录.
Rsync-avz--exclude= ". SVN" ${source_path}/zonefile/${yunyingshang}/* ${svn_path}/zonefile/${yunyingshang}/> > ${log_file}
# # #区文件推到GM目录.
Rsync-avz--exclude= ". SVN" ${source_path}/zonefile/${yunyingshang}/${zone_file}/bin/${default_conf} ${SVN_PATH}/ Psm_gm/zq/config/subserver/${qa_conf[0]}.properties >> ${log_file}
}
Change_one_zone_config_file () {
Change_config_file "${zone_name}"
}
Delete_one_zone_config_file () {
Delete_config_file "${zone_name}"
}
Delete_config_file () {
Zone_file= "$"
Yunyingshang= ' echo ${zone_file}|awk-f ' _ ' {print $} '
SOURCE ${dir}/conf/${zone_file}
RM-RF ${dir}/conf/${zone_file}
RM-RF ${source_path}/zonefile/${yunyingshang}/${zone_file}
RM-RF ${svn_path}/zonefile/${yunyingshang}/${zone_file}
RM-RF ${svn_path}/psm_gm/zq/config/subserver/${qa_conf[0]}.properties
echo "Delete_one_zone_config is ok!"
}
Update ()
{
Svn_name=$1
SVN update--username ${svn_name}
If [$?-ne 0];then
echo "SVN update failed"
Exit 1
Fi
version= ' svn info |awk-f ' []+ '/revision/{print.
temp= "' Date +%y%m%d ' ${version}"
Num= ' echo ${TEMP}+1|BC '
ECHO-E "####################\nsvn Update Complete"
}
Commit ()
{
Log_path= "/code/svnlog"
#svn Commit
echo "CD ${1:-${svn_path}}"
CD ${1:-${svn_path}}
[!-D ${log_path}] && mkdir-p ${log_path}
Mkdir-p ${log_path}/${version}
$SVN status |awk ' {if ($1== "!") Print $} ' |cut-b 9->${log_path}/${version}/svn_del.log
$SVN status |awk ' {if ($1== "?") Print $} ' |cut-b 9->${log_path}/${version}/svn_add.log
$SVN status |awk ' {if ($1== "M") print $} ' |cut-b 9->${log_path}/${version}/svn_change.log
While read line;d o $SVN Delete "$line";d one <${log_path}/${version}/svn_del.log && echo "SVN Delete complete "
While read line;d o $SVN Add "$line";d one <${log_path}/${version}/svn_add.log && echo ' SVN add complete '
$SVN commit-m "' Date +%y%m%d%h%m%s '"--username ${svn_name} && echo "SVN commit Complete"
#删除认证文件
Rm-f/root/.subversion/auth/svn.simple/*
}
If [-N "$"];then
Svn_name= "$"
Case $ in
Create_one_zone_config)
If [-N "$"];then
Change_one_zone_config_file
Else
ECHO-E "Please input zone name parameter for change_one_zone_config_file! For example: \c "&& echo-e" \033[40;32;1m create_one_zone_config psm_9wee_s0 \c "&& echo-e" \033[0m! "
Exit 1
Fi
Update $
Commit
;;
Delete_one_zone_config)
If [-N "$"];then
Delete_one_zone_config_file
Else
ECHO-E "Please input zone name parameter for delete_one_zone_config_file! For example: \c "&& echo-e" \033[40;32;1m delete_one_zone_config psm_9wee_s0 \c "&& echo-e" \033[0m! "
Exit 1
Fi
Update $
Commit
;;
*)
Usage
;;
Esac
Fi
About shell script functions, arrays, string interception, SVN update release instances