doinst.sh 468 B

123456789101112131415161718
  1. config() {
  2. NEW="$1"
  3. OLD="$(dirname "${NEW}")/$(basename "${NEW}" .new)"
  4. # If there's no config file by that name, mv it over:
  5. if [ ! -r "${OLD}" ]; then
  6. mv "${NEW}" "${OLD}"
  7. elif [ "$(md5sum "${OLD}")" = "$(md5sum "${NEW}")" ]; then
  8. # toss the redundant copy
  9. rm "${NEW}"
  10. fi
  11. # Otherwise, we leave the .new copy for the admin to consider...
  12. }
  13. find etc/openresty -name \*.new -type f |
  14. while IFS= read -r file; do
  15. config "${file}"
  16. done