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.

125 lines
4.1 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. recreate_initrd=1
  56. return 0
  57. }
  58. dm_add () {
  59. cmd=""
  60. for x in /dev/{ide,scsi}/host*/bus*/target*/lun*/{disc,part*} ; do
  61. [ -b $x ] || continue
  62. grep -q $x /etc/conf/dm/mounts && continue
  63. cmd="$cmd '$x' 'device=$x'"
  64. done
  65. eval "gui_menu dm_add1 'Please select the device to use' $cmd" || return
  66. cmd=""
  67. gui_input "Please enter mountpoint of $device" "/data" mountpoint || return
  68. gui_menu dm_add2 "Please enter current state of $device" \
  69. "is encrypted" "status=encrypted" \
  70. "Decrypt" "status=decrypt" \
  71. "Encrypt" "status=encrypt" \
  72. "Encrypted Swap (read documentation)" "status=swap" \
  73. "not encrypted" "status=plain" || return
  74. echo -e "$device\t$mountpoint\t$status" >>/etc/conf/dm/mounts
  75. recreate_initrd=1
  76. }
  77. main() {
  78. run=0
  79. if [ ! -f /etc/conf/dm/mounts ] ; then
  80. mkdir -p /etc/conf/dm
  81. touch /etc/conf/dm/mounts
  82. fi
  83. while [ $run -eq 0 ] ; do
  84. cmd=""
  85. while read device mountpoint status ; do
  86. cmd="$cmd 'Edit device $device ($status on $mountpoint)' 'dm_edit $device'"
  87. done < /etc/conf/dm/mounts
  88. cmd="$cmd 'Add new device' 'dm_add'"
  89. eval "gui_menu dm 'encrypted filesystems' $cmd"
  90. run=$?
  91. done
  92. tmp="`mktemp`"
  93. grep -v "added by mod_dm" /etc/conf/kernel >$tmp
  94. while read device mountpoint status ; do
  95. if [ "$status" == "swap" -o "$status" == "encrypted" -o "$status" == "encrypt" -o "$status" == "decrypt" ] ; then
  96. for x in aes-i586 dm-mod dm-crypt ; do
  97. grep -q $x $tmp || cat >> $tmp <<-EOF
  98. ### $x ### added by mod_dm
  99. modprobe $x # added by mod_dm
  100. EOF
  101. done
  102. fi
  103. done < /etc/conf/dm/mounts
  104. rm -f /etc/conf/kernel
  105. mv $tmp /etc/conf/kernel
  106. chmod 644 /etc/conf/kernel
  107. tmp=`mktemp`
  108. rm -rf ${tmp}
  109. grep -v fsck /etc/conf/initrd/initrd_dm > ${tmp}
  110. rm -f /etc/conf/initrd/initrd_dm
  111. mv ${tmp} /etc/conf/initrd/initrd_dm
  112. while read dev a mnt b fs c ; do
  113. [ -e "/sbin/fsck.${fs}" ] && echo "/sbin/fsck.${fs} /sbin/fsck.${fs}"
  114. done < <( mount ) | sort | uniq >>/etc/conf/initrd/initrd_dm
  115. echo "/sbin/fsck /sbin/fsck" >>/etc/conf/initrd/initrd_dm
  116. }