#!/bin/bash
source ~/.gamerc

# 遠端 XLOG 遊戲名稱接收目錄不存在, 協助新增目錄.
rsync /dev/null 104.199.226.218::UNCLEAN/${GAME_TYPE}${COUNTRY_CODE}/

for FULL_PATH_DIRECTORY in $(ls -hld ~/servers*/*Server* | egrep 'Mission|World|Zone' | grep -v core | awk -F" " '{print $NF}'); do 
	#SET_NUMBER=$(basename ${FULL_PATH_DIRECTORY} | sed 's/.*Server//' | cut -c 1); 
	#echo "${FULL_PATH_DIRECTORY} => ${SET_NUMBER}"; 

	DIRECTORY=$(basename ${FULL_PATH_DIRECTORY})
	# 遠端 XLOG 遊戲 Server 接收目錄不存在, 協助新增目錄.
	rsync /dev/null 104.199.226.218::UNCLEAN/${GAME_TYPE}${COUNTRY_CODE}/${DIRECTORY}/

	# 同步各 Server 的 onelevel / twolevel 檔案到 XLOG
	rsync -avz ${FULL_PATH_DIRECTORY}/*level* 104.199.226.218::UNCLEAN/${GAME_TYPE}${COUNTRY_CODE}/${DIRECTORY}/
done
