taskd/clone.sh: avoid unnecessary escape in darcs:// -> http:// mapping
[girocco/test-forks.git] / jobd / jobd.sh
blob709d70cd1a371a3d17ca9f6a6abb605371fab9a9
1 #!/bin/bash
3 # jobd - Perform Girocco maintenance jobs
5 # jobd is Girocco repositories maintenance servant; it periodically
6 # checks all the repositories and updates mirrored repositories and
7 # repacks push-repositories when needed.
9 # Execute with parameter --all-once to run only once (on all projects)
10 # instead of in infinite loop. Or call with parameter --one and name
11 # of a project (not full path, without .git suffix) to run maintenance
12 # only on that particular project.
14 # Use -q as VERY FIRST parameter to enable quiet mode (use in cronjobs).
16 . @basedir@/shlib.sh
18 set -e
19 export show_progress=1
21 # Lock setup
23 if [ -e /tmp/jobd.lock ]; then
24 echo "Locked! Stale /tmp/jobd.lock?" >&2
25 exit 1
27 echo $$ >/tmp/jobd.lock
28 trap "rm /tmp/jobd.lock" SIGINT SIGTERM EXIT
31 ## Single-project routine
33 check_one_proj()
35 proj="$1"
36 if [ ! -d "$cfg_reporoot/$proj.git" ]; then
37 echo "WARNING: Skipping non-existing project $proj" >&2
38 return
40 if [ ! -e "$cfg_reporoot/$proj.git"/.nofetch ]; then
41 "$cfg_basedir"/jobd/update.sh "$proj"
43 if [ -n "$show_progress" ]; then
44 "$cfg_basedir"/jobd/gc.sh "$proj"
45 else
46 "$cfg_basedir"/jobd/gc.sh "$proj" 2>&1 | grep -v '^Pack.*created\.$'
51 ## Main loop body
53 check_all_projects()
55 get_repo_list | while read proj; do
56 check_one_proj "$proj"
57 done
61 ## Main program
63 if [ "$1" = "-q" ]; then
64 export show_progress=
65 shift
68 case "$1" in
69 "")
70 while true; do
71 check_all_projects
72 sleep 10
73 done;;
74 "--all-once")
75 check_all_projects;;
76 "--one")
77 check_one_proj "$2";;
79 echo "Usage: $0 [-q] [--all-once | --one PRJNAME]" >&2
80 exit 1;;
81 esac