Skip to content

Instantly share code, notes, and snippets.

@eyemagine2
Created August 4, 2014 22:08
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 eyemagine2/b46a640c8625f6538315 to your computer and use it in GitHub Desktop.
Save eyemagine2/b46a640c8625f6538315 to your computer and use it in GitHub Desktop.
Configure new eyemagine repo
#!/bin/bash
function getRepoName() {
echo "Enter the name of the repository to configure (all lowercase, one word)..."
read repo
if [ -z "$repo" ]; then
echo "Repository name cannot be empty"
getRepoName
fi
repodir="/home/git/repositories/$repo.git"
if [ ! -d "$repodir" ]; then
echo "Repository directory does not exist ($repodir). Please try again"
getRepoName
fi
}
function getRepoDesc() {
echo "Enter the full, readable name of the repository (Melton Tackle, Braven)..."
read repodesc
if [ -z "$repodesc" ]; then
echo "Repository full name cannot be empty"
getRepoDesc
fi
}
function getRepoContacts() {
echo "Enter a comma separated list of contact emails for the hook events (user1@example.com,user2@example.com)"
read emails
}
# Fetch all required parameters
getRepoName
getRepoDesc
getRepoContacts
# Create description
echo "$repodesc Repository on GT:" > "$repodir/description"
echo "Description added at $repodir/description..."
# Add hook variables
echo "[hooks]
mailinglist = \"$emails\"
senderemail = \"$repo@gt.eyemaginetech.com\"
emailprefix = \"[git repo]: \"
showrev = \"git show -C %s; echo\"" >> "$repodir/config"
echo "Hooks configured at $repodir/config..."
# Symlink post-receive
ln -s /usr/share/git-core/contrib/hooks/post-receive-email "$repodir/hooks/post-receive"
echo "post-receive hook created at $repodir/hooks/post-receive..."
echo "Repository configuration complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment