#!/bin/bash

red="\e[0;91m"
green="\e[0;92m"
clean="\e[0m"


if [ $(which curl) != "/usr/bin/curl" ] 
then

	echo -e "\n${red}Benötigt curl.\n"
	exit 1
else

reset

gitdir=$(pwd)

echo -e "${green}Installiere Codestylechecker...${clean}\n"

mkdir -p $HOME/bin/codestylechecker

cd $HOME/bin/codestylechecker

curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
curl -OL https://alpha.finc.info/vufind2/logs/alpha/CodeSniffer.conf

chmod +x $HOME/bin/codestylechecker/phpcs.phar

echo -e "\n${green}Kopiere Hooks nach ${gitdir}/.git/hooks\n${clean}"

cd $gitdir/.git/hooks/

curl -OL https://alpha.finc.info/vufind2/logs/alpha/pre-commit
curl -OL https://alpha.finc.info/vufind2/logs/alpha/pre-push

chmod +x $gitdir/.git/hooks/pre-commit
chmod +x $gitdir/.git/hooks/pre-push

echo -e "\n${green}Fertig!${clean}\n"

exit 0

#heiko.wolf@uni-leipzig.de, 2021
