#!/bin/bash

echo
echo "Publish new built games?[YES,no]?"
read UPLOAD_FTP
[[ -z $UPLOAD_FTP ]] && UPLOAD_FTP="yes" && echo $UPLOAD_FTP #default


./pack-umount.sh $PACK_MOUNT_DIR  > /dev/null 2>&1
#mkdir $PACK_MOUNT_DIR #if mount poind does not exist, script will create a temporary mount point!
cd Outer
echo Started build of OUTER Game Packages
for d in */ ; do
        PACK_NAME=${d%%/}
        if [[ $PACK_NAME == *"pack-config"* ]]; then
                continue
        fi

	echo __________________________________________________________________________________
	if [ $UPLOAD_FTP == "yes" ] || [ $UPLOAD_FTP == "YES" ]; then
		/bin/bash -c "./pack-make-v7-OUTER-SINGLE.sh $PACK_NAME PUBLISH"
	else
		/bin/bash -c "./pack-make-v7-OUTER-SINGLE.sh $PACK_NAME"
	fi
	if [ $? -ne 0 ]; then
		echo "ERORR occured while building $PACK_NAME"
		cd ..
		exit 1
	fi

done
cd ..

exit 0
