driveprep.sh 3.1 KB

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