doinst.sh 593 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. # vim: et ts=2 sw=2
  3. config() {
  4. NEW="$1"
  5. OLD="${NEW%*.new}"
  6. # If there's no config file by that name, mv it over:
  7. if [ ! -r $OLD ]; then
  8. mv $NEW $OLD
  9. elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then # toss the redundant copy
  10. rm $NEW
  11. fi
  12. # Otherwise, we leave the .new copy for the admin to consider...
  13. }
  14. preserve_perms() {
  15. NEW="$1"
  16. OLD="$(dirname $NEW)/$(basename $NEW .new)"
  17. if [ -e $OLD ]; then
  18. cp -a $OLD ${NEW}.incoming
  19. cat $NEW > ${NEW}.incoming
  20. mv ${NEW}.incoming $NEW
  21. fi
  22. config $NEW
  23. }
  24. preserve_perms etc/pdfpcrc.new