内容目录
脚本记录备忘
#!/bin/bash
# startup run
source /etc/profile
if [ -f /gldata1/server/lv2/game_server ]; then
sed -i 's#172.17.0.2#'"$(hostname -I |awk '{print $1}')"'#g' /gldata1/server/lv2/game_server.conf
echo $@
if [[ $# -gt 0 ]]; then
echo $#
for i in $@
do
echo "now i is"$i
serid=$( echo ${i} | grep "serid"|awk -F "=" '{print $2}')
newdb=$( echo ${i} | grep "newdb"|awk -F "=" '{print $2}')
optime=$( echo ${i} | grep "optime"|awk -F "=" '{print $2}')
serv_type=$( echo ${i} | grep "serv_trpe"|awk -F "=" '{print $2}')
ssl=$( echo ${i} | grep "ssl"|awk -F "=" '{print $2}')
mem=$( echo ${i} | grep "mem"|awk -F "=" '{print $2}')
echo ${serid}
echo ${newdb}
echo ${optime}
if [[ ${serid} -gt 0 ]]; then
((kserid=serid + 30000))
echo $kserid
sed -i 's#KEY_SERVER=.*#KEY_SERVER='"${kserid}"'#g' /gldata1/server/lv2/game_server.conf
sed -i 's#game.server.id=.*#game.server.id='"${serid}"'#g' /gldata1/server/lv2/game_server.conf
dbName=$( curl http://openapi:4050/gameServer/Serializable|jq '.[] | select (.server == "'${kserid}'") | .dbName'|sed 's#"##g')
startTime=$( curl http://openapi:4050/gameServer/Serializable|jq '.[] | select (.server == "'${kserid}'") | .startTime'|sed 's#"##g')
if [[ -n $dbName ]];then
sed -i 's#docker_lv2#'"${dbName}"'#g' /gldata1/server/lv2/game_server.conf
else
sed -i 's#docker_lv2#lv2_'"${serid}"'#g' /gldata1/server/lv2/game_server.conf
fi
if [[ -n $startTime ]];then
#毫秒时间戳除以1000转为秒时间戳
startTime=$(($startTime/1000))
echo $starttime
#时间戳转为2023/10/13 这种日期格式,变量+@
sTime=$(date -d "@$startTime" +%Y/%m/%d)
echo $sTime
sed -i 's#server.open.time=.*#server.open.time='"${sTime}"'#g' /gldata1/server/lv2/game_server.conf
fi
fi
if [[ -n ${newdb} ]]; then
echo ${newdb}
mysqladr=$(cat /gldata1/server/lv2/game_server.conf |grep mysql|sed -n "1p"|awk -F "/|?" '{print $3}')
sed -i 's#'"${mysqladr}"'#'"${newdb}"'#g' /gldata1/server/lv2/game_server.conf
fi
if [[ -n ${optime} ]]; then
echo ${optime}
sed -i 's#server.open.time=.*#server.open.time='"${optime}"'#g' /gldata1/server/lv2/game_server.conf
fi
if [[ -n ${ssl} ]]; then
echo ${ssl}
sed -i 's#ssl.open=.*#ssl.open='"${ssl}"'#g' /gldata1/server/lv2/game_server.conf
fi
if [[ -n ${mem} ]]; then
echo ${mem}
((mem2=mem/2))
sed -i 's#-server -Xms1g -Xmx1g -XX:MaxDirectMemorySize=512m#-server -Xms'"${mem}"'g -Xmx'"${mem}"'g -XX:MaxDirectMemorySize='"${mem2}"'g#g' /gldata1/server/lv2/game_server
fi
if [[ -n ${serv_type} ]]; then
echo ${serv_type}
sed -i 's#game_server_type=.*#game_server_type='"${serv_type}"'#g' /gldata1/server/lv2/game_server.conf
fi
done
fi
/bin/bash /gldata1/server/lv2/game_server check
/bin/bash /gldata1/server/lv2/game_server genDB
#nohup /bin/bash /gldata1/server/lv2/game_server restart >/dev/null 2>&1 &
/usr/sbin/crond -i
cd /gldata1/server/lv2/
echo "启动srvWorld0"
sh game_server srvWorld0
fi
tail -f /dev/null
近期评论