stageinstall.sh 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. #copied from digit's witchnotes.
  21. #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).
  22. function howdlstage3 {
  23. echo
  24. $WITCH/color.sh QUESTION "how would you like to fetch your stage3"
  25. echo
  26. $WITCH/color.sh GREEN "
  27. A. get it same way as in gentoo handbook (instructive)
  28. B. enter a direct URL to the stage3 (INCOMPLETE)
  29. C. enter a location in the file system (already have downloaded)(INCOMPLETE)
  30. D. already extracted"
  31. read Stage3dlmethod
  32. case $Stage3dlmethod in
  33. A|a)
  34. echo "$Stage3dlmethod was selected."
  35. sleep 1
  36. browserstage3
  37. ;;
  38. B|b)
  39. echo "$Stage3dlmethod was selected."
  40. sleep 4
  41. urlstage3
  42. ;;
  43. C|c)
  44. echo "$Stage3dlmethod was selected."
  45. sleep 4
  46. locstage3
  47. ;;
  48. D|d)
  49. echo "Proceeding..."
  50. sleep 2
  51. ;;
  52. esac
  53. }
  54. function browserstage3 {
  55. echo "witchcraft will use browsers to download vital parts (and less vital parts too)"
  56. sleep 1
  57. echo "ok"
  58. sleep 1
  59. #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:
  60. #TXTBROWSER=hash links 2>&- || { echo >&2 "links is not installed. how about lynx..."; lynx 1; }
  61. #echo "what is your prefered text webbrowser?" && read -r TXTBROWSER
  62. # ... i think. anyways, i'll not implement (uncomment) that just yet. it'd mean making the appropriate changes bellow too.
  63. #variablise to denote any special needs per specific stages (such as the differences between exherbo and gentoo stages.)
  64. echo "READ INSTRUCTIONS CAREFULLY ~"
  65. echo "here you need to extract a stage3 compressed tarball to $SYSPATH"
  66. 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."
  67. echo ""
  68. 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
  69. echo "If you're using a text browser: Select one and press D to download. Otherwise, download however you wish."
  70. echo ""
  71. 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."
  72. $WITCH/color.sh YELLOW "make sure it's in the $SYSPATH path."
  73. echo ""
  74. $WITCH/color.sh GREEN "ready to follow those instructions? (y - yes) (p - yes, with proxy support ~ may not work)"
  75. read
  76. # appears that to automate it
  77. # use netstat + wget
  78. # will do that in another option for downloading stage3.
  79. case $REPLY in
  80. y)
  81. $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"
  82. read -p "ready to continue? (y):"
  83. if [ "$REPLY" == "y" ]; then
  84. echo "proceeding"
  85. echo "so what's your stage3 filename?"
  86. read FILENAME
  87. if [ -f $SYSPATH/$FILENAME ]; then
  88. echo "excellent you seem to have got your stage3 downloaded successfully."
  89. extractstage3 $SYSPATH/$FILENAME
  90. else
  91. echo "looks like you didn't manage to download your stage3 successfully."
  92. echo "in a couple of seconds we'll rerun this function."
  93. sleep 3
  94. browserstage3
  95. fi
  96. fi
  97. ;;
  98. p)
  99. $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"
  100. read -p "ready to continue? (y):"
  101. if [ "$REPLY" == "y" ]; then
  102. echo "proceeding"
  103. echo "so what's your stage3 filename?"
  104. read FILENAME
  105. if [ -f $SYSPATH/$FILENAME ]; then
  106. echo "excellent you seem to have got your stage3 downloaded successfully."
  107. sleep 2
  108. extractstage3 $SYSPATH/$FILENAME
  109. else
  110. echo "looks like you didn't manage to download your stage3 successfully."
  111. echo "in a couple of seconds we'll rerun this function."
  112. sleep 3
  113. browserstage3
  114. fi
  115. fi
  116. ;;
  117. n) exit ;;
  118. esac
  119. }
  120. function urlstage3 {
  121. echo "where are you getting your stage3 compressed-tarball from? what's the exact url?"
  122. read STAGE3URL
  123. cd $SYSPATH
  124. wget $STAGE3URL
  125. extractstage3 $STAGE3URL
  126. }
  127. function locstage3 {
  128. echo "where is your stage3 compressed-tarball located at? what's the exact file path adress?"
  129. read STAGE3LOC
  130. extractstage3 $STAGE3LOC
  131. }
  132. function extractstage3 {
  133. #set this so user can choose if they want verbose output
  134. echo "unpacking your stage3 ($FILE) to $SYSPATH. this may take some time, please wait."
  135. echo "extracting $1 to $SYSPATH"
  136. tar xvf $1 -C $SYSPATH
  137. }
  138. #script starts here.
  139. sleep 1
  140. echo
  141. howdlstage3