128 lines
2.8 KiB
Bash
Executable File
128 lines
2.8 KiB
Bash
Executable File
#!/bin/sh
|
|
if [ $# != 1 ] ; then
|
|
echo "需要1个参数"
|
|
exit 1;
|
|
fi
|
|
|
|
port=22
|
|
env=${1}
|
|
sshAddr=()
|
|
envs=()
|
|
masterAddr=''
|
|
|
|
if [ ${1} == 'zy' ] ; then
|
|
sshAddr=( "yjz-zy-game1" "yjz-zy-game2" "yjz-zy-game3" "yjz-zy-game4" "yjz-zy-game5" "yjz-zy-game6" "yjz-zy-game7" "yjz-zy-game8")
|
|
envs=("zy1" "zy2" "zy3" "zy4" "zy5" "zy6" "zy7" "zy8")
|
|
masterAddr=${sshAddr[0]}
|
|
echo ${masterAddr}
|
|
port=22
|
|
env='zy1'
|
|
elif [ ${1} == 'ch' ] ; then
|
|
sshAddr=("yjz-ch-game1" "yjz-ch-game2" "yjz-ch-game3" "yjz-ch-game4")
|
|
envs=("ch1" "ch2" "ch3" "ch4")
|
|
masterAddr=${sshAddr[0]}
|
|
echo ${masterAddr}
|
|
port=22
|
|
env='ch1'
|
|
elif [ ${1} == 'alpha' ] ; then
|
|
sshAddr=("zyzalpha")
|
|
envs=("alpha")
|
|
masterAddr=${sshAddr[0]}
|
|
echo ${masterAddr}
|
|
port=22
|
|
env='alpha'
|
|
elif [ ${1} == 'dev' ] ; then
|
|
sshAddr=("zyzdev")
|
|
envs=("dev")
|
|
masterAddr=${sshAddr[0]}
|
|
echo ${masterAddr}
|
|
port=22
|
|
env='dev'
|
|
else
|
|
echo "需要一个参数指明服务器"
|
|
exit 1;
|
|
fi
|
|
|
|
echo "|*********************|\n"
|
|
|
|
if branch=$(git symbolic-ref --short -q HEAD)
|
|
then
|
|
echo "git on branch $branch \n"
|
|
else
|
|
echo "git not on any branch \n"
|
|
fi
|
|
echo "|*********************|\n"
|
|
|
|
echo "and config.json is: \n"
|
|
node ./config.js ${env} ${1}
|
|
cat './game-server/config.json'
|
|
echo "\n"
|
|
echo "|*********************|\n"
|
|
|
|
echo "and server_const is \n"
|
|
cat './shared/resource/jsons/server_const.json' | grep DEBUG_PAY
|
|
cat './shared/resource/jsons/server_const.json' | grep DEBUG_TIME
|
|
cat './shared/resource/jsons/server_const.json' | grep CHECK_WORD
|
|
cat './shared/resource/jsons/server_const.json' | grep CAN_PAY
|
|
cat './shared/resource/jsons/server_const.json' | grep SKIP_ENCODE
|
|
echo "\n"
|
|
echo "|*********************|"
|
|
|
|
read -r -p "Are You Sure? [Y/n]" input
|
|
|
|
sshFun(){
|
|
curEnv=$1
|
|
sshAddr=$2
|
|
echo $curEnv $env
|
|
if [ $curEnv == $env ]
|
|
then
|
|
ssh $sshAddr '
|
|
cd /root/zyz/game-server
|
|
pm2 kill
|
|
./pm2Starter.sh
|
|
'
|
|
else
|
|
ssh $sshAddr '
|
|
cd /root/zyz/game-server
|
|
pm2 kill
|
|
./pm2StarterDistribute.sh '${env} ${curEnv}'
|
|
'
|
|
fi
|
|
}
|
|
|
|
case $input in
|
|
[yY][eE][sS]|[yY])
|
|
echo "Yes"
|
|
length=${#sshAddr[@]}
|
|
int=1
|
|
while(( $int<=$length ))
|
|
do
|
|
addr=${sshAddr[$int-1]}
|
|
destUrl='root@'${addr}':/root/zyz/'
|
|
echo $destUrl
|
|
rsync -av --include '.babelrc' --include '.eslintrc.js' --exclude-from='exclude-file.txt' --progress --inplace --no-owner --no-group --rsh='ssh -p'${port} . ${destUrl}
|
|
let "int++"
|
|
done
|
|
int=1
|
|
while(( $int<=$length ))
|
|
do
|
|
addr=${sshAddr[$int-1]}
|
|
curEnv=${envs[$int-1]}
|
|
echo $curEnv $addr
|
|
sshFun $curEnv $addr
|
|
let "int++"
|
|
done
|
|
;;
|
|
[nN][oO]|[nN])
|
|
echo "No"
|
|
;;
|
|
*)
|
|
echo "Invalid input"
|
|
;;
|
|
esac
|
|
|
|
git checkout ./game-server/config.json
|
|
git checkout ./gm-server/config/env
|
|
git checkout ./web-server/config/env
|
|
git checkout ./web-server/config/sshHost.ts
|