#!/bin/bash
#usage: init.sh $name

if [ $# -eq 0 ]
  then
    echo "No arguments supplied"
fi

set -e

mkdir $1
cd $1
git init
git config receive.denyCurrentBranch ignore
cat  > .git/hooks/post-update <<EOL
#!/bin/sh
cd /home/javaexperience/git-repositories/$1
unset GIT_DIR
git checkout master
git reset --hard
git update-server-info
_JAVA_OPTIONS=-Djdk.net.URLClassPath.disableClassPathURLCheck=true\
	mvn deploy -Dexternal.version=$(git describe --tags --always --dirty=-dirty) | mail -s "Git: JVX-$1 > post-receive hook > mvn deploy" maven@javaexperience.eu
EOL


chmod 755 .git/hooks/post-update
