html/volunteers: clean up some old style `/w` links
[girocco.git] / bin / create-personal-mob-area
blob96d85ae77489d98047666bcc758a4bdb67b1c3d7
1 #!/bin/sh
3 set -e
5 . @basedir@/shlib.sh
7 [ "$cfg_mob" = "mob" ] || { echo "mob support not enabled" >&2; exit 1; }
9 proj="$1"
10 [ -d "$cfg_reporoot/$proj.git" ] || { echo "Invalid project name: $1" >&2; exit 1; }
12 [ -f "$cfg_reporoot/$proj.git/.nofetch" ] || { echo "Mirrors may not use mob: $1" >&2; exit 1; }
14 projdir="$cfg_reporoot/$proj.git"
16 [ -L "$projdir/HEAD" ] ||
17 ! [ -f "$projdir/HEAD" ] ||
18 ! [ -f "$projdir/config" ] ||
19 ! [ -f "$projdir/description" ] ||
20 ! [ -f "$projdir/hooks/pre-receive" ] ||
21 ! [ -x "$projdir/hooks/pre-receive" ] ||
22 ! [ -f "$projdir/hooks/post-receive" ] ||
23 ! [ -x "$projdir/hooks/post-receive" ] ||
24 ! [ -f "$projdir/hooks/update" ] ||
25 ! [ -x "$projdir/hooks/update" ] ||
26 ! [ -d "$projdir/objects" ] ||
27 ! [ -d "$projdir/info" ]
28 then
29 echo "Incorrectly set up project: $1" >&2
30 exit 1
33 umask 002
35 mkdir -p "$projdir/refs/mob" "$projdir/mob/refs"
36 chmod 02775 "$projdir/refs" "$projdir/refs/mob" "$projdir/mob" "$projdir/mob/refs" ||
37 echo "Warning: could not chmod 02775 on all dirs" >&2
39 [ -d "$projdir/mob/refs/heads" ] || ln -sfn ../../refs/mob "$projdir/mob/refs/heads"
40 [ -d "$projdir/mob/refs/mob" ] || ln -sfn ../../refs/mob "$projdir/mob/refs/mob"
42 [ -L "$projdir/mob/packed-refs" ] || ln -sfn ../packed-refs.mob "$projdir/mob/packed-refs"
43 [ -d "$projdir/mob/objects" ] || ln -sfn ../objects "$projdir/mob/objects"
44 [ -d "$projdir/mob/info" ] || ln -sfn ../info "$projdir/mob/info"
45 [ -d "$projdir/mob/hooks" ] || ln -sfn ../hooks "$projdir/mob/hooks"
46 [ -f "$projdir/mob/description" ] || ln -sfn ../description "$projdir/mob/description"
47 [ -f "$projdir/mob/config" ] || ln -sfn ../config "$projdir/mob/config"
49 cp -p -f "$projdir/HEAD" "$projdir/mob/HEAD.$$"
50 mv -f "$projdir/mob/HEAD.$$" "$projdir/mob/HEAD"
51 rm -f "$projdir/mob/HEAD.$$"
53 git --git-dir="$projdir" for-each-ref --format='%(objectname) %(refname)' >"$projdir/packed-refs.mob.$$" || :
54 if [ -s "$projdir/packed-refs.mob.$$" ]; then
55 mv -f "$projdir/packed-refs.mob.$$" "$projdir/packed-refs.mob"
57 rm -f "$projdir/packed-refs.mob.$$"
59 exit 0