if [ -n "$PS1" ]; then
# on lance un git status sur l'utilisateur s'il est dans le groupe
- # aufadmin ou bien si c'est root
- if $(id -Gn | grep -qw aufadmin) || test $(id -u) -eq 0; then
- (cd / ; sudo /usr/bin/git status -a)
+ # admin ou bien si c'est root
+ if $(id -Gn | grep -qw admin) || test $(id -u) -eq 0; then
+ test -x /usr/bin/git && (cd / ; sudo /usr/bin/git status -a)
fi
# les lignes suivantes tentent de configurer les variables GIT_*
# si les résultats ne sont pas bien "devinés", définir les bonnes
case "$1" in
configure)
- # on crée au besoin le dépôt GIT global à ce système
- if [ ! -d /var/lib/git/root ]; then
- cd /
- git init-db
- chmod 0700 /.git
- mkdir -p /var/lib/git
- mv /.git /var/lib/git/root
- cp -a /usr/share/doc/auf-git-etc-*/sample/exclude /.git/info/
- cp -a /usr/share/doc/auf-git-etc-*/sample/post-commit /.git/hooks/
- chmod 0755 /.git/hooks/post-commit
- git add etc usr/local
- git commit -m "Mise en route du suivi de /etc et /usr/local." \
- --author "Installation auf-git-etc <root@apt.auf.org>"
- fi
- if [ ! -L /.git ]; then
- ln -s /var/lib/git/root /.git
- fi
-
- # on conserve l'environnement GIT pendant un sudo
- if ! grep -q "env_keep.*GIT" /etc/sudoers; then
- sed -i '/^$/{s//Defaults env_keep += "GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL"\n/;:l;n;b l}' /etc/sudoers
- fi
-
- # on autorise le groupe aufadmin à demander le statut GIT
- if ! grep -q '^%aufadmin.*git status' /etc/sudoers; then
- echo '%aufadmin ALL=(ALL) NOPASSWD: /usr/bin/git status -a' >> /etc/sudoers
- fi
-
# on ajoute de la souplesse dans /etc/profile
# XXX: c'est pas vraiment spécifique à ce paquet...
- if ! grep -q '/etc/profile.d' /etc/profile; then
- sed -i '/^PATH/r /proc/self/fd/0' /etc/profile << __EOF__
-
+ if ! grep -q '/etc/profile\.d' /etc/profile; then
+ sed -i -e '/^$/{r /proc/self/fd/0' -e ':l;n;b l}' \
+ /etc/profile << __EOF__
if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
done
unset i
fi
+
__EOF__
fi
+ # gestion transparente de GIT via sudo
+ if test -f /etc/sudoers; then
+
+ # on conserve l'environnement GIT pendant un sudo
+ if ! grep -q "env_keep.*GIT" /etc/sudoers; then
+ sed -i '/^$/{s//Defaults env_keep += "GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL"\n/;:l;n;b l}' /etc/sudoers
+ fi
+
+ # on autorise le groupe admin à demander le statut GIT
+ if test -f /etc/sudoers && ! grep -q '^%admin.*git status' /etc/sudoers; then
+ echo '%admin ALL=(ALL) NOPASSWD: /usr/bin/git status -a' >> /etc/sudoers
+ fi
+
+ fi
+
+ # on crée au besoin le dépôt GIT global à ce système
+ if [ ! -d /var/lib/git/root ]; then
+ cd /
+ git init-db
+ chmod 0700 /.git
+ mkdir -p /var/lib/git
+ mv /.git /var/lib/git/root
+ ln -s /var/lib/git/root /.git
+ cp -a /usr/share/doc/auf-git-etc/sample/exclude /.git/info/
+ cp -a /usr/share/doc/auf-git-etc/sample/post-commit /.git/hooks/
+ chmod 0755 /.git/hooks/post-commit
+ git add etc usr/local
+ # TODO: ajouter -q quand on sera en git ≥ 1.5 (Debian "Lenny")
+ git commit -m "Mise en route du suivi de /etc et /usr/local." \
+ --author "Installation auf-git-etc <root@apt.auf.org>"
+ fi
+
;;
abort-upgrade|abort-remove|abort-deconfigure)
+#!/bin/sh
#recipients="admins@XX.auf.org" # adresse pour l'envoi du mail
recipients="root"
# On modifie un peu la sortie de git show :
# et on envoie le tout via sendmail
PATH=/usr/sbin:/usr/bin:/sbin:/bin
git show --pretty=email |
- sed -e '1,6s/^From: /From: git '`hostname -f`' - /'
- -e '1,6s/^Subject: \[PATCH\]/Subject: git-commit:/'
- -e '2iTo: '"${recipients}" |
+ sed -e '1,6s/^From: /From: '`hostname -f`' - /' \
+ -e '1,6s/^Subject: \[PATCH\]/Subject: git-commit:/' \
+ -e '3iTo: '"${recipients}" |
head -c 16k | /usr/sbin/sendmail ${recipients}
exit 0