summaryrefslogtreecommitdiff
path: root/localbackupconfig
blob: ed745a5c913118fd26db4faa1d44b87fe8aaa330 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/localbackupconfig
  4. # Copyright 2001 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: localbackupconfig,v 1.6 2002-10-17 17:20:56 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. set -e
  17. FQDN=`hostname -f`
  18. BACKUPDIR=/var/local/backups/$FQDN
  19. LOCALCONFIGDIR=/etc/local-$FQDN
  20. if [ -e $LOCALCONFIGDIR ]; then
  21. mkdir -p $BACKUPDIR/$LOCALCONFIGDIR
  22. cp -fa $LOCALCONFIGDIR $BACKUPDIR/`dirname $LOCALCONFIGDIR`/
  23. fi
  24. 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`
  25. for i in $changedfiles; do
  26. if [ -e $i ]; then
  27. if [ -e $i.dpkg-new ]; then
  28. orig="$i.dpkg-new"
  29. elif [ -e $i.orig ]; then
  30. orig="$i.orig"
  31. elif [ -e $i.old ]; then
  32. orig="$i.old"
  33. elif [ -e $i.bak ]; then
  34. orig="$i.bak"
  35. else
  36. echo "What the f... Original for \"$i\" has disappeared?!?"
  37. exit 1
  38. fi
  39. mkdir -p $BACKUPDIR/`dirname $i`
  40. cp -fa $i $BACKUPDIR/`dirname $i`/
  41. diff -ruN $orig $i > $BACKUPDIR/$i.diff || true
  42. fi
  43. done