eerevert.in 1.6KB

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