make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / git-server / git-repo-mgmt
blob2072e7b853338d26dadd35765b033a50eb5cecf1
1 #!/bin/bash
3 set -u
5 directory=$1
7 echo "----" >&2
8 echo "Performing repo management commands..." >&2
11 set -e
12 set -o pipefail
14 GIT_DIR="$directory" git show repo-mgmt:access |\
15 while read -r line
17 case "$line" in
18 (public)
19 echo "Making '$directory' public..." >&2
20 chmod o+rx "$directory"
22 (private)
23 echo "Making '$directory' private..." >&2
24 setfacl -b "$directory"
25 chmod g-rwx,o-rwx "$directory"
27 (default)
28 # leave permissions as they are set at the beginning
29 true
31 (delete)
32 echo "Deleting '$directory'..." >&2
33 rm -rf --one-file-system "$directory"
35 (*)
36 echo "Unknown directive: '$line'" >&2
38 esac
39 done
43 set -e
44 set -o pipefail
46 default_branch=$(GIT_DIR="$directory" git show repo-mgmt:default-branch)
47 if [ -n "$default_branch" ]
48 then
49 echo "Setting default branch to '$default_branch'..." >&2
50 GIT_DIR="$directory" git symbolic-ref HEAD refs/heads/"$default_branch"
54 errstatus=$?
55 echo "Repo management commands are over." >&2
56 echo "----" >&2
57 exit $errstatus