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.

123 lines
4.0 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/base/device-mapper/etc_stone.d_mod_dm.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. #
  23. # [MAIN] 60 dm DeviceMapper configuration (encrypted filesystems)
  24. dm_edit_status () {
  25. gui_menu dm_edit_status "Please select new status of $device" \
  26. "Is encrypted" "status=encrypted" \
  27. "Decrypt" "status=decrypt" \
  28. "Encrypt" "status=encrypt" \
  29. "Encrypted Swap (read documentation)" "status=swap" \
  30. "not encrypted" "status=plain"
  31. }
  32. dm_edit_dev () {
  33. cmd=""
  34. for x in /dev/{ide,scsi}/host*/bus*/target*/lun*/{disc,part*} ; do
  35. [ -b $x ] || continue
  36. cmd="$cmd '$x' 'device=$x'"
  37. done
  38. eval "gui_menu dm_edit_dev \"Please select new device to mount on $mountpoint\" $cmd"
  39. }
  40. dm_edit () {
  41. device=$1
  42. while read olddevice oldmountpoint oldstatus ; do
  43. [ "$olddevice" == "$device" ] && break
  44. done < /etc/conf/dm/mounts
  45. mountpoint=$oldmountpoint
  46. status=$oldstatus
  47. run=0
  48. while [ $run -eq 0 ] ; do
  49. gui_menu dm_edit "Edit encryption for $device" "Device: $device" "dm_edit_dev $mountpoint" \
  50. "Mountpoint: $mountpoint" "gui_input 'Please enter new mountpoint' '$mountpoint' mountpoint" \
  51. "Status: $status" "dm_edit_status"
  52. run=$?
  53. done
  54. sed -e "s,^$olddevice.*$oldmountpoint.*$oldstatus$,$device\t$mountpoint\t$status," -i /etc/conf/dm/mounts
  55. return 0
  56. }
  57. dm_add () {
  58. cmd=""
  59. for x in /dev/{ide,scsi}/host*/bus*/target*/lun*/{disc,part*} ; do
  60. [ -b $x ] || continue
  61. grep -q $x /etc/conf/dm/mounts && continue
  62. cmd="$cmd '$x' 'device=$x'"
  63. done
  64. eval "gui_menu dm_add1 'Please select the device to use' $cmd"
  65. cmd=""
  66. gui_input "Please enter mountpoint of $device" "/data" mountpoint
  67. gui_menu dm_add2 "Please enter current state of $device" \
  68. "is encrypted" "status=encrypted" \
  69. "Decrypt" "status=decrypt" \
  70. "Encrypt" "status=encrypt" \
  71. "Encrypted Swap (read documentation)" "status=swap" \
  72. "not encrypted" "status=plain"
  73. echo -e "$device\t$mountpoint\t$status" >>/etc/conf/dm/mounts
  74. }
  75. main() {
  76. run=0
  77. if [ ! -f /etc/conf/dm/mounts ] ; then
  78. mkdir -p /etc/conf/dm
  79. touch /etc/conf/dm/mounts
  80. fi
  81. while [ $run -eq 0 ] ; do
  82. cmd=""
  83. while read device mountpoint status ; do
  84. cmd="$cmd 'Edit device $device ($status on $mountpoint)' 'dm_edit $device'"
  85. done < /etc/conf/dm/mounts
  86. cmd="$cmd 'Add new device' 'dm_add'"
  87. eval "gui_menu dm 'encrypted filesystems' $cmd"
  88. run=$?
  89. done
  90. tmp="`mktemp`"
  91. grep -v "added by mod_dm" /etc/conf/kernel >$tmp
  92. while read device mountpoint status ; do
  93. if [ "$status" == "swap" -o "$status" == "encrypted" -o "$status" == "encrypt" -o "$status" == "decrypt" ] ; then
  94. for x in aes-i586 dm-mod dm-crypt ; do
  95. grep -q $x $tmp || cat >> $tmp <<-EOF
  96. ### $x ### added by mod_dm
  97. modprobe $x # added by mod_dm
  98. EOF
  99. done
  100. fi
  101. done < /etc/conf/dm/mounts
  102. rm -f /etc/conf/kernel
  103. mv $tmp /etc/conf/kernel
  104. chmod 644 /etc/conf/kernel
  105. tmp=`mktemp`
  106. rm -rf ${tmp}
  107. grep -v fsck /etc/conf/initrd/initrd_dm > ${tmp}
  108. rm -f /etc/conf/initrd/initrd_dm
  109. mv ${tmp} /etc/conf/initrd/initrd_dm
  110. while read dev a mnt b fs c ; do
  111. [ -e "/sbin/fsck.${fs}" ] && echo "/sbin/fsck.${fs} /sbin/fsck.${fs}"
  112. done < <( mount ) | sort | uniq >>/etc/conf/initrd/initrd_dm
  113. echo "/sbin/fsck /sbin/fsck" >>/etc/conf/initrd/initrd_dm
  114. }