blob: 1a40dffb73c1d0a690c6b3d12ffcaacca2be200f (
plain) (
tree)
|
|
#!/bin/sh
set -e
usage() {
printf "usage: git init-acl directory [user...]\n" >&2
exit 1
}
acl_mask() {
# Set the ACL mask for the directory. The default mask will be inherited by
# new directories and files (where it will correctly be set to rw-)
setfacl -m "d:m:rwx,m:rwx" "$1"
}
add_to_acl() {
# Recursively apply all necessary ACL settings as we may be reinitializing
# the git repository with additional authorised users.
# Take care to specify the ACL mask explicitly to make sure it is set to
# rw- on files and rwx on directories (automatic recalculation ends up
# setting rwx even on non-directory files)
setfacl -Rm "d:u:$2:rwX,u:$2:rwX,d:m:rwX,m:rwX" "$1"
}
test $# -ge 1 || usage
dir=$1
shift
mkdir -p "$dir"
acl_mask "$dir"
for user in "$(id -un)" "$@"; do
add_to_acl "$dir" "$user"
done
exec git init --bare "$dir"
|