#!/bin/bash
workdir="$0"
echo "CA updater script for linux"
echo "Type ctrl+c to terminate script at any moment"
if test -d ~/.spring/ca
then
	cd ~/.spring/ca/trunk/
	echo "updating svn. this may take a while"
	svn up
else
	echo "Making necessary configurations"
	mkdir ~/.spring/ca
	cd ~/.spring
	if test -d mods
	then
		echo "using existing ~/spring/mods directory as a default moddir."
	else
		echo "To make it work you'll need to enter"
		echo "path to the mods directory of spring(e.g. ~/.spring/mods):"
		read
		echo "creating a symlink to effective mods directory"
		ln -s "$REPLY" mods
	fi
	cd ca
	echo "making an svn checkout. this will take a while."
	svn co svn://svn.caspring.org/trunk/ trunk
fi
echo "making modfiles and installing them..."
cd ~/.spring/ca/trunk/
make install
echo "Update complete. If there were no errors you may play now=)"