summaryrefslogtreecommitdiff
path: root/localbackupconfig
blob: 5f39fcec4f81e2d016824915c88d442e22876a78 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/localbackupconfig
  4. # Copyright 2001 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: localbackupconfig,v 1.3 2002-03-29 13:33:06 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. FQDN=`hostname -f`
  15. BACKUPDIR=/var/local/backups/$FQDN
  16. LOCALCONFIGDIR=/etc/local-$FQDN
  17. if [ -e $LOCALCONFIGDIR ]; then
  18. mkdir -p $BACKUPDIR/$LOCALCONFIGDIR
  19. cp -fa $LOCALCONFIGDIR $BACKUPDIR/`dirname $LOCALCONFIGDIR`/
  20. fi
  21. changedfiles=`find /etc -name '*.old' -o -name '*.orig' -o -name '*.dpkg-new' | sed -e 's,\.\(old\|orig\|dpkg-new\)$,,' | grep -v "^$LOCALCONFIGDIR" | sort -u`
  22. for i in $changedfiles; do
  23. if [ -e $i ]; then
  24. if [ -e $i.dpkg-new ]; then
  25. orig="$i.dpkg-new"
  26. elif [ -e $i.orig ]; then
  27. orig="$i.orig"
  28. elif [ -e $i.old ]; then
  29. orig="$i.old"
  30. else
  31. echo "What the f... Original for \"$i\" has disappeared?!?"
  32. exit 1
  33. fi
  34. mkdir -p $BACKUPDIR/`dirname $i`
  35. cp -fa $i $BACKUPDIR/`dirname $i`/
  36. diff -ruN $orig $i > $BACKUPDIR/$i.diff
  37. fi
  38. done