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.

64 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. echo -n "Please enter passphrase: "
  30. read -s passphrase
  31. echo
  32. for x in /lvp.data* ; do
  33. echo "${passphrase}" | losetup -e ${thisenc} -p 0 /dev/loop/${x#/lvp.data} ${x}
  34. done
  35. mdadm --build /dev/md/0 -l linear --force -n ${numfiles} ${files}
  36. mount /dev/md/0 /mnt1
  37. if [ ! -e /mnt1/lvp.xml ] ; then
  38. echo "Wrong Passphrase!"
  39. mdadm /dev/md/0 -S
  40. for x in /lvp.data* ; do
  41. losetup -d /dev/loop/${x#/lvp.data}
  42. done
  43. fi
  44. done
  45. exec 2>&1
  46. fi
  47. }
  48. encryption_stop(){
  49. umount /mnt1
  50. mdadm -S /dev/md/0
  51. for x in /lvp.data* ; do
  52. losetup -d /dev/loop/${x#/lvp.data}
  53. done
  54. }
  55. encryption_(){
  56. echo "Uh-Oh"
  57. }
  58. eval "encryption_${1}"