summaryrefslogtreecommitdiff
path: root/localbackupconfig
blob: d6e6cf9861b9188f75a166d8837c8fdf7ef5c47e (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/localbackupconfig
  4. # Copyright 2001 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: localbackupconfig,v 1.4 2002-03-29 13:43:17 jonas Exp $
  7. #
  8. # .dpkg-new files appear when refusing to update a conffile on package update
  9. #
  10. # .orig files you should save yourself before customizing a configfile
  11. #
  12. # .old files are for customizing when you don't have the original (anymore)
  13. #
  14. # .bak is... eh... just in case you felt like using that name now and then...
  15. #
  16. FQDN=`hostname -f`
  17. BACKUPDIR=/var/local/backups/$FQDN
  18. LOCALCONFIGDIR=/etc/local-$FQDN
  19. if [ -e $LOCALCONFIGDIR ]; then
  20. mkdir -p $BACKUPDIR/$LOCALCONFIGDIR
  21. cp -fa $LOCALCONFIGDIR $BACKUPDIR/`dirname $LOCALCONFIGDIR`/
  22. fi
  23. changedfiles=`find /etc -name '*.bak' -o -name '*.old' -o -name '*.orig' -o -name '*.dpkg-new' | sed -e 's,\.\(bak\|old\|orig\|dpkg-new\)$,,' | grep -v "^$LOCALCONFIGDIR" | sort -u`
  24. for i in $changedfiles; do
  25. if [ -e $i ]; then
  26. if [ -e $i.dpkg-new ]; then
  27. orig="$i.dpkg-new"
  28. elif [ -e $i.orig ]; then
  29. orig="$i.orig"
  30. elif [ -e $i.old ]; then
  31. orig="$i.old"
  32. elif [ -e $i.bak ]; then
  33. orig="$i.bak"
  34. else
  35. echo "What the f... Original for \"$i\" has disappeared?!?"
  36. exit 1
  37. fi
  38. mkdir -p $BACKUPDIR/`dirname $i`
  39. cp -fa $i $BACKUPDIR/`dirname $i`/
  40. diff -ruN $orig $i > $BACKUPDIR/$i.diff
  41. fi
  42. done