Merge branch 'master' of ssh://git.onelab.eu/git/infrastructure
[infrastructure.git] / scripts / git-check.sh
1 #!/bin/sh
2
3 cd /git
4
5 gitwebfiles="git-favicon.png git-logo.png gitweb.cgi gitweb.css"
6
7 ########
8 gitwebpattern=""
9 for file in $gitwebfiles; do gitwebpattern="${gitwebpattern}|$file" ; done
10 gitwebpattern=$(echo "$gitwebpattern" | sed -e 's,|,,')
11
12 function missing_gitweb () {
13
14     echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx missing in gitweb (for web)"
15     for i in $gitwebfiles; do
16         echo -n "$i "
17         if [ -f ${i} ] ; then
18             echo -n "OK "
19         else
20             echo -n "MISSING.. " ; 
21         fi
22     done
23     echo ""
24
25 }
26
27
28 function fill_descriptions () {
29     echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx checking descriptions "
30     for arg in "$@" ; do
31         # accept args like plcapi or plcapi.git
32         b=$(basename $arg .git)
33         git=${b}.git
34         echo -n "$git "
35         grep -q Unnamed $git/description && { echo -n $i "Setting.. "; echo $b > $git/description ; }
36     done
37     echo ""
38 }
39
40 function check_permissions () {
41     echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx checking permissions "
42     for arg in "$@" ; do
43         # accept args like plcapi or plcapi.git
44         b=$(basename $arg .git)
45         git=${b}.git
46         echo -n "$git "
47         chown -R root:onelab $git
48         chmod -R g+w,o-w $git
49     done
50     echo ""
51 }
52
53 function check_configs () {
54     echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx checking config (upload*, hooks...) "
55     for arg in "$@" ; do
56         # accept args like plcapi or plcapi.git
57         b=$(basename $arg .git)
58         git=${b}.git
59         echo -n "$git "
60         cd $git 
61         git config core.sharedrepository >& /dev/null || { git config core.sharedrepository true; echo -n "sharedrepository "; }
62         git config daemon.uploadpack >& /dev/null || { git config daemon.uploadpack true; echo -n "uploadpack "; }
63         git config daemon.uploadarch >& /dev/null || { git config daemon.uploadarch true; echo -n "uploadarch "; }
64         git config hooks.mailinglist >& /dev/null || { git config hooks.mailinglist build@onelab.eu; echo -n "mailinglist "; }
65         git config hooks.announcelist >& /dev/null  || { git config hooks.announcelist  build@onelab.eu; echo -n "announcelist "; }
66         git config hooks.envelopesender >& /dev/null  || { git config hooks.envelopesender  build@onelab.eu; echo -n "envelopesender "; }
67         git config hooks.emailprefix >& /dev/null|| { git config hooks.emailprefix '[GIT]'; echo -n "emailprefix "; }
68         cd - >& /dev/null
69     done
70     echo ""
71 }
72
73 function check_hooks () {
74     echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx checking hooks "
75     for arg in "$@" ; do
76         # accept args like plcapi or plcapi.git
77         b=$(basename $arg .git)
78         git=${b}.git
79         echo -n "$git "
80         # standard version is in /usr/share/doc/git-1.5.5.6/hooks/post-receive-email
81         (cd $git/hooks; [ -h post-receive ] || ln -sf /root/bin/post-receive-email-with-diffs post-receive )
82     done
83     echo ""
84 }
85
86 # missing_gitweb
87 args="$@"
88 [[ -z "$args" ]] && args=$(ls -d *.git)
89 fill_descriptions $args
90 check_permissions $args
91 check_configs $args
92 check_hooks $args