aboutsummaryrefslogtreecommitdiff
path: root/server/mkrepo.sh
blob: 9c405292033f0b47d5aa2adce83eeb564f441de2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /usr/bin/env bash

# Create remote git repository (on the server). You must run this script
# from the directory where you want the repository to be created.
#
# Usage: mkrepo.sh [<options>] <name>
#
# --private  make the repository private
#
# Note: <name> if without the .git suffix.
#
trap 'exit 1' ERR

function error ()
{
  echo "$*" 1>&2
}

public=y

while [ $# -gt 0 ]; do
  case $1 in
    --private)
      public=n
      shift
      ;;
    -*)
      error "unknown option: $1"
      exit 1
      ;;
    *)
      break
      ;;
  esac
done

if [ "$1" = "" ]; then
  error "repository name expected"
  exit 1
fi

r=$1.git

mkdir $r
chgrp scm $r
git --bare init --shared=all $r
error "Enter project description (one line; or edit $r/descrition later)"
error "Hit Ctrl-D when done"
cat >$r/description
chgrp -R scm $r

if [ "$public" = "y" ]; then
  f=$r/git-daemon-export-ok
  touch  $f
  chgrp scm $f
  chmod g+w $f
fi

mv $r/hooks/post-update.sample $r/hooks/post-update