/contrib/upgrade-conffile.sh

http://github.com/sukria/Backup-Manager · Shell · 42 lines · 28 code · 5 blank · 9 comment · 4 complexity · ed0eca007497953f4bc25fbe7a802ec7 MD5 · raw file

  1. #! /usr/bin/env bash
  2. # This will assist you for upgrading a conffile of version prior
  3. # to 0.5.9.
  4. #
  5. # Usage:
  6. # upgrade-conffile.sh <CONFFILE>
  7. #
  8. # It will replace every deprecated confiugration key with the new name
  9. # and will show you the diff before applying it.
  10. set -e
  11. for file in "$1"
  12. do
  13. sed \
  14. -e 's/BM_ARCHIVES_REPOSITORY/BM_REPOSITORY_ROOT/g' \
  15. -e 's/BM_USER/BM_REPOSITORY_USER/g' \
  16. -e 's/BM_GROUP/BM_REPOSITORY_GROUP/g' \
  17. -e 's/BM_MAX_TIME_TO_LIVE/BM_ARCHIVE_TTL/g' \
  18. -e 's/BM_PURGE_DUPLICATES/BM_ARCHIVE_PURGEDUPS/g' \
  19. -e 's/BM_ARCHIVES_PREFIX/BM_ARCHIVE_PREFIX/g' \
  20. -e 's/BM_FILETYPE/BM_TARBALL_FILETYPE/g' \
  21. -e 's/BM_BACKUP_METHOD/BM_ARCHIVE_METHOD/g' \
  22. -e 's/BM_NAME_FORMAT/BM_TARBALL_NAMEFORMAT/g' \
  23. -e 's/BM_DUMP_SYMLINKS/BM_TARBALL_DUMPSYMLINKS/g' \
  24. -e 's/BM_DIRECTORIES_BLACKLIST/BM_TARBALL_BLACKLIST/g' \
  25. -e 's/BM_DIRECTORIES/BM_TARBALL_DIRECTORIES/g' \
  26. -e 's/BM_FTP_PURGE/BM_UPLOAD_FTPPURGE/g' < $file > $file.tmp
  27. diff -ubB $file $file.tmp | less
  28. echo -n "Apply changes to $file? [y/N] "
  29. read ret
  30. if [[ -z $ret ]]; then
  31. ret="n"
  32. fi
  33. if [[ $ret = y ]] || [[ $ret = Y ]]; then
  34. mv $file.tmp $file
  35. fi
  36. rm -f $file.tmp
  37. done