X-Git-Url: https://git.danix.xyz/?p=git_shell.git;a=blobdiff_plain;f=create;h=e7185fdfc5f6e4ea96ddf6aecb5e125d3897dd2a;hp=04d299a8b4c0195f06cccfcf4ce45ded698db907;hb=11e0ea6b6d39aac3e2e6fbd53e07f7839dc00a70;hpb=81873de46fa20d0d13ee44659850c07c2b247816 diff --git a/create b/create index 04d299a..e7185fd 100755 --- a/create +++ b/create @@ -4,7 +4,8 @@ # this command will setup the repo and send a mail for confirmation. GITDIR="/var/git" -MULTIMAIL="/usr/doc/git-2.14.5/contrib/hooks/multimail/git_multimail.py" +BASEDIR=".gitbase" +MULTIMAIL="/usr/doc/git-*/contrib/hooks/multimail/git_multimail.py" GITUSER="git" GITGRP="git" VENVSDIR="/usr/local/venvs" @@ -23,7 +24,8 @@ function is_bare() { function git_init() { PROJECT=$1 echo "creating project \"${PROJECT}.git\"" - read -p "Describe your project in one line: " DESCRIPTION + echo -n "Describe your project in one line: " + read DESCRIPTION if [ ! -d ${GITDIR}/${PROJECT}.git ]; then mkdir ${GITDIR}/${PROJECT}.git fi @@ -32,32 +34,28 @@ function git_init() { echo "Remember to insert a README.md file to explain what your project is about." mkdir custom-hooks ln -s $MULTIMAIL custom-hooks/git_multimail.py - touch hooks/post-receive - cat > hooks/post-receive < custom-hooks/pip_install << EOPIP -#!/bin/sh -while read oldrev newrev refname; do - if [[ \$refname =~ .*/master$ ]]; then - # definitely updating master; - CHECKFILE=\$(git ls-tree --full-tree -r HEAD |grep requirements.txt |awk '{print \$3}') - TMPREQ=\$(git cat-file -p \$CHECKFILE > /tmp/${PROJECT}-req.txt) - if [ \$CHECKFILE ]; then - ${VENVSDIR}/${PROJECT}/bin/pip install -r /tmp/${PROJECT}-req.txt - fi - if git diff-tree --name-only -r -z \$oldrev \$newrev \$CHECKFILE; then - ${VENVSDIR}/${PROJECT}/bin/pip install -r /tmp/${PROJECT}-req.txt - fi - fi -done -EOPIP + # if yes + cp ${GITDIR}/${BASEDIR}/post-receive-py hooks/post-receive + sed -i "s|{{GITDIR}}|${GITDIR}|g" hooks/post-receive + sed -i "s|{{PROJECT}}|${PROJECT}|g" hooks/post-receive + cp ${GITDIR}/${BASEDIR}/pip_install custom-hooks/pip_install + sed -i "s|{{VENVSDIR}}|${VENVSDIR}|g" custom-hooks/pip_install + sed -i "s|{{PROJECT}}|${PROJECT}|g" custom-hooks/pip_install + chmod 0755 custom-hooks/pip_install + else + # otherwise + cp ${GITDIR}/${BASEDIR}/post-receive hooks/post-receive + sed -i "s|{{GITDIR}}|${GITDIR}|g" hooks/post-receive + sed -i "s|{{PROJECT}}|${PROJECT}|g" hooks/post-receive fi + # in any case we setup so that we can deploy + cp ${GITDIR}/${BASEDIR}/deploy.sh custom-hooks/deploy.sh + sed -i "s|{{GITDIR}}|${GITDIR}|g" custom-hooks/deploy.sh + sed -i "s|{{PROJECT}}|${PROJECT}|g" custom-hooks/deploy.sh + # add multimail settings to config cat >> config < custom-hooks/deploy.sh < description cd ${GITDIR}/ chown -R ${GITUSER}:${GITGRP} ${GITDIR}/${PROJECT}.git echo "All done, you can now work on \"${PROJECT}.git\"" + echo "You can now clone this repository at ssh://danix_git:/${GITDIR}/${PROJECT}.git" exit 0 }