mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.4 KiB

  1. #!/bin/bash
  2. encryption_start() {
  3. if [ -e /lvp.data1 ] ; then
  4. numfiles=0
  5. files=""
  6. echo -n "Found "
  7. for x in /lvp.data* ; do
  8. echo -n "${x} "
  9. numfiles=$(( ${numfiles} + 1 ))
  10. files="${files} /dev/loop/${numfiles}"
  11. done
  12. echo
  13. echo "Starting crypto-subroutine"
  14. echo "Please choose which encryption you want to use:"
  15. echo -e "\t1\tblowfish"
  16. echo -e "\t2\ttwofish"
  17. echo -e "\t3\tserpent"
  18. echo
  19. unset thisenc
  20. while [ -z "${thisenc}" ] ; do
  21. read -p "Please enter your choice: " rthisenc
  22. [ "${rthisenc}" == "1" ] && thisenc="blowfish256"
  23. [ "${rthisenc}" == "2" ] && thisenc="twofish256"
  24. [ "${rthisenc}" == "3" ] && thisenc="serpent256"
  25. done
  26. echo "Using ${thisenc%256} encryption."
  27. exec 2>/dev/null
  28. while [ ! -e /mnt1/lvp.xml ] ; do
  29. read -p "Please enter passphrase: " -s passphrase
  30. echo
  31. for x in /lvp.data* ; do
  32. echo "${passphrase}" | losetup -e ${thisenc} -p 0 /dev/loop/${x#/lvp.data} ${x}
  33. done
  34. mdadm --build /dev/md/0 -l linear --force -n ${numfiles} ${files}
  35. mount /dev/md/0 /mnt1
  36. if [ ! -e /mnt1/lvp.xml ] ; then
  37. echo "Wrong Passphrase!"
  38. mdadm /dev/md/0 -S
  39. for x in /lvp.data* ; do
  40. losetup -d /dev/loop/${x#/lvp.data}
  41. done
  42. fi
  43. done
  44. exec 2>&1
  45. fi
  46. }
  47. encryption_stop(){
  48. exec 2>/dev/null
  49. umount /mnt1
  50. mdadm /dev/md/0 -S
  51. for x in /lvp.data* ; do
  52. losetup -d /dev/loop/${x#/lvp.data}
  53. done
  54. exec 2>&1
  55. }
  56. encryption_(){
  57. echo "Uh-Oh"
  58. }
  59. eval "encryption_${1}"