#!/bin/bash

source ~/.gamerc

COREDUMP_ROOT_DIRECTORY="${WORKING_DIRECTORY}/www/core"
COREDUMP_OLD_DIRECTORY="${WORKING_DIRECTORY}/www/core/live_log"
#TIME_INTERVAL="5"
#CHECK_TIME_INTERVAL=$(date --date="${TIME_INTERVAL} minutes ago" +'%Y-%m-%d %H:%M') 
TEST_SERVER_IP=${TEST_SERVER_GLOBAL_IP}
PATCH_SERVER_IP=${REMOTE_PATCH_SERVER}
REMOTE_DIRECTORY_ON_PATCH="upload/${COUNTRY_CODE}/Log"


cd ${COREDUMP_ROOT_DIRECTORY}

#find . -name "${GAME_TYPE}-${COUNTRY_CODE}-*.core_dump.*.tar.gz" -newermt "${CHECK_TIME_INTERVAL}" | xargs ls {}

#lftp -e 'mput test_core*; quit' http://60.199.246.187/upload/HK/Log
lftp -e "mput *.tgz ; quit" http://${PATCH_SERVER_IP}/${REMOTE_DIRECTORY_ON_PATCH} 

ls *.tgz -hltra | awk -F" " '{print $9}' | sed "s/^/\/upload\/${COUNTRY_CODE}\/Log\//"

mv *.tgz ${COREDUMP_OLD_DIRECTORY}
