/etckeeper/pre-install.d/50uncommitted-changes

http://github.com/brinkman83/bashrc · Shell · 29 lines · 26 code · 2 blank · 1 comment · 8 complexity · bfdaeac839e6788fcfd3a6bdd0839362 MD5 · raw file

  1. #!/bin/sh
  2. set -e
  3. if [ "$1" = "fail-debconf" ]; then
  4. . /usr/share/debconf/confmodule
  5. db_subst etckeeper/commit_failed VCS "$VCS"
  6. db_input critical etckeeper/commit_failed || true
  7. db_go || true
  8. db_reset etckeeper/commit_failed || true
  9. exit 0
  10. fi
  11. if etckeeper unclean; then
  12. if [ "$AVOID_COMMIT_BEFORE_INSTALL" = 1 ]; then
  13. echo "" >&2
  14. echo "** etckeeper detected uncommitted changes in /etc prior to $HIGHLEVEL_PACKAGE_MANAGER run" >&2
  15. echo "** Aborting $HIGHLEVEL_PACKAGE_MANAGER run. Manually commit and restart." >&2
  16. echo "" >&2
  17. exit 1
  18. fi
  19. if ! etckeeper commit "saving uncommitted changes in /etc prior to $HIGHLEVEL_PACKAGE_MANAGER run"; then
  20. if [ -e /usr/share/debconf/confmodule ]; then
  21. $0 fail-debconf
  22. else
  23. echo "error: etckeeper failed to commit changes in /etc using $VCS"
  24. exit 1
  25. fi
  26. fi
  27. fi