eerevert.in 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. . <(ffoom init)
  3. ffoo import core
  4. ffoo import recon
  5. usage() {
  6. usage_is "[-d|--debug] [-v|--verbose] [--dry-run] [-c|--connection] domain [snapshot]"
  7. }
  8. FFOO_DRY_RUN=false
  9. connection="qemu:///system"
  10. while true; do
  11. case $1 in
  12. -c|--connection)
  13. connection=$2
  14. shift 2
  15. ;;
  16. -d|--debug)
  17. FFOO_DEBUG=true
  18. shift 1
  19. ;;
  20. -q|--quiet)
  21. FFOO_VERBOSE=false
  22. shift 1
  23. ;;
  24. -v|--verbose)
  25. FFOO_VERBOSE=true
  26. shift 1
  27. ;;
  28. --dry-run)
  29. FFOO_DRY_RUN=true
  30. shift 1
  31. ;;
  32. "")
  33. usage
  34. ;;
  35. --)
  36. shift 1
  37. break
  38. ;;
  39. *)
  40. break
  41. ;;
  42. esac
  43. done
  44. domain="$1"
  45. snapshot="$2"
  46. test -z "$snapshot" && {
  47. think "looking for $domain in revert.ini"
  48. snapshot=$(eeini -1 -p revert.to.snapshot.$domain)
  49. }
  50. test -z "$snapshot" && {
  51. think "looking for default snapshot name in revert.ini"
  52. snapshot=$(eeini -1 -p revert.to.snapshot._default_)
  53. }
  54. test -z "$snapshot" && {
  55. die "could not determine snapshot for $domain"
  56. }
  57. think "reverting $domain to $snapshot"
  58. debug "virsh -c "$connection" snapshot-revert $domain $snapshot"
  59. $FFOO_DRY_RUN || virsh -c "$connection" snapshot-revert $domain $snapshot
  60. think "starting $domain"
  61. debug "virsh -c "$connection" start $domain"
  62. $FFOO_DRY_RUN || virsh -c "$connection" start $domain