+PACKAGE = $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
VERSION = $(shell dpkg-parsechangelog | sed -n 's/^Version: //p')
DIST = $(shell dpkg-parsechangelog | sed -n 's/^Distribution: //p')
install: build
install -o root -g root -m 0755 -d $(DESTDIR)/usr/sbin
- install -o root -g root -m 0755 cron.auf-git-etc $(DESTDIR)/usr/sbin/
+ install -o root -g root -m 0755 auf-git-etc-status $(DESTDIR)/usr/sbin/
+ install -o root -g root -m 0755 -d $(DESTDIR)/usr/lib/$(PACKAGE)
+ install -o root -g root -m 0755 cron.sh $(DESTDIR)/usr/lib/$(PACKAGE)/
install -o root -g root -m 0755 -d $(DESTDIR)/etc/profile.d
- install -o root -g root -m 0644 auf-git-etc.sh $(DESTDIR)/etc/profile.d/
- install -o root -g root -m 0750 -d $(DESTDIR)/etc/auf-git-etc
- cp -a etc/* $(DESTDIR)/etc/auf-git-etc/
+ install -o root -g root -m 0644 profile.sh $(DESTDIR)/etc/profile.d/$(PACKAGE).sh
+ install -o root -g root -m 0755 -d $(DESTDIR)/etc/sudoers.d
+ install -o root -g root -m 0440 sudoers.d $(DESTDIR)/etc/sudoers.d/$(PACKAGE)
+ install -o root -g root -m 0750 -d $(DESTDIR)/etc/$(PACKAGE)
+ cp -a etc/* $(DESTDIR)/etc/$(PACKAGE)/
clean:
-test:
- debuild -I.git -I*.ex -b -us -uc && sudo debi
+deb:
+ debuild -I.git -I*.ex -us -uc -b && \
+ echo -e "\n\n==> Lancer \"sudo debi\" pour tester l'installation.\n"
release:
- debuild -I.git -I*.ex -tc && debrelease --dput squeeze-test
-
+ debuild -I.git -I*.ex -us -uc -tc -sa && debrelease --dput wheezy-test
+++ /dev/null
-Objectif :
- Automatiser l'installation d'un suivi de /etc et /usr/local via GIT.
-
-Documentation :
- http://wiki.auf.org/wikiteki/Git/SuiviDeConfiguration
-
-Responsable :
- Progfou <jean-christophe.andre@auf.org>
-
+++ /dev/null
-Liste des choses à faire :
-
-* passer à un fichier dans /etc/sudoers.d/auf-git-etc (disponible à partir
- de Squeeze, mais pas automatiquement en cas de migration depuis Lenny)
-
--- /dev/null
+#!/bin/sh
+GIT_DIR="/.git"
+GIT_WORK_TREE="/"
+export GIT_DIR GIT_WORK_TREE
+cd /
+exec git -c color.ui=always status --short
+++ /dev/null
-if test -n "$PS1"; then
- # on lance un git status sur l'utilisateur s'il est dans le groupe admin
- # ou bien si c'est root
- if `id -Gn | grep -qw admin` || test `id -u` -eq 0; then
- test -x /usr/bin/git -a -d /.git && (cd / ; sudo /usr/bin/git status) |
- /bin/sed -e '1{/^# On branch /d};2{/^nothing to commit/d}'
- # deux variables indispensables à cause d'un bogue de git avec la racine
- # disons que les admins ne gèrent rien d'autre… au pire, .bash_profile !
- GIT_DIR=/.git
- GIT_WORK_TREE=/
- export GIT_DIR GIT_WORK_TREE
- fi
- # les lignes suivantes tentent de configurer les variables GIT_*
- # si les résultats ne sont pas bien "devinés", définir les bonnes
- # valeurs dans .bash_profile (ou .profile pour root)
- if test -z "$GIT_AUTHOR_NAME"; then
- GIT_AUTHOR_NAME="`getent passwd $(id -un)|cut -d: -f5|cut -d, -f1`"
- fi
- if test -z "$GIT_AUTHOR_EMAIL"; then
- GIT_AUTHOR_EMAIL="`id -un`@`cat /etc/mailname 2>/dev/null || hostname -f`"
- fi
- if test -z "$GIT_COMMITTER_NAME"; then
- GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
- fi
- if test -z "$GIT_COMMITTER_EMAIL"; then
- GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
- fi
- export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
-fi
+++ /dev/null
-#!/bin/sh
-recipients="root+git" # adresse pour l'envoi du mail
-
-PATH="/bin:/usr/bin"
-export PATH
-
-if [ "$1" != "cron" ]; then
- echo "Ce script n'est pas fait pour être lancé manuellement mais via cron."
- exit -1
-fi
-
-[ -x /usr/bin/git -a -d /.git ] || exit 0
-
-tempfile=`tempfile`
-if [ $? != 0 ]; then
- echo "Erreur fatale de création de fichier temporaire."
- exit -1
-fi
-trap "rm -f \"$tempfile\"" 0 1 2 3 15
-
-(cd / ; /usr/bin/git status) |
-sed -e '1{/^# On branch /d};2{/^nothing to commit/d};s/^#//' >"$tempfile"
-
-if [ -s "$tempfile" ]; then
-(
- echo "From: git `hostname --fqdn` - Cron Daemon <root+git@`cat /etc/mailname 2>/dev/null || hostname --fqdn`>"
- echo "To: ${recipients}"
- echo "Date: `date --rfc-2822`"
- echo "Subject: git-status: `hostname --fqdn` - $0"
- echo "Content-Type: text/plain; charset=utf-8"
- echo ""
- echo "Liste de modifications sur la machine `hostname --fqdn`"
- echo "qui n'ont pas encore été validées :"
- echo "( voir http://wiki.auf.org/wikiteki/Git/SuiviDeConfiguration )"
- echo ""
- cat "$tempfile"
-) | head -c 16k | /usr/sbin/sendmail ${recipients}
-fi
-
-exit 0
--- /dev/null
+#!/bin/sh
+recipients="root+git" # adresse pour l'envoi du courriel
+
+PATH="/bin:/usr/bin"
+export PATH
+
+. /etc/auf-git-etc/config
+
+[ -x /usr/bin/git -a -d /.git ] || exit 0
+
+tempfile=`tempfile`
+if [ $? != 0 ]; then
+ echo "Erreur fatale de création de fichier temporaire."
+ exit -1
+fi
+trap "rm -f \"$tempfile\"" 0 1 2 3 15
+
+(cd / ; /usr/bin/git status --short) >"$tempfile"
+
+if [ -s "$tempfile" ]; then
+(
+ cat << __EOF__
+From: auf-git-etc - Cron Daemon <root+git@`cat /etc/mailname 2>/dev/null || hostname --fqdn`>
+To: ${recipients}
+Date: `date --rfc-2822`
+Subject: git-status: `hostname --fqdn` - $0
+Content-Type: text/plain; charset=utf-8
+
+Modifications en attente de validation sur `hostname --fqdn` :
+
+__EOF__
+ cat "$tempfile"
+) | (
+ head -c 16k
+ cat << __EOF__
+
+--
+http://wiki.auf.org/wikiteki/Git/SuiviDeConfiguration
+__EOF__
+) | /usr/sbin/sendmail ${recipients}
+fi
+
+exit 0
+auf-git-etc (1.7.10) stable; urgency=medium
+
+ * Refonte du paquet pour Debian post-Squeeze :
+ * déplacement de la configuration sudo dans /etc/sudoers.d/
+ * nettoyage de l'ancienne configuration sudo dans /etc/sudoers
+ * utilisation du groupe "sudo" plutôt que "admin"
+ * destinataire(s) des courriels configurable dans /etc/auf-git-etc/config
+ * statut git simplifié (git status --short)
+
+ -- Progfou <jean-christophe.andre@auf.org> Wed, 14 Oct 2015 23:19:25 -0400
+
auf-git-etc (1.7.2.1) stable; urgency=low
* Dépendance directe sur 'git' au lieu de 'git-core'.
Priority: optional
Maintainer: Progfou <jean-christophe.andre@auf.org>
Build-Depends: debhelper (>= 5)
-Standards-Version: 3.7.2
+Standards-Version: 3.9.5
Package: auf-git-etc
Architecture: all
-Depends: git (> 1:1.7), sudo, ${misc:Depends}
-Recommends: exim4 | mail-transport-agent, cron
-Suggests: tig
+Depends: git (>> 1:1.7.0.2), sudo, ${misc:Depends}
+Recommends: exim4 | mail-transport-agent, cron, tig
Description: suivi de /etc et /usr/local via git
Ce paquet permet d'automatiser l'installation d'un suivi de /etc,
/usr/local et autres via un dépôt GIT à la racine du système.
Copyright Holder:
- Copyright (C) 2008-2011 Agence universitaire de la Francophonie
+ Copyright (C) 2008-2015 Agence universitaire de la Francophonie
http://www.auf.org/
License:
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
-
+
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this package; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On Debian systems, the complete text of the GNU General
Public License can be found in `/usr/share/common-licenses/GPL'.
-The Debian packaging is (C) 2008-2011, Progfou <jean-christophe.andre@auf.org>
-and is licensed under the GPL, see above.
+The Debian packaging is
+ Copyright (C) 2008-2015 Agence universitaire de la Francophonie
+ http://www.auf.org/
+
+and is licensed under the GPL, see above.
#
# Regular cron jobs for the auf-git-etc package
#
-0 10,16 * * 1-5 root test -x /usr/sbin/cron.auf-git-etc && /usr/sbin/cron.auf-git-etc cron
+0 10,16 * * 1-5 root test -x /usr/lib/auf-git-etc/cron.sh && /usr/lib/auf-git-etc/cron.sh
-usr/sbin
-etc/cron.d
-etc/profile.d
+usr/lib/auf-git-etc
etc/auf-git-etc
+etc/profile.d
+etc/sudoers.d
+etc/cron.d
case "$1" in
configure)
- # 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 GIT_DIR GIT_WORK_TREE"\n/;:l;n;b l}' /etc/sudoers
- # configuration déjà là, on ajoute les nouveautés avec 1.5
- elif ! grep -q "env_keep.*GIT_DIR" /etc/sudoers; then
- sed -i 's/GIT_AUTHOR_EMAIL/GIT_AUTHOR_EMAIL GIT_DIR GIT_WORK_TREE/' /etc/sudoers
+ # on retire les modifications faites directement dans /etc/sudoers
+ for f in /etc/sudoers /etc/sudoers.d/local
+ do
+ if test -f "$f"; then
+ if grep -q "env_keep.*GIT" "$f"; then
+ sed -i '/^Defaults env_keep += "GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_DIR GIT_WORK_TREE"$/d' "$f"
fi
- # on autorise le groupe admin à demander le statut GIT
- if test -f /etc/sudoers; then
- if ! grep -q '^%admin.*git status' /etc/sudoers; then
- echo '%admin ALL=(ALL) NOPASSWD: /usr/bin/git status' >> /etc/sudoers
- else
- sed -i '/^%admin /s/git status -a/git status/' /etc/sudoers
- fi
+ if grep -q '^%admin.*git status' "$f"; then
+ sed -i '/^%admin ALL=(ALL) NOPASSWD: \/usr\/bin\/git status$/d' "$f"
fi
- fi
+ fi
+ done
# on vérifie la présence d'un existant
if [ -d /.git ]; then
cd /
git add etc usr/local var boot
git commit -q -m "Mise en route du suivi de /etc et /usr/local." \
- --author "Installation auf-git-etc <root@apt.auf.org>"
+ --author "Installation auf-git-etc <root+git@auf.org>"
fi
;;
#!/usr/bin/make -f
# -*- makefile -*-
-configure:
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
-build:
+%:
+ dh $@
-clean:
- dh_testdir
- dh_testroot
- -$(MAKE) clean
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
- $(MAKE) DESTDIR=$(CURDIR)/debian/auf-git-etc install
-
-# Build architecture-independent files here.
-binary-indep: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
-# dh_installexamples
-# dh_install
-# dh_installdebconf
-# dh_installlogrotate
-# dh_python
-# dh_installinit
- dh_installcron
-# dh_installman
- dh_compress
- dh_fixperms
- dh_installdeb
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-# Build architecture-dependent files here.
-binary-arch: build install
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+Objectif :
+
+ Automatiser l'installation d'un suivi de /etc et /usr/local via git.
+
+Documentation :
+
+ http://wiki.auf.org/wikiteki/Git/SuiviDeConfiguration
+
+Responsable :
+
+ Progfou <jean-christophe.andre@auf.org>
+
--- /dev/null
+Liste des choses à faire :
+
+Rien pour le moment. :-)
--- /dev/null
+recipients="root+git" # adresse pour l'envoi du courriel
#!/bin/sh
-recipients="root+git" # adresse pour l'envoi du mail
+recipients="root+git" # adresse pour l'envoi du courriel
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+export PATH
+
+. /etc/auf-git-etc/config
+
# On modifie un peu la sortie de git show :
# - on remplace le nom de l'expéditeur dans l'enveloppe par "root+git"
# - on insère "git hostname - " devant le nom en From:
# - on ajoute un champ To:
# - on ajoute des champs MIME (version, type & encodage)
# et on envoie le tout via sendmail
-PATH=/usr/sbin:/usr/bin:/sbin:/bin
git show --pretty=email | awk '\
BEGIN { v=0 ; t=0 ; e=0 }
/^From / { sub(/ [^ ]+ /," root+git ") }
-/^From: / { sub(/:/,": git '"`hostname --fqdn`"' -") }
+/^From: / { sub(/:/,": auf-git-etc '"`hostname --fqdn`"' -") }
/^Subject: / { sub(/\[PATCH\]/,"git-commit:") }
/^MIME-Version: / { v=1 }
/^Content-Type: / { t=1 }
print ; while(getline) { print } ; exit
}
{ print }
-' | head -c 16k | sendmail ${recipients}
+' | (
+ head -c 16k
+ cat << __EOF__
+
+--
+http://wiki.auf.org/wikiteki/Git/SuiviDeConfiguration
+__EOF__
+) | /usr/sbin/sendmail ${recipients}
exit 0
/etc/postfix/*.db
/etc/postfix/*/*.db
/etc/postfix/ssl/smtpd.pem
+/etc/dovecot/passwd*
/etc/exim4/passwd.client
/etc/samba/smbpasswd
/etc/samba/*.tdb
/etc/nut/upsd.users
/etc/pipsecd/pipsecd.conf
+/etc/check_mk/logwatch.state
# futur remplaçant de rc.d, mais faut-il l'exclure entièrement ?
/etc/sv
+# on ne suit pas les fichiers dynamiques de Proxmox
+/etc/pve/*
+!/etc/pve/nodes
# Le /boot/grub/menu.lst peut être intéressant à suivre aussi
!/boot
/boot/*
#!/var/log
#/var/log/*
#!/var/log/dpkg.log
+# On suit aussi les sources Python ou Django
+!/srv
+/srv/*
+!/srv/python
+!/srv/*django*
+*.pyc
+*.pyo
# quelques type fichiers à ne pas jamais considérer, globalement :
+shadow*
htpasswd
.htpasswd
*.dpkg-old
*_key
*.key
*-key.pem
+*crypt*
--- /dev/null
+if test -n "$PS1"; then
+ # on lance un git status si l'utilisateur est dans le groupe sudo
+ # ou bien si c'est root
+ if `id -Gn | grep -qw sudo` || test `id -u` -eq 0; then
+ test -x /usr/bin/git -a -d /.git && sudo /usr/sbin/auf-git-etc-status
+ # deux variables indispensables à cause d'un bogue de git avec la racine
+ # disons que les admins ne gèrent rien d'autre… au pire, .bash_profile !
+ GIT_DIR=/.git
+ GIT_WORK_TREE=/
+ export GIT_DIR GIT_WORK_TREE
+ fi
+ # les lignes suivantes tentent de configurer les variables GIT_*
+ # si les résultats ne sont pas bien « devinés », définir les bonnes
+ # valeurs dans .bash_profile (ou .profile pour root)
+ e=""
+ if test -z "$GIT_AUTHOR_NAME"; then
+ GIT_AUTHOR_NAME="`getent passwd $(id -un)|cut -d: -f5|cut -d, -f1`"
+ e="$e GIT_AUTHOR_NAME"
+ fi
+ if test -z "$GIT_AUTHOR_EMAIL"; then
+ GIT_AUTHOR_EMAIL="`id -un`@`cat /etc/mailname 2>/dev/null || hostname -f`"
+ e="$e GIT_AUTHOR_EMAIL"
+ fi
+ if test -z "$GIT_COMMITTER_NAME"; then
+ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
+ e="$e GIT_COMMITTER_NAME"
+ fi
+ if test -z "$GIT_COMMITTER_EMAIL"; then
+ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
+ e="$e GIT_COMMITTER_EMAIL"
+ fi
+ if test -n "$e"; then
+ export $e
+ echo "(auto-config de$e)"
+ fi
+fi
--- /dev/null
+Defaults env_keep += "GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_DIR GIT_WORK_TREE"
+
+%sudo ALL=(ALL:ALL) NOPASSWD: /usr/bin/git status
+%sudo ALL=(ALL:ALL) NOPASSWD: /usr/sbin/auf-git-etc-status