Skip to content

Instantly share code, notes, and snippets.

@tusbar
Created June 18, 2013 10:27
Show Gist options
  • Save tusbar/5804276 to your computer and use it in GitHub Desktop.
Save tusbar/5804276 to your computer and use it in GitHub Desktop.
Fetch git repositories and update redmine's cache.
#! /usr/bin/env bash
cd /usr/share/redmine
log=log/fetch_repositories
pid=tmp/pids/fetch_repositories.pid
function log() {
date=$(/bin/date --rfc-3339=seconds)
echo "[$date] $*" &>> $log
}
test -f $pid && {
log "[-] Process already running, exiting..."
exit 1
}
log "[+] Creating pid file ($pid)"
echo $$ > $pid
export PATH=/usr/bin
for repo in $(/bin/ls repositories); do
log "[+] Fetching $repo"
/usr/bin/git --git-dir=repositories/$repo fetch || {
log "[-] ... failed"
}
done
log "[+] Getting new commits"
./script/rails runner "Repository.fetch_changesets" -e production || {
log "[-] ... failed"
}
log "[+] Removing pid file ($pid)"
/bin/rm $pid || {
log "[-] ... failed"
}
log "[+] Done, exiting..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment