Przeglądaj źródła

save xky script

gitwallet 1 rok temu
rodzic
commit
569e6d65d8
4 zmienionych plików z 136 dodań i 5 usunięć
  1. 1 5
      docs/timed_task.sh
  2. 1 0
      docs/xky/config.txt
  3. 74 0
      docs/xky/srv_install.sh
  4. 60 0
      docs/xky/timed_task.sh

+ 1 - 5
docs/timed_task.sh

@@ -25,11 +25,7 @@ table_name="game_server"
 
 index1=寻宝
 index2=区
-server_name=
-mapserver() {
-  server_name=$index1$zone_id$index2
-  echo $server_name
-}
+server_name=$index1$zone_id$index2
 
 mongodb_name=$((350001 + zone_id))
 port=$((8191 + zone_id))

+ 1 - 0
docs/xky/config.txt

@@ -0,0 +1 @@
+zone_start_id=2

+ 74 - 0
docs/xky/srv_install.sh

@@ -0,0 +1,74 @@
+#! /bin/bash
+# 用于开新区 
+if [[ -z "$1" || ! "$1" =~ ^[0-9]+$ ]]; then
+  echo "错误: 请输入有效的 zone_id (正整数)。"
+  exit 1
+fi
+
+serverPath=/server #能否获取当前路径作为服务器路径
+zone_id=$1
+echo -e "获取服务器id: ${zone_id} \n"
+
+##################################
+declare -A zone_id_name
+zone_id_name[2]=花开满城
+zone_id_name[3]=春暖花开
+zone_id_name[4]=云卷云舒
+zone_id_name[5]=静夜思归
+zone_id_name[6]=海阔天空
+zone_id_name[7]=星河灿烂
+zone_id_name[8]=鸟语花香
+zone_id_name[9]=山明水秀
+zone_id_name[10]=岁月静好
+zone_id_name[11]=月明如水
+##################################
+
+### 下面xxx修改为需要的路径
+to_dir=${serverPath}/bin${zone_id}
+if [ ! -d "$to_dir" ]; then
+    # 目录不存在,创建目录
+    mkdir -p "$to_dir"
+    cd $to_dir
+    # 目录不存在,创建目录
+    mkdir -p "log"
+    ## 复制 Config ,Main,AdminLogic 三个文件 创建common core excel module 四个软链接
+    cp -r ${serverPath}/bin/script ${to_dir}
+    cp -r ${serverPath}/bin/lua51.dll ${to_dir}
+    cp -r ${serverPath}/bin/logic.exe ${to_dir}
+    cp -r ${serverPath}/bin/logic ${to_dir}
+    cp -r ${serverPath}/bin/libgcc_s_dw2-1.dll ${to_dir}
+    
+     chmod 777 logic
+    
+    rm -rf ${to_dir}/script/common
+    rm -rf ${to_dir}/script/excel
+    rm -rf ${to_dir}/script/module
+    
+    
+    #cp ${serverPath}/bin/script/Config.lua     ${serverPath}/bin${zone_id}/script/Config.lua
+    #cp ${serverPath}/bin/script/Main.lua       ${serverPath}/bin${zone_id}/script/Main.lua
+    #cp ${serverPath}/bin/script/AdminLogic.lua ${serverPath}/bin${zone_id}/script/AdminLogic.lua
+    
+    ln -s ${serverPath}/bin/script/common ${serverPath}/bin${zone_id}/script/common 
+    #ln -s ${serverPath}/bin/script/core ${serverPath}/bin${zone_id}/script/core 
+    ln -s ${serverPath}/bin/script/excel ${serverPath}/bin${zone_id}/script/excel 
+    ln -s ${serverPath}/bin/script/module ${serverPath}/bin${zone_id}/script/module 
+    
+    port=$((8191 + zone_id))
+    port_admin=$((10000 + zone_id))
+    database_idx=$((350001 + zone_id))
+    svr_idx=$((810537 + zone_id))
+    svrName_idx=$((zone_id - 1))
+    
+    # 替换配置文件
+    sed -i "24c\PORT_CLIENT = ${port}" ${to_dir}/script/Config.lua
+    sed -i "25c\PORT_ADMIN = ${port_admin}" ${to_dir}/script/Config.lua
+    sed -i "28c\DB_NAME = \"ckwy_fy_S${database_idx}\"" ${to_dir}/script/Config.lua
+    sed -i "31c\SVR_INDEX = ${svr_idx}" ${to_dir}/script/Config.lua
+    sed -i "32c\SVR_NAME = \"${zone_id_name[$zone_id]}\"" ${to_dir}/script/Config.lua
+    
+fi
+
+#启动服务
+echo -e "开始启动服务:${zone_id}\n"
+cd $to_dir && ./logic

+ 60 - 0
docs/xky/timed_task.sh

@@ -0,0 +1,60 @@
+#!bin/bash
+
+echo "start"
+
+serverPath=/server
+task_log_path=${serverPath}/timed_task.log
+
+#zone_id=$(awk '{print $1}' ${serverPath}/config.txt)
+zone_id=$(awk 'NR==1{split($0,a,"=");print a[2]}' ${serverPath}/config.txt)
+echo $zone_id
+
+cur_time=$(date "+%Y-%m-%d %H:%M:%S")
+echo "当前执行开服:${zone_id}区开始时间为:${cur_time}" >> $task_log_path
+
+#1:execute install
+sh ${serverPath}/srv_install.sh $zone_id
+cur_time=$(date "+%Y-%m-%d %H:%M:%S")
+echo "${cur_time}=>srv_install.sh ${zone_id}" >> $task_log_path
+
+#4:update 
+db_user="root"
+db_password="wch123.com"
+db_name="sdk"
+table_name="game_server"
+
+declare -A zone_id_name
+zone_id_name[2]=花开满城
+zone_id_name[3]=春暖花开
+zone_id_name[4]=云卷云舒
+zone_id_name[5]=静夜思归
+zone_id_name[6]=海阔天空
+zone_id_name[7]=星河灿烂
+zone_id_name[8]=鸟语花香
+zone_id_name[9]=山明水秀
+zone_id_name[10]=岁月静好
+zone_id_name[11]=月明如水
+
+mongodb_name=$((350001 + zone_id))
+port=$((8191 + zone_id))
+
+update_sql="insert into game_server(id,name,status,ip,port,tag,tips,white_list,open_time) values(${zone_id},'${zone_id_name[$zone_id]}', 1,'43.248.185.27',${port},'default','','',0);"
+mysql -u $db_user -p$db_password $db_name -e "$update_sql"
+
+cur_time=$(date "+%Y-%m-%d %H:%M:%S")
+echo "${cur_time}=>update sql:${update_sql}" >> $task_log_path
+
+#5:add 1
+((zone_id++))
+cur_time=$(date "+%Y-%m-%d %H:%M:%S")
+echo "${cur_time}=>zone_id++ ${zone_id}" >> $task_log_path
+
+#6:save id
+sed -i "1c\zone_start_id=${zone_id}" ${serverPath}/config.txt
+cur_time=$(date "+%Y-%m-%d %H:%M:%S")
+echo "${cur_time}=>zone_id++ ${zone_id}" >> $task_log_path
+
+cur_time=$(date "+%Y-%m-%d %H:%M:%S")
+echo "当前执行开服:${zone_id}区结束时间为:${cur_time}" >> $task_log_path
+
+echo $zone_id