the stuff

heads-persistent-load 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2016-2018 Ivan J. <parazyd@dyne.org>
  4. # See LICENSE file for copyright and license details.
  5. #
  6. # this will guide you through a persistence setup for heads
  7. # should become more sophisticated in the future
  8. yesno() {
  9. printf "Is this all right? [y/N] "
  10. read dummy
  11. case "$dummy" in
  12. y|Y)
  13. ;;
  14. n|N)
  15. return 1
  16. ;;
  17. *)
  18. printf "unknown reply\n"
  19. $0
  20. ;;
  21. esac
  22. }
  23. find_device() {
  24. awk '/lib\/live\/mount\/medium/ {print $1}' /proc/mounts | cut -c 1-8
  25. }
  26. mount_device() {
  27. [ -b "$(find_device)2" ] || {
  28. printf "The persistence partition was not found. Exiting...\n"
  29. exit 1
  30. }
  31. mount "$(find_device)2" /mnt
  32. cd /mnt
  33. [ -f "persistence.tomb" ] || {
  34. printf "The tomb was not found. Exiting...\n"
  35. exit 1
  36. }
  37. [ -f "persistence.tomb.key" ] || {
  38. printf "The tomb's key was not found. Exiting...\n"
  39. exit 1
  40. }
  41. cd - >/dev/null
  42. }
  43. prepare_tomb() {
  44. cat <<EOF > /home/luther/tombprep
  45. #!/bin/sh
  46. cd /mnt
  47. sudo tomb open persistence.tomb -k persistence.tomb.key
  48. rm -f /home/luther/tombprep
  49. EOF
  50. chmod +x /home/luther/tombprep
  51. sudo -u luther /home/luther/tombprep
  52. }
  53. cat <<EOM
  54. +-------------------------------------+
  55. | heads persistence load |
  56. +-------------------------------------+
  57. We're about to mount your persistence setup. If you have not setup
  58. persistence already, answer 'N' and run 'sudo heads-persistent-setup'.
  59. Otherwise, answer 'Y' to continue.
  60. EOM
  61. yesno || exit 1
  62. mount_device
  63. prepare_tomb