Created
February 4, 2014 17:42
-
-
Save lpar/8808597 to your computer and use it in GitHub Desktop.
Shell script to make a shared Git repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CMDNAME=`basename $0` | |
GROUP=$1 | |
REPODIR=$2 | |
if [ -z $REPODIR ]; then | |
echo "usage: $CMDNAME <group> <dir>" | |
echo "creates a shared Git repository for group <group> in the specified directory" | |
exit 0 | |
fi | |
if [ -z `grep ^$GROUP /etc/group` ]; then | |
echo "no such group $GROUP" | |
exit 1 | |
fi | |
if [ `id -u` != '0' ]; then | |
echo "this command must be run as root" | |
exit 2 | |
fi | |
if [ -e $REPODIR ]; then | |
echo "destination directory already exists" | |
exit 3 | |
fi | |
CWD=`pwd` | |
mkdir -p $REPODIR | |
cd $REPODIR | |
# At some point every copy of Git will be recent enough to have the | |
# --shared=group option in git-init | |
git --bare init | |
git config core.sharedRepository group | |
cd .. | |
chmod -R g+rwXs $REPODIR | |
chgrp -R $GROUP $REPODIR | |
cd $CWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment