daemons/repod -> jobd/jobd, daemons/cloned -> taskd/taskd
[girocco/test-forks.git] / jobd / jobd.sh
blob5b83a9e6c86d95e8709508a9cf3c2dc2a76e2570
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 [ ! -e "$cfg_reporoot/$proj.git"/.nofetch ]; then
37 "$cfg_basedir"/jobd/update.sh "$proj"
39 if [ -n "$show_progress" ]; then
40 "$cfg_basedir"/jobd/gc.sh "$proj"
41 else
42 "$cfg_basedir"/jobd/gc.sh "$proj" 2>&1 | grep -v '^Pack.*created\.$'
47 ## Main loop body
49 check_all_projects()
51 get_repo_list | while read proj; do
52 check_one_proj "$proj"
53 done
57 ## Main program
59 if [ "$1" = "-q" ]; then
60 export show_progress=
61 shift
64 case "$1" in
65 "")
66 while true; do
67 check_all_projects
68 sleep 10
69 done;;
70 "--all-once")
71 check_all_projects;;
72 "--one")
73 check_one_proj "$2";;
75 echo "Usage: $0 [-q] [--all-once | --one PRJNAME]" >&2
76 exit 1;;
77 esac