#!/bin/bash
#===============================================================================
#
#          FILE: change_gw
#
#         USAGE: change_gw
#
#   DESCRIPTION: Get the newest GatewayServer binary from ftp(path: ~/patch/BGW/)
#                and change the GatewayServer binary directly
#
#       OPTIONS: N/A
#
#  REQUIREMENTS:
#
#         NOTES:
#
#          BUGS:  ---
#        AUTHOR: rickz (Rick Zhang), xlrickz@gmail.com
#       COMPANY: X-LEGEND Entertainment Corp.
#       CREATED: Mon Oct 31 17:54:50 KST 2011
#      REVISION: 1.0
#
#          TODO:
#
#===============================================================================

#set -o nounset                              # Treat unset variables as an error
#set -m                                      # Enable job control


source ~/.gamerc

rm -f ~/patch/BGW/Gateway*
yes | TestCtrl patch TEST BGW
chmod 755 ~/patch/BGW/Gateway*

ssh accountdb "SKServer stop GatewayServer"
ssh accountdb "cp -v ~/common/bin/GatewayServer ~/common/bin/GatewayServer.$(date +%Y%m%dT%H%M%S)"
scp ~/patch/BGW/GatewayServer bgw:~/common/bin/
ssh accountdb "SKServer start GatewayServer"

sleep 3
ssh accountdb "killall tail"
