#!/bin/bash
source ~/.gamerc

directory="$WORKING_DIRECTORY/www/download/"
testserver_ip=${TEST_SERVER_GLOBAL_IP}
gametype=${GAME_TYPE}
country=${COUNTRY_CODE}
date=$(date "+%Y-%m-%d")

cd ${directory}

output_file_name=$(ls -hltra * | tail -n 1 | awk -F" " '{print $9}')
output_file_size=$(ls -ltra * | tail -n 1 | awk -F" " '{print $5}')
output_file_size_human=$(ls -hltra * | tail -n 1 | awk -F" " '{print $5}')
output_file=$(echo -n ${output_file_size}\(${output_file_size_human}\) ${output_file_name})
output_file_md5=$(md5sum ${output_file_name})

link_directory=$(echo ${directory} | sed -r 's/(.*)\/www(.*)/\2/')

link+='http://'
link+=${testserver_ip}
link+=${link_directory}
link+=${output_file_name}

echo "/*"
echo "//${gametype}${country} ${date}"
echo "1. File Download Link: "
echo ${link}
echo "2. File Size: "
echo ${output_file}
echo "3. MD5: "
echo ${output_file_md5}
echo "*/"
