jobd: unify error/status reporting
[girocco.git] / fixupd / fixup.sh
blobdb1e2216080910104c44daef617348dffbd072cb
1 #!/bin/bash
3 # THIS SCRIPT IS BEING RUN UNDER ROOT!!!
5 # [repo.or.cz] You will need to manually update this file if you modify
6 # it in the repository.
8 set -e
10 proj="$1"
11 groupfile="$2"
12 mirror_user="$3"
14 # disallow suspicious paths
15 case "$proj" in
16 /* | *..*)
17 echo "Invalid path" >&2
18 exit 1
20 esac
21 cd "$proj.git"
23 chmod -R ug+rw,o+r . 2>&1 | (grep -v 'No such file or directory' || true)
25 [ -e .nofetch ] || exit
27 xproj="$(echo "$proj" | sed 's/[.\/]/\\&/g')"
28 gid="$(sed -ne "/^$xproj:/ { s/^[^:]*:[^:]*:\([0-9]*\):.*/\1/; p; }" "$groupfile")"
29 if [ -z "$gid" ]; then
30 echo "cannot resolve gid for $proj ($xproj)" >&2
31 exit 1
34 if ! [ -L packed-refs ]; then
35 if [ -f packed-refs ] && ! [ -f objects/info/packed-refs ]; then
36 mv packed-refs objects/info/packed-refs
38 if ! [ -e packed-refs ]; then
39 ln -s objects/info/packed-refs packed-refs
43 chown -R "$mirror_user":"$gid" info refs packed-refs objects 2>&1 | (grep -v 'No such file or directory' || true)