61 lines
1.3 KiB
Bash
Executable File
61 lines
1.3 KiB
Bash
Executable File
#!/bin/sh -efu
|
|
|
|
. gitery-sh-functions
|
|
|
|
usage()
|
|
{
|
|
[ -z "$*" ] || message "$*"
|
|
echo >&2 "usage: $PROG <path to git repository> [<path to directory>]"
|
|
exit 1
|
|
}
|
|
|
|
[ "$#" -ge 1 ] ||
|
|
usage 'Not enough arguments.'
|
|
[ "$#" -le 2 ] ||
|
|
usage 'Too many arguments.'
|
|
[ "${1-}" != '--help' ] ||
|
|
usage
|
|
|
|
[ -n "${PEOPLE_DIR:-}" ] ||
|
|
fatal 'PEOPLE_DIR undefined'
|
|
|
|
[ -n "${SRPMS_DIR:-}" ] ||
|
|
fatal 'SRPMS_DIR undefined'
|
|
|
|
[ -n "${GEARS_DIR:-}" ] ||
|
|
fatal 'GEARS_DIR undefined'
|
|
|
|
cd
|
|
|
|
repo0="$1"; shift
|
|
case "$repo0" in
|
|
ftp://*|git://*|http://*|https://*|rsync://*) repo="$repo0" ;;
|
|
*) repo="$(validate_local_exported_gitdir "$repo0")"
|
|
people="$(readlink -ev "$PEOPLE_DIR")"
|
|
gears="$(readlink -ev "$GEARS_DIR")"
|
|
srpms="$(readlink -ev "$SRPMS_DIR")"
|
|
case "$(readlink -ev "$repo")" in
|
|
"$people"/*|"$gears"/*|"$srpms"/*) ;;
|
|
*) fatal "$repo0: git repository does not belong to allowed directory tree" ;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
if [ "$#" -ge 1 ]; then
|
|
dir0="$1"; shift
|
|
else
|
|
dir0="${repo0##*/}"
|
|
fi
|
|
|
|
dir="$(validate_user_gitdir "$dir0")"
|
|
if [ -e "$dir" ]; then
|
|
fatal "$dir0: destination already exists"
|
|
fi
|
|
|
|
git clone --bare --template="$GIT_TEMPLATE_DIR" "$repo" "$dir" >/dev/null
|
|
cd "$dir"
|
|
echo "${dir%.git}" >description
|
|
install -m600 /dev/null git-daemon-export-ok
|
|
GIT_DIR="$PWD" "$HOOKS_DIR/post-update"
|
|
printf '%s:\t%s\n' "$PROG" "$PWD"
|