Skip to content

Instantly share code, notes, and snippets.

@noqqe
Created November 27, 2010 11:41
Show Gist options
  • Save noqqe/717822 to your computer and use it in GitHub Desktop.
Save noqqe/717822 to your computer and use it in GitHub Desktop.
post-recieve hook for bare repos to use with redmine
#!/bin/bash
# post-recieve hook for redmine git repos
# clone git repo to redmine directory
# Copyright: (C) 2010 Florian Baumann <[email protected]>
# License: GPL-3 <http://www.gnu.org/licenses/gpl-3.0.txt>
# Date: Thursday 2010-11-26
# print some informations for user
echo "running post-receive hook..."
### get environment informations
#
# Read repo from pwd
REPO=$(readlink -f .)
# clean repo name
NAME=$(echo $REPO | sed -e 's/.*\/repositories\/\(.*\).git$/\1/')
# directory for redmine
STOREDIR="/var/cache/redmine/default/repos/${NAME}/"
### hardcore cloneing action begins below
#
#delete existing repo
if [ -e $STOREDIR ]; then
rm -r $STOREDIR
fi
# clone new repo
echo "creating repo for redmine on $(hostname)..."
git clone $REPO $STOREDIR &> /dev/null
# more user informations
if [ $? -eq 0 ]; then
echo "redmine repo successfully updated"
else
echo "some problems O_o"
echo ""
fi
# these permissions are _required_ !
chmod -R 755 $STOREDIR
chmod 755 ${STOREDIR}.git
if [ "$UID" = "0" ]; then
chown -R git:git $STOREDIR
chown -R git:git ${STOREDIR}.git
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment