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