apt-snapshots 914 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. set -e
  3. . /lib/recovery-mode/l10n.sh
  4. # check if its there
  5. if [ ! -x /usr/bin/apt-btrfs-snapshot ]; then
  6. exit 1
  7. fi
  8. # check if its usable, if list returns a non-zero exit code,
  9. # we probably run on a system with no snapshot support
  10. if ! /usr/bin/apt-btrfs-snapshot list > /dev/null 2>&1; then
  11. exit 1
  12. fi
  13. # if we make it to this point, show some help
  14. if [ "$1" = "test" ]; then
  15. echo $(eval_gettext "Revert to old snapshot and reboot")
  16. exit 0
  17. fi
  18. # get snapshots and show them in whiptail
  19. snapshots=$(apt-btrfs-snapshot list | sed 1d)
  20. tag_item=""
  21. for item in $snapshots; do
  22. tag_item="$item snapshot $tag_item"
  23. done
  24. choice="$(whiptail --menu "$(eval_gettext "Snapshot")" 15 70 6 $tag_item \
  25. 3>&1 1>&2 2>&3 3>&-)"
  26. # user selected cancel
  27. if [ -z "$choice" ]; then
  28. exit 0
  29. fi
  30. # set new snapshot and reboot
  31. if apt-btrfs-snapshot set-default "$choice"; then
  32. reboot
  33. fi