Created
June 18, 2013 10:27
-
-
Save tusbar/5804276 to your computer and use it in GitHub Desktop.
Fetch git repositories and update redmine's cache.
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
#! /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