repod: Run with set -e
[girocco/test-forks.git] / daemons / repod.sh
blob63db0b4932bf3968433dfd5ecb774a12067ec0f6
1 #!/bin/bash
3 # repod - Perform Girocco maintenance jobs
5 # repod 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 . @basedir@/shlib.sh
16 set -e
18 # Lock setup
20 if [ -e /tmp/repod.lock ]; then
21 echo "Locked! Stale /tmp/repod.lock?" >&2
22 exit 1
24 echo $$ >/tmp/repod.lock
25 trap "rm /tmp/repod.lock" SIGINT SIGTERM EXIT
28 ## Single-project routine
30 check_one_proj()
32 proj="$1"
33 if [ ! -e "$proj.git"/.nofetch ]; then
34 "$cfg_basedir"/daemons/update.sh "$proj"
36 "$cfg_basedir"/jobs/gc.sh "$proj" 2>&1 | grep -v '^Pack.*created\.$'
40 ## Main loop body
42 check_all_projects()
44 get_repo_list | while read proj; do
45 check_one_proj "$proj"
46 done
50 ## Main program
52 case "$1" in
53 "")
54 while true; do
55 check_all_projects
56 sleep 10
57 done;;
58 "--all-once")
59 check_all_projects;;
60 "--one")
61 check_one_proj "$2";;
63 echo "Usage: $0 [--all-once | --one PRJNAME]" >&2
64 exit 1;;
65 esac