3 # usage: create <PROJECT> - create a git bare repository named PROJECT.git
4 # this command will setup the repo and send a mail for confirmation.
8 MULTIMAIL
="/usr/doc/git-2.14.5/contrib/hooks/multimail/git_multimail.py"
11 VENVSDIR
="/usr/local/venvs"
16 if "$(git --git-dir="$repodir" rev-parse --is-bare-repository)" = true
26 echo "creating project \"${PROJECT}.git\""
27 echo -n "Describe your project in one line: "
29 if [ ! -d ${GITDIR}/${PROJECT}.git
]; then
30 mkdir
${GITDIR}/${PROJECT}.git
32 cd ${GITDIR}/${PROJECT}.git
34 echo "Remember to insert a README.md file to explain what your project is about."
36 ln -s $MULTIMAIL custom-hooks
/git_multimail.py
38 # check if we are creating a python project
39 if [ $USEVENV == true
]; then
41 cp ${GITDIR}/${BASEDIR}/post-receive-py hooks
/post-receive
42 sed -i "s|{{GITDIR}}|${GITDIR}|g" hooks
/post-receive
43 sed -i "s|{{PROJECT}}|${PROJECT}|g" hooks
/post-receive
44 cp ${GITDIR}/${BASEDIR}/pip_install custom-hooks
/pip_install
45 sed -i "s|{{VENVSDIR}}|${VENVSDIR}|g" custom-hooks
/pip_install
46 sed -i "s|{{PROJECT}}|${PROJECT}|g" custom-hooks
/pip_install
47 chmod 0755 custom-hooks
/pip_install
50 cp ${GITDIR}/${BASEDIR}/post-receive hooks
/post-receive
51 sed -i "s|{{GITDIR}}|${GITDIR}|g" hooks
/post-receive
52 sed -i "s|{{PROJECT}}|${PROJECT}|g" hooks
/post-receive
54 # in any case we setup so that we can deploy
55 cp ${GITDIR}/${BASEDIR}/deploy.sh custom-hooks
/deploy.sh
56 sed -i "s|{{GITDIR}}|${GITDIR}|g" custom-hooks
/deploy.sh
57 sed -i "s|{{PROJECT}}|${PROJECT}|g" custom-hooks
/deploy.sh
58 # add multimail settings to config
63 refchangeShowGraph = true
64 mailingList = "danixland@gmail.com"
65 commitEmailFormat = "html"
68 from = "danix@danix.xyz"
69 administrator = "danix@danix.xyz"
71 logFile = "/var/log/multimail.log"
72 errorLogFile = "/var/log/multimail_err.log"
75 # fix permissions to post-receive and deploy.sh scripts
76 chmod 0755 hooks
/post-receive custom-hooks
/deploy.sh
77 echo $DESCRIPTION > description
79 chown
-R ${GITUSER}:${GITGRP} ${GITDIR}/${PROJECT}.git
80 echo "All done, you can now work on \"${PROJECT}.git\""
81 echo "You can now clone this repository at ssh://danix_git:/${GITDIR}/${PROJECT}.git"
86 if [ "python" == $1 ]; then
88 # this is a python project. Let's create a virtualenv
92 read -p 'Python project name: ' PROJECT
94 virtualenv
${VENVSDIR}/${PROJECT}
95 echo "virtual environment created inside ${VENVSDIR}/${PROJECT}"
100 read -p 'Project name: ' PROJECT
103 if [ ! -d ${GITDIR}/${PROJECT}.git
]; then
106 echo "Project directory ${PROJECT}.git already exists."
107 if [ $
(ls -A ${GITDIR}/${PROJECT}.git
) ]; then
108 if is_bare
${GITDIR}/${PROJECT}.git
110 echo "looks like \"${PROJECT}.git\" is an existing git project directory, choose another name."
113 echo "\"${PROJECT}.git\" is not empty, I can't create a Git Project in it. Choose another name."
117 echo "\"${PROJECT}.git\" is an empty directory. Do you want to initialize a Git Project here? [y/N]"
124 echo "Aborting due to user request."
128 # we assume no as default answer.
129 echo "you said \"$answer\" which I don't understand, so to me is no. Aborting."