Skip to content

Instantly share code, notes, and snippets.

@melmi
Last active January 3, 2016 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melmi/e43e1aa934c6d7852c1b to your computer and use it in GitHub Desktop.
Save melmi/e43e1aa934c6d7852c1b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
basedir="/git/"
access_group="developers"
show_err() {
echo
echo "add-repo: an error occured."
echo
echo "Usage:"
echo " add-repo <repo_name>"
echo
echo "Check if base variables at the start of the script are set correctly."
echo "You may also need root privilages to run this script."
echo
exit 1
}
if [ -z "$1" ]; then show_err; fi
trap show_err ERR
startdir="`pwd`"
repodir="$basedir$1.git"
sudo mkdir -p "$repodir"
cd "$repodir"
sudo git init --quiet --bare
sudo git config core.sharedRepository group
sudo chgrp -R $access_group .
sudo chmod -R g+rwX .
sudo find . -type d -exec chmod g+ws '{}' +
cd "$startdir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment