2014-01-03 10:32:13 -08:00
#!/bin/bash
2014-01-05 19:51:52 -05:00
repositoryUrl = ${ 1 :- https : //github.com/codecombat/codecombat.git }
2014-01-03 10:32:13 -08:00
deps = ( git python )
2014-01-08 15:14:56 -05:00
NODE_VERSION = v0.10
2014-01-03 10:32:13 -08:00
function checkDependencies { #usage: checkDependencies [name of dependency array] [name of error checking function]
declare -a dependencyArray = ( " ${ !1 } " )
for i in " ${ dependencyArray [@] } "
do
command -v $i >/dev/null 2>& 1 || { $2 " $i " >& 2; exit 1; }
done
}
2014-03-29 18:23:58 -05:00
function openUrl {
case " $OSTYPE " in
darwin*)
open $@ ; ;
linux*)
xdg-open $@ ; ;
*)
echo " $@ " ; ;
esac
}
2014-01-03 10:32:13 -08:00
function basicDependenciesErrorHandling {
case " $1 " in
"python" )
echo "Python isn't installed. Please install it to continue."
read -p "Press enter to open download link..."
2014-03-29 18:23:58 -05:00
openUrl http://www.python.org/download/
2014-01-03 10:32:13 -08:00
exit 1
; ;
"git" )
2015-01-27 22:33:38 +00:00
echo "Please install Git (if you're running mac, this is included in the XCode command line tools)."
2014-01-03 10:32:13 -08:00
esac
}
2014-01-08 15:14:56 -05:00
2014-01-03 10:32:13 -08:00
function checkIsRoot {
if [ [ $EUID -ne 0 ] ] ; then
echo " This script must be run as root (run 'sudo ./ $me $installDirectory ') " 1>& 2
exit 1
fi
}
2014-01-08 15:14:56 -05:00
function checkNodeVersion {
#thanks https://gist.github.com/phatblat/1713458
node --version | grep ${ NODE_VERSION }
if [ [ $? != 0 ] ] ; then
echo "Node was found, but not version 0.10. Make sure 0.10 is installed before running the install script."
echo "Also, make sure `sudo node -v` also returns v0.10.x."
exit 1
fi
}
2014-01-03 10:32:13 -08:00
checkDependencies deps[ @] basicDependenciesErrorHandling
2014-01-08 15:14:56 -05:00
#check for node
2014-02-12 11:05:19 -08:00
if command -v node >/dev/null 2>& 1; then
checkNodeVersion
fi
2014-06-17 19:44:32 +01:00
#check if a git repository already exists here
if [ -d .git ] ; then
echo "A git repository already exists here!"
else
#install git repository
git clone $repositoryUrl coco
#python ./coco/scripts/devSetup/setup.py
echo "Now copy and paste 'sudo python ./coco/scripts/devSetup/setup.py' into the terminal!"
fi