driveprep.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. ############
  2. #############
  3. # driveprep
  4. # GLOBAL needs no change.
  5. #MIX ... this is where the addaption from gentoo to poly-distro develops
  6. echo "======================"
  7. DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
  8. echo "Distro name: $DISTRONAME"
  9. INTERVENE=$(sed -n '4p' $WITCH/config.txt)
  10. echo "Intervene? $INTERVENE"
  11. echo "======================"
  12. #this is the partition preparation function. calls of it aught imediately preceed the stageinstall function
  13. show_disk() {
  14. sleep 1
  15. echo
  16. $WITCH/color.sh GREEN "here's a nice little list of your drives."
  17. fdisk -l
  18. echo
  19. }
  20. create_mnt() {
  21. if [ ! -d /mnt/$a ]
  22. then
  23. mkdir /mnt
  24. fi
  25. echo "your new OS installation / distro name is $DISTRONAME (this will make a directory of that name in /mnt/___.):"
  26. if [ ! -d /mnt/$DISTRONAME/$a ]
  27. then
  28. mkdir /mnt/$DISTRONAME
  29. fi
  30. cd /mnt/$DISTRONAME
  31. }
  32. partition() {
  33. echo "do you need to partition? creating your partition for your own little witch. (y/n) :"
  34. read REPLY
  35. if [ "$REPLY" == "y" ]
  36. then
  37. $WITCH/procedure.d/partmanselector.sh #calls the partition manager selection function "partmanselector"
  38. elif [ "$REPLY" == "n" ]
  39. then
  40. echo "ok, ready to go so..."
  41. fi
  42. }
  43. error() { # first parameter is error message, second is fuction to execute
  44. $WITCH/color.sh ERROR "$1"
  45. "$2"
  46. }
  47. rootdir() {
  48. echo "where ya putting your root dir? (e.g. sda3) - (NOT /root, we mean /):"
  49. read -r ROOTDEV
  50. echo $ROOTDEV >> $WITCH/config.base.txt # a late 5th line :P
  51. if [ $INTERVENE == "y" ]
  52. then
  53. echo "we're going to mount /dev/$ROOTDEV to /mnt/$DISTRONAME. want a different location? [y/n]"
  54. read REPLY
  55. if [ $REPLY == "y" ]
  56. then
  57. echo "okay, type in your wanted location."
  58. read LOCATION
  59. mount /dev/$ROOTDEV $LOCATION || error "something went wrong. try again" rootdir
  60. else
  61. echo "okay."
  62. sleep 1
  63. mount /dev/$ROOTDEV /mnt/$DISTRONAME || error "something went wrong. try again" rootdir
  64. fi
  65. else
  66. mount /dev/$ROOTDEV /mnt/$DISTRONAME || error "something went wrong. try again" rootdir
  67. fi
  68. }
  69. boot() {
  70. echo "you want a separate boot right? [y/n]:"
  71. read
  72. if [ "$REPLY" == "y" ]
  73. then
  74. if [ ! -d /mnt/$DISTRONAME/boot/$a ]
  75. then
  76. mkdir /mnt/$DISTRONAME/boot
  77. fi
  78. echo "where ya putting your boot dir? (e.g. sda1):"
  79. read -r BOOTDEV
  80. mount /dev/$BOOTDEV /mnt/$DISTRONAME/boot || error "something went wrong. try again" boot
  81. fi
  82. # i wonder, if you can do "if $REPLY=y then else fi" or something like that.
  83. }
  84. home() {
  85. echo "you want a separate home too? (y):"
  86. read
  87. if [ "$REPLY" == "n" ]
  88. then
  89. echo "ok your home partition will just be lumped in with root, like the stupid people use."
  90. elif [ "$REPLY" == "y" ]
  91. then
  92. if [ ! -d /mnt/$DISTRONAME/home/$a ]
  93. then
  94. mkdir /mnt/$DISTRONAME/home
  95. fi
  96. echo "where ya putting your home dir? (e.g. sda1):"
  97. read -r HOMEDEV
  98. mount /dev/$HOMEDEV /mnt/$DISTRONAME/home || error "something went wrong. try again" home
  99. else
  100. home
  101. fi
  102. }
  103. dimg_script() {
  104. mkdir $WITCH/sys
  105. mkdir $WITCH/sys/$DISTRONAME
  106. }
  107. # start of execution of methods
  108. if [ "$DIMG_RUN" == "true" ]; then
  109. dimg_script
  110. else
  111. show_disk
  112. create_mnt
  113. partition
  114. rootdir
  115. boot
  116. home
  117. fi
  118. sleep 1