Fix test for directory
[git-tools-moved-to-github.git] / id-new-project / id-new-project.sh
1 #!/bin/sh
2
3 usage() {
4         echo ""
5         echo "Usage:"
6         echo "id-new-project.sh srcdir description {pub/private/admin}"
7         echo "For example:"
8         echo "id-new-project.sh ../myproj \"Which does good things\" private"
9         exit 1
10 }
11
12 SRC=$1
13 DESC=$2
14 TYPE=$3
15
16 case "${TYPE}" in
17         pub | private | admin ) ;;
18         * ) echo "invalid type: '$TYPE', use pub or private or admin "; usage ;;
19 esac
20
21 if test ! -e post-receive; then
22         echo "file post-receive must be in the current directory"
23         exit 1  
24 fi
25
26 PROJ=`basename $SRC`
27
28 if test -d ${PROJ}.git; then
29         echo "${PROJ}.git already exists"
30         exit 1
31 fi
32
33
34 if git clone --bare $SRC ${PROJ}.git; then
35         cd ${PROJ}.git
36         touch git-daemon-export-ok
37         echo "${DESC}" >description
38         git config core.sharedRepository true
39         git config core.ignorecase true
40         cp ../post-receive hooks/post-receive
41         chmod +x hooks/post-receive
42         git config hooks.mailinglist gitid@indexdata.dk
43         cd ..
44         scp -P 222 -r ${PROJ}.git git.indexdata.com:/home/git/${TYPE}
45         ssh -p 222 git.indexdata.com "cd /home/git/${TYPE}/${PROJ}.git && chmod -R g+w . && chgrp -R git . && find . -type d | xargs chmod g+s"
46 fi
47