├── README.md ├── init └── game-server.init ├── install-game-server.sh └── latest ├── game-server └── game-server-386 /README.md: -------------------------------------------------------------------------------- 1 | Game-Server 2 | =========== 3 | 4 | ##[koolshare](http://koolshare.cn/forum-72-1.html)的[小宝](http://koolshare.cn/space-uid-2380.html) 宝大开发的游戏系列服务器(SS),支持udp in udp和udp in tcp模式,完美支持游戏NAT2。 5 | 6 | 脚本是业余爱好,英文属于文盲,写的不好,不要笑话我,欢迎您批评指正。 7 | 安装平台:CentOS、Debian、Ubuntu。 8 | Server 9 | ------ 10 | 11 | ### Install 12 | 13 | wget --no-check-certificate https://github.com/clangcn/game-server/raw/master/install-game-server.sh -O ./install-game-server.sh 14 | chmod 500 ./install-game-server.sh 15 | ./install-game-server.sh install 16 | 17 | ### UnInstall 18 | 19 | ./install-game-server.sh uninstall 20 | 21 | ### Update 22 | 23 | ./install-game-server.sh update 24 | 25 | ### 服务器管理 26 | 27 | Usage: /etc/init.d/game-server {start|stop|restart|status} 28 | 29 | ### 多用户配置文件范例 30 | 按照下面格式修改默认的/usr/local/game-server/config.json文件: 31 | 32 | { 33 | "server":"0.0.0.0", 34 | "local_port":1080, 35 | "timeout": 600, 36 | "method":"chacha20", 37 | "port_password": 38 | { 39 | "端口1": "密码1", 40 | "端口2": "密码2", 41 | "端口3": "密码3", 42 | "端口4": "密码4", 43 | "端口5": "密码5" 44 | }, 45 | "_comment": 46 | { 47 | "端口1": "端口描述1", 48 | "端口2": "端口描述2", 49 | "端口3": "端口描述3", 50 | "端口4": "端口描述4", 51 | "端口5": "端口描述5" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /init/game-server.init: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # chkconfig: 2345 55 25 3 | # Description: Startup script for Game-Server(XiaoBao) on Debian. Place in /etc/init.d and 4 | # run 'update-rc.d -f game-server defaults', or use the appropriate command on your 5 | # distro. For CentOS/Redhat run: 'chkconfig --add game-server' 6 | 7 | ### BEGIN INIT INFO 8 | # Provides: game-server 9 | # Required-Start: $all 10 | # Required-Stop: $all 11 | # Default-Start: 2 3 4 5 12 | # Default-Stop: 0 1 6 13 | # Short-Description: starts the game-server 14 | # Description: starts game-server using start-stop 15 | ### END INIT INFO 16 | 17 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 18 | ProgramName="Game-Server(XiaoBao)" 19 | ProgramPath="/usr/local/game-server" 20 | NAME=game-server 21 | BIN=${ProgramPath}/$NAME 22 | CONFIGFILE=${ProgramPath}/config.json 23 | LOGFILE=${ProgramPath}/game-server.log 24 | SCRIPTNAME=/etc/init.d/$NAME 25 | program_version=`${BIN} -version` 26 | version="1.2" 27 | RET_VAL=0 28 | 29 | [ -x $BIN ] || exit 0 30 | 31 | fun_check_run() 32 | { 33 | PID=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'` 34 | if [ ! -z $PID ]; then 35 | return 0 36 | else 37 | return 1 38 | fi 39 | } 40 | fun_load_config(){ 41 | if [ ! -r ${CONFIGFILE} ]; then 42 | echo "config file ${CONFIGFILE} not found" 43 | return 1 44 | fi 45 | } 46 | fun_status() 47 | { 48 | PID=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'` 49 | if [ ! -z $PID ]; then 50 | echo "${ProgramName} (pid $PID) is running..." 51 | else 52 | echo "${ProgramName} is stopped" 53 | exit 0 54 | fi 55 | } 56 | fun_start(){ 57 | if fun_check_run; then 58 | echo "${ProgramName} (pid $PID) already running." 59 | return 0 60 | fi 61 | fun_load_config 62 | echo -n "Starting ${ProgramName}..." 63 | ${BIN} -c ${CONFIGFILE} > ${LOGFILE} 2>&1 & 64 | sleep 1 65 | if ! fun_check_run; then 66 | echo "start failed" 67 | return 1 68 | fi 69 | echo " done" 70 | echo "${ProgramName} (pid $PID)is running." 71 | echo "read ${LOGFILE} for log" 72 | return 0 73 | } 74 | 75 | fun_stop(){ 76 | if fun_check_run; then 77 | echo -n "Stoping ${ProgramName} (pid $PID)... " 78 | kill $PID 79 | if [ "$?" != 0 ] ; then 80 | echo " failed" 81 | return 1 82 | else 83 | echo " done" 84 | fi 85 | else 86 | echo "${ProgramName} is not running." 87 | fi 88 | return 0 89 | } 90 | 91 | fun_restart(){ 92 | fun_stop 93 | fun_start 94 | } 95 | 96 | fun_config(){ 97 | if [ -s ${CONFIGFILE} ]; then 98 | vi ${CONFIGFILE} 99 | else 100 | echo "${ProgramName} configuration file not found!" 101 | return 1 102 | fi 103 | } 104 | 105 | fun_version(){ 106 | echo "${program_version}" 107 | return 0 108 | } 109 | 110 | case "$1" in 111 | start|stop|restart|status|version) 112 | fun_$1 113 | ;; 114 | *) 115 | echo "Usage: $SCRIPTNAME {start|stop|restart|status|version}" 116 | RET_VAL=1 117 | ;; 118 | esac 119 | exit $RET_VAL 120 | -------------------------------------------------------------------------------- /install-game-server.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin 3 | export PATH 4 | #=============================================================================================== 5 | # System Required: CentOS Debian or Ubuntu (32bit/64bit) 6 | # Description: Install Game-Server(XiaoBao) for CentOS Debian or Ubuntu 7 | # Author: Clang 8 | # Intro: http://clang.cn 9 | #=============================================================================================== 10 | version="7.3" 11 | str_game_dir="/usr/local/game-server" 12 | game_x64_download_url=https://raw.githubusercontent.com/clangcn/game-server/master/latest/game-server 13 | game_x86_download_url=https://raw.githubusercontent.com/clangcn/game-server/master/latest/game-server-386 14 | program_init_download_url=https://raw.githubusercontent.com/clangcn/game-server/master/init/game-server.init 15 | str_install_shell=https://raw.githubusercontent.com/clangcn/game-server/master/install-game-server.sh 16 | shell_update(){ 17 | clear 18 | fun_clang.cn 19 | echo "Check updates for shell..." 20 | remote_shell_version=`wget --no-check-certificate -qO- ${str_install_shell} | sed -n '/'^version'/p' | cut -d\" -f2` 21 | if [ ! -z ${remote_shell_version} ]; then 22 | if [[ "${version}" != "${remote_shell_version}" ]];then 23 | echo -e "${COLOR_GREEN}Found a new version,update now!!!${COLOR_END}" 24 | echo 25 | echo -n "Update shell ..." 26 | if ! wget --no-check-certificate -qO $0 ${str_install_shell}; then 27 | echo -e " [${COLOR_RED}failed${COLOR_END}]" 28 | echo 29 | exit 1 30 | else 31 | echo -e " [${COLOR_GREEN}OK${COLOR_END}]" 32 | echo 33 | echo -e "${COLOR_GREEN}Please Re-run${COLOR_END} ${COLOR_PINK}$0 ${clang_action}${COLOR_END}" 34 | echo 35 | exit 1 36 | fi 37 | exit 1 38 | fi 39 | fi 40 | } 41 | fun_clang.cn(){ 42 | echo "" 43 | echo "#####################################################################" 44 | echo "# Install Game-Server(XiaoBao) for CentOS Debian or Ubuntu(32/64bit)" 45 | echo "# Version ${version}" 46 | echo "#####################################################################" 47 | echo "" 48 | } 49 | 50 | # Check if user is root 51 | rootness(){ 52 | if [[ $EUID -ne 0 ]]; then 53 | fun_clang.cn 54 | echo "Error:This script must be run as root!" 1>&2 55 | exit 1 56 | fi 57 | } 58 | 59 | get_char(){ 60 | SAVEDSTTY=`stty -g` 61 | stty -echo 62 | stty cbreak 63 | dd if=/dev/tty bs=1 count=1 2> /dev/null 64 | stty -raw 65 | stty echo 66 | stty $SAVEDSTTY 67 | } 68 | 69 | fun_set_text_color(){ 70 | COLOR_RED='\E[1;31m' 71 | COLOR_GREEN='\E[1;32m' 72 | COLOR_YELOW='\E[1;33m' 73 | COLOR_BLUE='\E[1;34m' 74 | COLOR_PINK='\E[1;35m' 75 | COLOR_CYAN_BLUE='\033[40;36m' 76 | COLOR_PINKBACK_WHITEFONT='\033[45;37m' 77 | COLOR_END='\E[0m' 78 | } 79 | 80 | # Check OS 81 | checkos(){ 82 | if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then 83 | OS=CentOS 84 | elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then 85 | OS=Debian 86 | elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then 87 | OS=Ubuntu 88 | else 89 | echo "Not support OS, Please reinstall OS and retry!" 90 | exit 1 91 | fi 92 | } 93 | 94 | # Get version 95 | getversion(){ 96 | if [[ -s /etc/redhat-release ]];then 97 | grep -oE "[0-9.]+" /etc/redhat-release 98 | else 99 | grep -oE "[0-9.]+" /etc/issue 100 | fi 101 | } 102 | 103 | # CentOS version 104 | centosversion(){ 105 | local code=$1 106 | local version="`getversion`" 107 | local main_ver=${version%%.*} 108 | if [ $main_ver == $code ];then 109 | return 0 110 | else 111 | return 1 112 | fi 113 | } 114 | 115 | # Check OS bit 116 | check_os_bit(){ 117 | if [[ `getconf WORD_BIT` = '32' && `getconf LONG_BIT` = '64' ]] ; then 118 | Is_64bit='y' 119 | else 120 | Is_64bit='n' 121 | fi 122 | } 123 | 124 | check_centosversion(){ 125 | if centosversion 5; then 126 | echo "Not support CentOS 5.x, please change to CentOS 6,7 or Debian or Ubuntu and try again." 127 | exit 1 128 | fi 129 | } 130 | 131 | # Disable selinux 132 | disable_selinux(){ 133 | if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then 134 | sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 135 | setenforce 0 136 | fi 137 | } 138 | 139 | # Check port 140 | fun_check_port(){ 141 | strServerPort="$1" 142 | if [ ${strServerPort} -ge 1 ] && [ ${strServerPort} -le 65535 ]; then 143 | checkServerPort=`netstat -ntul | grep "\b:${strServerPort}\b"` 144 | if [ -n "${checkServerPort}" ]; then 145 | echo "" 146 | echo -e "${COLOR_RED}Error:${COLOR_END} Port ${COLOR_GREEN}${strServerPort}${COLOR_END} is ${COLOR_PINK}mused${COLOR_END},view relevant port:" 147 | #netstat -apn | grep "\b:${strServerPort}\b" 148 | netstat -ntulp | grep "\b:${strServerPort}\b" 149 | fun_input_port 150 | else 151 | serverport="${strServerPort}" 152 | fi 153 | else 154 | echo "Input error! Please input correct numbers." 155 | fun_input_port 156 | fi 157 | } 158 | 159 | # input port 160 | fun_input_port(){ 161 | server_port="8838" 162 | echo "" 163 | echo -e "Please input Server Port [1-65535](Don't the same SSH Port ${COLOR_RED}${sshport}${COLOR_END})" 164 | read -p "(Default Server Port: ${server_port}):" serverport 165 | [ -z "${serverport}" ] && serverport="${server_port}" 166 | fun_check_port "${serverport}" 167 | } 168 | 169 | # Random password 170 | fun_randstr(){ 171 | index=0 172 | strRandomPass="" 173 | for i in {a..z}; do arr[index]=$i; index=`expr ${index} + 1`; done 174 | for i in {A..Z}; do arr[index]=$i; index=`expr ${index} + 1`; done 175 | for i in {0..9}; do arr[index]=$i; index=`expr ${index} + 1`; done 176 | for i in {1..16}; do strRandomPass="$strRandomPass${arr[$RANDOM%$index]}"; done 177 | echo $strRandomPass 178 | } 179 | # ====== check packs ====== 180 | pre_install_packs(){ 181 | local wget_flag='' 182 | local killall_flag='' 183 | local netstat_flag='' 184 | local curl_flag='' 185 | local iptables_flag='' 186 | local vim_flag='' 187 | wget --version > /dev/null 2>&1 188 | wget_flag=$? 189 | killall -V >/dev/null 2>&1 190 | killall_flag=$? 191 | netstat --version >/dev/null 2>&1 192 | netstat_flag=$? 193 | curl -V > /dev/null 2>&1 194 | curl_flag=$? 195 | iptables -V > /dev/null 2>&1 196 | iptables_flag=$? 197 | vim --version > /dev/null 2>&1 198 | vim_flag=$? 199 | if [[ ${wget_flag} -gt 1 ]] || [[ ${killall_flag} -gt 1 ]] || [[ ${netstat_flag} -gt 6 ]] || [[ ${curl_flag} -gt 1 ]] || [[ ${iptables_flag} -gt 1 ]] || [[ ${vim_flag} -gt 1 ]];then 200 | echo -e "${COLOR_GREEN} Install support packs...${COLOR_END}" 201 | if [ "${OS}" == 'CentOS' ]; then 202 | yum install -y wget psmisc net-tools curl-devel iptables policycoreutils libpcap libpcap-devel vim 203 | else 204 | apt-get -y update && apt-get -y install wget psmisc net-tools curl iptables libpcap-dev vim 205 | fi 206 | fi 207 | } 208 | 209 | # ====== pre_install ====== 210 | pre_install_clang(){ 211 | #config setting 212 | echo " Please input your Game-Server(XiaoBao) server_port and password" 213 | echo "" 214 | sshport=`netstat -anp |grep ssh | grep '0.0.0.0:'|cut -d: -f2| awk 'NR==1 { print $1}'` 215 | #defIP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.' | cut -d: -f2 | awk 'NR==1 { print $1}'` 216 | #if [ "${defIP}" = "" ]; then 217 | defIP=$(curl -s -4 ip.clang.cn) 218 | #fi 219 | IP="0.0.0.0" 220 | echo "You VPS IP:$defIP" 221 | fun_input_port 222 | echo "" 223 | shadowsocks_pwd=`fun_randstr` 224 | read -p "Please input Password (Default Password: ${shadowsocks_pwd}):" shadowsockspwd 225 | if [ "${shadowsockspwd}" = "" ]; then 226 | shadowsockspwd="${shadowsocks_pwd}" 227 | fi 228 | echo "" 229 | ssmethod="chacha20" 230 | echo "Please input Encryption method(chacha20-ietf, chacha20, aes-256-cfb, bf-cfb, des-cfb, rc4)" 231 | read -p "(Default method: ${ssmethod}):" ssmethod 232 | if [ "${ssmethod}" = "" ]; then 233 | ssmethod="chacha20" 234 | fi 235 | echo "" 236 | set_iptables="n" 237 | echo -e "${COLOR_YELOW}Do you want to set iptables?${COLOR_END}" 238 | read -p "(if you want please input: y,Default [no]):" set_iptables 239 | 240 | case "${set_iptables}" in 241 | y|Y|Yes|YES|yes|yES|yEs|YeS|yeS) 242 | echo "You will set iptables!" 243 | set_iptables="y" 244 | ;; 245 | n|N|No|NO|no|nO) 246 | echo "You will NOT set iptables!" 247 | set_iptables="n" 248 | ;; 249 | *) 250 | echo "The iptables is not set!" 251 | set_iptables="n" 252 | esac 253 | 254 | echo "" 255 | echo "============== Check your input ==============" 256 | echo -e "Your Server IP:${COLOR_GREEN}${defIP}${COLOR_END}" 257 | echo -e "Your Server Port:${COLOR_GREEN}${serverport}${COLOR_END}" 258 | echo -e "Your Password:${COLOR_GREEN}${shadowsockspwd}${COLOR_END}" 259 | echo -e "Your Encryption Method:${COLOR_GREEN}${ssmethod}${COLOR_END}" 260 | echo -e "Your SSH Port:${COLOR_GREEN}${sshport}${COLOR_END}" 261 | echo "==============================================" 262 | echo "" 263 | echo "Press any key to start...or Press Ctrl+c to cancel" 264 | 265 | char=`get_char` 266 | 267 | [ ! -d ${str_game_dir} ] && mkdir -p ${str_game_dir} 268 | cd ${str_game_dir} 269 | echo $PWD 270 | 271 | # Config shadowsocks 272 | cat > ${str_game_dir}/config.json<<-EOF 273 | { 274 | "server":"${IP}", 275 | "local_port":1080, 276 | "timeout": 600, 277 | "method":"${ssmethod}", 278 | "fast_open": true, 279 | "port_password": 280 | { 281 | "${serverport}": "${shadowsockspwd}" 282 | }, 283 | "_comment": 284 | { 285 | "${serverport}": "The server port comment" 286 | } 287 | } 288 | EOF 289 | chmod 600 ${str_game_dir}/config.json 290 | rm -f ${str_game_dir}/game-server 291 | if [ "${Is_64bit}" == 'y' ] ; then 292 | if [ ! -s ${str_game_dir}/game-server ]; then 293 | if ! wget --no-check-certificate ${game_x64_download_url} -O ${str_game_dir}/game-server; then 294 | echo "Failed to download game-server file!" 295 | exit 1 296 | fi 297 | fi 298 | else 299 | if [ ! -s ${str_game_dir}/game-server ]; then 300 | if ! wget --no-check-certificate ${game_x86_download_url} -O ${str_game_dir}/game-server; then 301 | echo "Failed to download game-server file!" 302 | exit 1 303 | fi 304 | fi 305 | fi 306 | [ ! -x ${str_game_dir}/game-server ] && chmod 755 ${str_game_dir}/game-server 307 | if [ ! -s /etc/init.d/game-server ]; then 308 | if ! wget --no-check-certificate ${program_init_download_url} -O /etc/init.d/game-server; then 309 | echo "Failed to download game-server.init file!" 310 | exit 1 311 | fi 312 | fi 313 | [ ! -x /etc/init.d/game-server ] && chmod +x /etc/init.d/game-server 314 | if [ "${OS}" == 'CentOS' ]; then 315 | chmod +x /etc/init.d/game-server 316 | chkconfig --add game-server 317 | else 318 | chmod +x /etc/init.d/game-server 319 | update-rc.d -f game-server defaults 320 | fi 321 | 322 | if [ "$set_iptables" == 'y' ]; then 323 | # iptables config 324 | iptables -I INPUT -p udp --dport ${serverport} -j ACCEPT 325 | iptables -I INPUT -p tcp --dport ${serverport} -j ACCEPT 326 | iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 327 | if [ "${OS}" == 'CentOS' ]; then 328 | service iptables save 329 | else 330 | echo '#!/bin/bash' > /etc/network/if-post-down.d/iptables 331 | echo 'iptables-save > /etc/iptables.rules' >> /etc/network/if-post-down.d/iptables 332 | echo 'exit 0;' >> /etc/network/if-post-down.d/iptables 333 | chmod +x /etc/network/if-post-down.d/iptables 334 | 335 | echo '#!/bin/bash' > /etc/network/if-pre-up.d/iptables 336 | echo 'iptables-restore < /etc/iptables.rules' >> /etc/network/if-pre-up.d/iptables 337 | echo 'exit 0;' >> /etc/network/if-pre-up.d/iptables 338 | chmod +x /etc/network/if-pre-up.d/iptables 339 | fi 340 | fi 341 | [ -s /etc/init.d/game-server ] && ln -s /etc/init.d/game-server /usr/bin/game-server 342 | /etc/init.d/game-server start 343 | ${str_game_dir}/game-server -version 344 | echo "" 345 | fun_clang.cn 346 | #install successfully 347 | echo "" 348 | echo "Congratulations, Game-Server(XiaoBao) install completed!" 349 | echo -e "Your Server IP:${COLOR_GREEN}${defIP}${COLOR_END}" 350 | echo -e "Your Set IP:${COLOR_GREEN}${IP}${COLOR_END}" 351 | echo -e "Your Server Port:${COLOR_GREEN}${serverport}${COLOR_END}" 352 | echo -e "Your Password:${COLOR_GREEN}${shadowsockspwd}${COLOR_END}" 353 | echo -e "Your Local Port:${COLOR_GREEN}1080${COLOR_END}" 354 | echo -e "Your Encryption Method:${COLOR_GREEN}${ssmethod}${COLOR_END}" 355 | echo "" 356 | echo -e "Game-Server(XiaoBao) status manage: ${COLOR_PINKBACK_WHITEFONT}/etc/init.d/game-server${COLOR_END} {${COLOR_PINK}start${COLOR_END}|${COLOR_GREEN}stop${COLOR_END}|${COLOR_YELOW}restart${COLOR_END}|${COLOR_CYAN_BLUE}status${COLOR_END}}" 357 | #iptables -L -n 358 | } 359 | ############################### install function ################################## 360 | install_game_server_clang(){ 361 | fun_clang.cn 362 | checkos 363 | check_centosversion 364 | check_os_bit 365 | disable_selinux 366 | if [ -s ${str_game_dir}/game-server ] && [ -s /etc/init.d/game-server ]; then 367 | echo "Game-Server(XiaoBao) is installed!" 368 | else 369 | pre_install_clang 370 | fi 371 | } 372 | ############################### configure function ################################## 373 | configure_game_server_clang(){ 374 | if [ -s ${str_game_dir}/config.json ]; then 375 | vim ${str_game_dir}/config.json 376 | else 377 | echo "Game-Server(XiaoBao) configuration file not found!" 378 | fi 379 | } 380 | ############################### uninstall function ################################## 381 | uninstall_game_server_clang(){ 382 | fun_clang.cn 383 | if [ -s /etc/init.d/game-server ] || [ -s ${str_game_dir}/game-server ] ; then 384 | echo "============== Uninstall Game-Server(XiaoBao) ==============" 385 | save_config="n" 386 | echo -e "${COLOR_YELOW}Do you want to keep the configuration file?${COLOR_END}" 387 | read -p "(if you want please input: y,Default [no]):" save_config 388 | 389 | case "${save_config}" in 390 | y|Y|Yes|YES|yes|yES|yEs|YeS|yeS) 391 | echo "" 392 | echo "You will keep the configuration file!" 393 | save_config="y" 394 | ;; 395 | n|N|No|NO|no|nO) 396 | echo "" 397 | echo "You will NOT to keep the configuration file!" 398 | save_config="n" 399 | ;; 400 | *) 401 | echo "" 402 | echo "will NOT to keep the configuration file!" 403 | save_config="n" 404 | esac 405 | checkos 406 | /etc/init.d/game-server stop 407 | if [ "${OS}" == 'CentOS' ]; then 408 | chkconfig --del game-server 409 | else 410 | update-rc.d -f game-server remove 411 | fi 412 | rm -f /usr/bin/game-server /etc/init.d/game-server /var/run/game-server.pid /root/game-server-install.log /root/game-server-update.log 413 | if [ "${save_config}" == 'n' ]; then 414 | rm -fr ${str_game_dir} 415 | else 416 | rm -f ${str_game_dir}/game-server ${str_game_dir}/game-server.log 417 | fi 418 | echo "Game-Server(XiaoBao) uninstall success!" 419 | else 420 | echo "Game-Server(XiaoBao) Not install!" 421 | fi 422 | echo "" 423 | } 424 | ############################### update function ################################## 425 | update_game_server_clang(){ 426 | fun_clang.cn 427 | if [ -s /etc/init.d/game-server ] || [ -s ${str_game_dir}/game-server ] ; then 428 | echo "============== Update Game-Server(XiaoBao) ==============" 429 | checkos 430 | check_centosversion 431 | check_os_bit 432 | killall game-server 433 | remote_init_version=`wget --no-check-certificate -qO- ${program_init_download_url} | sed -n '/'^version'/p' | cut -d\" -f2` 434 | local_init_version=`sed -n '/'^version'/p' /etc/init.d/game-server | cut -d\" -f2` 435 | if [ ! -z ${remote_init_version} ];then 436 | if [[ "${local_init_version}" != "${remote_init_version}" ]];then 437 | echo "========== Update Game-Server(XiaoBao) /etc/init.d/game-server ==========" 438 | if ! wget --no-check-certificate ${program_init_download_url} -O /etc/init.d/game-server; then 439 | echo "Failed to download game-server.init file!" 440 | exit 1 441 | else 442 | echo -e "${COLOR_GREEN}/etc/init.d/game-server Update successfully !!!${COLOR_END}" 443 | fi 444 | fi 445 | fi 446 | [ ! -d ${str_game_dir} ] && mkdir -p ${str_game_dir} 447 | rm -f /usr/bin/game-server ${str_game_dir}/game-server /root/game-server /root/game-server.log 448 | if [ "${Is_64bit}" == 'y' ] ; then 449 | if ! wget --no-check-certificate ${game_x64_download_url} -O ${str_game_dir}/game-server; then 450 | echo "Failed to download game-server file!" 451 | exit 1 452 | fi 453 | else 454 | if ! wget --no-check-certificate ${game_x86_download_url} -O ${str_game_dir}/game-server; then 455 | echo "Failed to download game-server file!" 456 | exit 1 457 | fi 458 | fi 459 | [ ! -x ${str_game_dir}/game-server ] && chmod 755 ${str_game_dir}/game-server 460 | if [ "${OS}" == 'CentOS' ]; then 461 | chmod +x /etc/init.d/game-server 462 | chkconfig --add game-server 463 | else 464 | chmod +x /etc/init.d/game-server 465 | update-rc.d -f game-server defaults 466 | fi 467 | [ -s /etc/init.d/game-server ] && ln -s /etc/init.d/game-server /usr/bin/game-server 468 | if [ -s /root/config.json ] && [ ! -a ${str_game_dir}/config.json ]; then 469 | mv /root/config.json ${str_game_dir}/config.json 470 | fi 471 | /etc/init.d/game-server start 472 | ${str_game_dir}/game-server -version 473 | echo "Game-Server(XiaoBao) update success!" 474 | else 475 | echo "Game-Server(XiaoBao) Not install!" 476 | fi 477 | echo "" 478 | } 479 | clear 480 | rootness 481 | strPath=`pwd` 482 | pre_install_packs 483 | shell_update 484 | # Initialization 485 | action=$1 486 | [ -z $1 ] 487 | case "$action" in 488 | install) 489 | install_game_server_clang 2>&1 | tee /root/game-server-install.log 490 | ;; 491 | config) 492 | configure_game_server_clang 493 | ;; 494 | uninstall) 495 | uninstall_game_server_clang 2>&1 | tee /root/game-server-uninstall.log 496 | ;; 497 | update) 498 | update_game_server_clang 2>&1 | tee /root/game-server-update.log 499 | ;; 500 | *) 501 | fun_clang.cn 502 | echo "Arguments error! [${action} ]" 503 | echo "Usage: `basename $0` {install|uninstall|update|config}" 504 | ;; 505 | esac 506 | -------------------------------------------------------------------------------- /latest/game-server: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clangcn/game-server/755c30f6b25fb7d4e9db2392c09d0901f1013fd2/latest/game-server -------------------------------------------------------------------------------- /latest/game-server-386: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clangcn/game-server/755c30f6b25fb7d4e9db2392c09d0901f1013fd2/latest/game-server-386 --------------------------------------------------------------------------------