stageinstall.sh 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. echo "======================"
  2. BROWSER=$(sed -n '2p' $WITCH/config.txt)
  3. PROX=$(sed -n '3p' $WITCH/config.txt)
  4. echo "Browser: $BROWSER"
  5. echo "Proxy: $PROX"
  6. DISTRONAME=$(sed -n '1p' $WITCH/config.base.txt)
  7. ARCH=$(sed -n '3p' $WITCH/config.base.txt)
  8. echo "Distroname: $DISTRONAME"
  9. echo "Arch: $ARCH"
  10. echo "======================"
  11. if [ $DIMG_RUN == "true" ]; then
  12. SYSPATH=$WITCH/sys/$DISTRONAME
  13. else
  14. SYSPATH=/mnt/$DISTRONAME
  15. fi
  16. #############
  17. #############
  18. # stageinstall
  19. # Needs some changes. METADISTRO has been included for usage.
  20. #MIX ... this is where the addaption from gentoo to poly-distro develops
  21. #copied from digit's witchnotes.
  22. #change the browser bit. at least extend the explanation, or re-word to something like, "download the .tar.bz2 stage3 file apropriate for your architechture, to $SYSPATH/" and then add a "are you ready to proceed? (have you got the stage3 in your distro-to-be's root dir?)" and perhaps even altering it, since i already have a check in place, change what happens upon that check failing, so that it gives the user time to arrange that to make sure it is there... perhaps even advising/educating on ways to do that (like explaining how with tty n wget or cp etc).
  23. function howdlstage3 {
  24. echo
  25. $WITCH/color.sh QUESTION "how would you like to fetch your stage3"
  26. echo
  27. $WITCH/color.sh GREEN "
  28. A. get it same way as in gentoo handbook (instructive)
  29. B. enter a direct URL to the stage3 (INCOMPLETE)
  30. C. enter a location in the file system (already have downloaded)(INCOMPLETE)
  31. D. already extracted"
  32. read Stage3dlmethod
  33. case $Stage3dlmethod in
  34. A|a)
  35. echo "$Stage3dlmethod was selected."
  36. sleep 1
  37. browserstage3
  38. ;;
  39. B|b)
  40. echo "$Stage3dlmethod was selected."
  41. sleep 4
  42. urlstage3
  43. ;;
  44. C|c)
  45. echo "$Stage3dlmethod was selected."
  46. sleep 4
  47. locstage3
  48. ;;
  49. D|d)
  50. echo "Proceeding..."
  51. sleep 2
  52. ;;
  53. esac
  54. }
  55. function browserstage3 {
  56. echo "witchcraft will use browsers to download vital parts (and less vital parts too)"
  57. sleep 1
  58. echo "ok"
  59. sleep 1
  60. #get links n lynx variablised, so can then have either used throughout with ease (y'know, so like later on it'd be just $TXTBROWSER insteada links, and TXTBROWSER would be referenced to either links or lynx, like so:
  61. #TXTBROWSER=hash links 2>&- || { echo >&2 "links is not installed. how about lynx..."; lynx 1; }
  62. #echo "what is your prefered text webbrowser?" && read -r TXTBROWSER
  63. # ... i think. anyways, i'll not implement (uncomment) that just yet. it'd mean making the appropriate changes bellow too.
  64. #variablise to denote any special needs per specific stages (such as the differences between exherbo and gentoo stages.)
  65. echo "READ INSTRUCTIONS CAREFULLY ~"
  66. echo "here you need to extract a stage3 compressed tarball to $SYSPATH"
  67. echo "once you\'ve read these instructions, press y (and enter) to use \"$BROWSER\" web browser to navigate http://www.gentoo.org/main/en/mirrors2.xml to download your stage3 tarball for the base system."
  68. echo ""
  69. echo "Once the page loads and you\'ve found a nearby mirror, navigate to the ** releases/$ARCH/autobuilds/ ** directory. There you should see all available stage files for your architecture (they might be stored within subdirectories named after the individual subarchitectures). download the tar.bz2, not a tar.xz" #we'll add ability to use any format later. or maybe ye who is reading this can. :P
  70. echo "If you're using a text browser: Select one and press D to download. Otherwise, download however you wish."
  71. echo ""
  72. echo "This may take some time. When it has finished, quit the browser (press q in links browser) (or just close the tab) and the rest of this script will resume."
  73. $WITCH/color.sh YELLOW "make sure it's in the $SYSPATH path."
  74. echo ""
  75. $WITCH/color.sh GREEN "ready to follow those instructions? (y - yes) (p - yes, with proxy support ~ may not work)"
  76. read
  77. # appears that to automate it
  78. # use netstat + wget
  79. # will do that in another option for downloading stage3.
  80. case $REPLY in
  81. y)
  82. $BROWSER http://www.gentoo.org/main/en/mirrors2.xml || $WITCH/color.sh ERROR "hmm things don't seem to have worked. open up your browser yourself, navigate to http://www.gentoo.org/main/en/mirrors2.xml and download to the witch directory at $SYSPATH"
  83. read -p "ready to continue? (y):"
  84. if [ "$REPLY" == "y" ]; then
  85. echo "proceeding"
  86. echo "so what's your stage3 filename?"
  87. read FILENAME
  88. if [ -f $SYSPATH/$FILENAME ]; then
  89. echo "excellent you seem to have got your stage3 downloaded successfully."
  90. extractstage3 $SYSPATH/$FILENAME
  91. else
  92. echo "looks like you didn't manage to download your stage3 successfully."
  93. echo "in a couple of seconds we'll rerun this function."
  94. sleep 3
  95. browserstage3
  96. fi
  97. fi
  98. ;;
  99. p)
  100. $BROWSER -http-proxy $PROX http://www.gentoo.org/main/en/mirrors.xml || $WITCH/color.sh ERROR "hmm things don't seem to have worked. open up your browser yourself, navigate to http://www.gentoo.org/main/en/mirrors2.xml and download to the witch directory at $SYSPATH"
  101. read -p "ready to continue? (y):"
  102. if [ "$REPLY" == "y" ]; then
  103. echo "proceeding"
  104. echo "so what's your stage3 filename?"
  105. read FILENAME
  106. if [ -f $SYSPATH/$FILENAME ]; then
  107. echo "excellent you seem to have got your stage3 downloaded successfully."
  108. sleep 2
  109. extractstage3 $SYSPATH/$FILENAME
  110. else
  111. echo "looks like you didn't manage to download your stage3 successfully."
  112. echo "in a couple of seconds we'll rerun this function."
  113. sleep 3
  114. browserstage3
  115. fi
  116. fi
  117. ;;
  118. n) exit ;;
  119. esac
  120. }
  121. function urlstage3 {
  122. echo "where are you getting your stage3 compressed-tarball from? what's the exact url?"
  123. read STAGE3URL
  124. cd $SYSPATH
  125. wget $STAGE3URL
  126. extractstage3 $STAGE3URL
  127. }
  128. function locstage3 {
  129. echo "where is your stage3 compressed-tarball located at? what's the exact file path adress?"
  130. read STAGE3LOC
  131. extractstage3 $STAGE3LOC
  132. }
  133. function extractstage3 {
  134. #set this so user can choose if they want verbose output
  135. echo "unpacking your stage3 ($FILE) to $SYSPATH. this may take some time, please wait."
  136. echo "extracting $1 to $SYSPATH"
  137. tar xvf $1 -C $SYSPATH
  138. }
  139. #script starts here.
  140. sleep 1
  141. echo
  142. howdlstage3