if [ ! $1 ] ; then
echo "################################################"
echo "GameCP steambuilder Running on " `date`
echo ""
echo "Counter-strike srcds and hlds versions are"
echo "installed to:"
echo "   /usr/local/gcp/installs"
echo ""
echo "################################################"
echo ""
echo ""
echo "Please wait..."
sleep 5

echo "Starting steambuilder, ctrl +c to cancel"
sleep 1

fi;

echo "Creating required directories"

mkdir -p /usr/local/gcp/installs/
cd /usr/local/gcp/installs/

mkdir -p cs
mkdir -p css

if [ ! -f steam ] ; then
echo "Downloading Steam"

wget http://cvs.gamecp.com/steam.tar.gz
tar zxvf steam.tar.gz
rm -f steam.tar.gz
chmod +x steam

fi;

echo "Updating steam..."
./steam > /dev/null

# Reference 2
# Copy steam and its files to each game so it can update itself
cp steam cs
cp steam css
cp test*.so cs
cp test*.so css

echo "Executing Steam installer/updater for HALF-LIFE:"

# Reference 3
# Execute the steam updater
cd /usr/local/gcp/installs/cs
./steam  -command update -game cstrike -dir . -verify_all 
chmod +x /usr/local/gcp/installs/cs/hlds_*
echo "Executing Steam installer/updater for SOURCE:"


cd /usr/local/gcp/installs/css
./steam  -command update -game "counter-strike source" -dir . -verify_all 
chmod +x /usr/local/gcp/installs/css/srcds_*




echo "################################################"
echo ""
echo "GameCP has downloaded Counter Strike and Counter Strike Source"
echo "It is located in /usr/local/gcp/installs"
echo "To update your files re-execute this script"
echo ""
echo "################################################"



