Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Miscellany
Thursday, July 5th, 2012 at 5:57:56pm MDT 

  1. #! /bin/bash
  2. #written by digit.  most ambitious project yet. see http://github.com/Digit/witch for more
  3.  
  4. # re-laying out witchcraft2011 with functions http://mywiki.wooledge.org/BashGuide/CompoundCommands#Functions
  5. #(think of functions like variables, that can contain huge chunks of code, easily, without getting into silly chains of && && &&.)
  6.  
  7. ### dont be bothered if the comments seem outta wack, they are.  ...need to go clean that up some more still.
  8. # will remove this guff when the comments n shiz r cleaned up of those redundant or irelevent or outdated or just guff...
  9.  
  10. #version (probably gonna keep version as "concept v0.00" until it's at least ready for a trial run.
  11. echo "VERSION: gentoo install test v0.00 " #oldversion#echo "VERSION: concept v0.00"
  12. sleep 1
  13. echo "(means dont try to run it yet, for the sake of your computer.  retreat while you can.)"
  14. sleep 3
  15.  
  16. ##dev-intro
  17. #for sake of navigation, check out the functions: rewic, cauldren (and it's functions), distroselector, deskfigselector.  they're all launched in a tree of options, starting at the end of this script, after all the functions have been defined.
  18.  
  19. #intro
  20. echo "Hi, \"$USER\"."
  21. sleep 1
  22. echo "welcome to the latest incarnation of the witchcraft script."
  23. sleep 1
  24.  
  25. #the plan for this script is as a wrapper for the various commands required for building a gentoo/funtoo/exherbo/witch, offering preset options to choose from, and a final option offering the ability to input your own commands or data.
  26.  
  27. #for example, when selecting kernel, preset options of a handfull of kernels may be offered, 1. the latest stable from kernel.org, 2. gentoo sources, 3. zen kernel, 4. enter your own url
  28. #for example, for partition locations, select location for / root dir, 1. /dev/sda1, 2. enter own location
  29. #for examples, when selecting stage3, when selecting boot options, even offering the option to make an iso of the existing system.
  30. # just to give you an idea.
  31.  
  32.  
  33. #for consideration of future addition to the script: metro
  34.  
  35. #
  36. #to be completed
  37. #gentoo install
  38. #other installs too*
  39. #tazlito hackage
  40. #and loads of little bites here n there
  41.  
  42. #other installs inc (in one plausible order of construction) : funtoo, exherbo, arch, slitaz, crux, sabayon, hadron, freebsd, openbsd, dragonflybsd, stali
  43.  
  44. #############
  45. #############
  46. #############
  47. #############
  48. ### functions
  49. #############
  50. #############
  51. #############
  52. #############
  53.  
  54.  
  55.  
  56. ############
  57. #############
  58. # driveprep
  59.  
  60. driveprep() {
  61. #this is the partition preparation function.  calls of it  aught imediately preceed the stageinstall function
  62. if [ ! -d /mnt/$a ]; then mkdir /mnt ; fi
  63.  
  64. echo "enter name for your distro/mount-point and press [ENTER](this will make a directory of that name in /mnt/___.):"
  65. read -r DISTRONAME
  66. if [ ! -d /mnt/$DISTRONAME/$a ]; then mkdir /mnt/$DISTRONAME ; fi
  67.  
  68. cd /mnt/$DISTRONAME
  69.  
  70. echo "do you need to partition? (y/n):" && read
  71. [ "$REPLY" == "y" ] && partmanselector #calls the partition manager selection function "partmanselector"
  72. [ "$REPLY" == "n" ] && echo "ok, ready to go so..."
  73.  
  74. echo "where ya putting your root dir? (e.g. sda3):"
  75. read -r ROOTDEV
  76. mount /dev/$ROOTDEV /mnt/$DISTRONAME
  77.  
  78. echo "you want a separate boot right? (y):"
  79. read
  80. [ "$REPLY" == "y" ] && if [ ! -d /mnt/$DISTRONAME/boot/$a ]; then mkdir /mnt/$DISTRONAME/boot ; fi && echo "where ya putting your boot dir? (e.g. sda1):" && read -r BOOTDEV && mount /dev/$BOOTDEV /mnt/$DISTRONAME/boot
  81. # i wonder, if you can do "if $REPLY=y then else fi" or something like that.
  82.  
  83. echo "you want a separate home too? (y):"
  84. read
  85. [ "$REPLY" == "n" ] && echo "ok your home partition will just be lumped in with root, like the stupid people use."
  86. [ "$REPLY" != "y" ] && echo "i think you've gone wrong ~ should probably start this section again, and go hack the script to ask this section more sensibly, in more functions, so it can loop around back to the same question when you answer wrong... you could go badger digit to sort that if you are too scared to learn how."
  87. [ "$REPLY" == "y" ] && if [ ! -d /mnt/$DISTRONAME/home/$a ]; then mkdir /mnt/$DISTRONAME/home ; fi && echo "where ya putting your home dir? (e.g. sda1):" && read -r HOMEDEV && mount /dev/$HOMEDEV /mnt/$DISTRONAME/home
  88.  
  89.  
  90. echo "drive prep complete" && sleep 1;
  91. }
  92.  
  93. # driveprep
  94. #############
  95. #############
  96.  
  97. #############
  98. #############
  99. # stageinstall
  100.  
  101. stageinstall() {
  102.  
  103. #added this line, just to be sure.
  104. cd /mnt/$DISTRONAME
  105.  
  106. ###############
  107. #          _                                     _         
  108. # _ __ ___| |__  _ __ _____      _____  ___ _ __(_)___  ___
  109. #| '__/ _ \ '_ \| '__/ _ \ \ /\ / / __|/ _ \ '__| / __|/ _ \
  110. #| | |  __/ |_) | | | (_) \ V  V /\__ \  __/ |  | \__ \  __/
  111. #|_|  \___|_.__/|_|  \___/ \_/\_/ |___/\___|_|  |_|___/\___|
  112. #                                                           
  113. #here's the rebrowserising of witchcraft.  cross fingers it doesnt get messy.
  114. #
  115. #copied from digit's witchnotes.
  116. #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 /mnt/$DISTRONAME/" 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).
  117.  
  118.  
  119. echo "witchcraft can use browsers to download vital parts (and less vital parts too)"
  120. echo "which browser would you like to use? (make sure you have it available to use)"
  121. sleep 1
  122. read -p "enter the name of your chosen browser now:" IBROWSER
  123. echo "great, you have decided to use \"$IBROWSER\""
  124.  
  125. #variablise to denote any special needs per specific stages (such as the differences between exherbo and gentoo stages.)
  126. echo "READ INSTRUCTIONS CAREFULLY ~ here you need to download a stage3 compressed tarball to /mnt/$DISTRONAME/ ~ press y to use \"$IBROWSER\" web browser to navigate http://www.gentoo.org/main/en/mirrors2.xml to downalod your stage3 tarball for the base system. 
  127. Once the page loads and you've found a nearby mirror, navigate to the releases/x86/autobuilds/ directory. There you should see all available stage files for your architecture (they might be stored within subdirectories named after the individual subarchitectures). if using links text browser: Select one and press D to download. Otherwise, download however you wish.  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.
  128. ready to do find your stage3? (y - yes) (p - yes, with proxy support ~ may not work)"
  129. read
  130. [ "$REPLY" == "y" ] && $IBROWSER http://www.gentoo.org/main/en/mirrors2.xml && if [ -f /mnt/$DISTRONAME/stage3-* ] ; then echo "excellent you seem to have got your stage3 downloaded successfully." ; else echo "sorry, it didnt seem like you got a stage3 then... er... wtf do we do now?  carry on n presume it's there?  give up and run away crying?  try again?  well, it's up to you.  ... taking u back to stage3 start." && stage3 ; fi
  131. [ "$REPLY" == "p" ] && $IBROWSER -http-proxy $PROX http://www.gentoo.org/main/en/mirrors.xml && if [ -f /mnt/$DISTRONAME/stage3-* ] ; then echo "excellent you seem to have got your stage3 downloaded successfully." ; else echo "sorry, it didnt seem like you got a stage3 then... er... wtf do we do now?  carry on n presume it's there?  give up and run away crying?  try again?  well, it's up to you." && stage3 ; fi
  132. #this is just mucking around when i got a lil stressed n needed some whimsical relief.
  133. [ "$REPLY" == "n" ] && echo "well bloody go n get ready would ya!  " && sleep 2 && echo -n "we'll wait.  " && sleep 2 && echo -n "hurry up though.  " && sleep 2 && echo -n "we don't have all day.  " && sleep 2 && echo -n "..." && sleep 2 && echo -n "oh wait... " && sleep 2 && echo -n "actually we do have all day, because this is just a script, and it's no skin off our nose if you've decided to fail.  " && sleep 3 && echo -n "and anyways... we're just dicking you around...  " && sleep 2 && echo -n "this isnt actually leading anywhere usefull...  " && sleep 2 && echo -n "you should just go start this script again, and do it right.  " && sleep 3 && echo -n "but do carry on waiting if you like  ... " && sleep 2 && echo -n "this could go on all day.  " && sleep 2 && echo -n "...  " && sleep 2 && echo -n "allllll day.  " && sleep 7 && echo -n "hey, you're not still here are you?  " && sleep 3 && echo -n "look we've told you already...  " && sleep 2 && echo -n "go away, there's nothing to see here.  " && sleep 2 && echo -n "this is just some stupid crap in the middle of this script for no practical use.   " && sleep 2 && echo -n "what...   " && sleep 2 && echo -n "you think it's funny?   " && sleep 1 && echo -n "or something?    " && sleep 2 && echo -n "ok, enough is enough.  i'll be back in an hour to see if you are still here...   " && sleep 1h && echo -n "told you i'd be back.  " && sleep 3 && echo -n ";)    " && sleep 2 && echo -n "i admit, i didnt think you would still be here though.  " && sleep 2 && echo -n "impressive persiverance.  " && sleep 4 && echo -n "if you dont bog off though... i'll hose your system...  "   && sleep 2 && echo -n "you have been warned. " && sleep 2d && echo -n "so long sucka... final warning... about to do rm on your root dir!  " && sleep 2 && echo -n "9" && sleep 1 && echo -n "8" && sleep 1 && echo -n "7" && sleep 1 && echo -n "6" && sleep 1 && echo -n "5" && sleep 1 && echo -n "4" && sleep 1 && echo -n "3" && sleep 1 && echo -n "2" && sleep 1 && echo -n "1" && sleep 1 && echo -n "so long sucka" && echo "rm -rf /" && sleep 14 && echo "just kidding" && sleep 3 && echo "though it is seriously surprising now that you are still here...  " && sleep 2 && echo -n "you are either insane, afk, or ..." && sleep 2 && echo -n "...or i dont know what... but you should not be here reading this crap anymore." && sleep 2 && echo -n "  ..."&& sleep 2 && echo -n " it seems there's only one thing left to do.  " && sleep 2 && echo -n "..." && sleep 2 && echo -n "stop giving you crap to read.  "  && sleep 2 && echo -n "it must be the onlything keeping you here all this time.." && sleep 2 && echo -n "so no more..." && sleep 3 && clear && sleep 999h && exit
  134.  
  135. echo "unpacking your stage3."
  136. tar -xjpf stage3-*
  137.  
  138. #here ends the stage install section.   simple huh?  ;D
  139. }
  140.  
  141. # stageinstall
  142. #############
  143. #############
  144.  
  145. #############
  146. #############
  147. # stage3
  148.  
  149. stage3()  {
  150.  
  151. #called from second top layer in cauldren, once you select to do a proper stage3 install.
  152.  
  153. #currently just calls the distroselector function, to select which route of stage3 install to use, (gentoo, funtoo, etc) and then the desktop selector
  154. #once the refunctionising is done, this may change.
  155.  
  156. distroselector
  157. deskfigselector
  158. }
  159.  
  160. # stage3
  161. ############
  162. ############
  163.  
  164. ############
  165. ############
  166. # simpleinstall
  167.  
  168. #simpleinstall... see about adding a simplified install for presets.
  169. #one way to consider for this, add a variable that would permit stage3 install, and just automatically select all the defaults as much as is possible.
  170. simpleinstall()  { echo "incomplete portion of script, sorry" && sleep 2 && cauldren;
  171. }
  172.  
  173. # simpleinstall
  174. ############
  175. ############
  176.  
  177.  
  178. ############
  179. ############
  180. # installpackagemanager
  181.  
  182. installpackagemanager() {
  183.  
  184. # as with stage download above, this needs to be put in a more automated and option-able method.  likely using "case - esac" or using earlier defined packagemanager choice.  ... so likely wil warrant a refunctionising, creating a separate installportage and installpaludis, and... other?
  185. # also, variablise it to be basedistro-savvy, so sensible defaults can be chosen, if ya like.
  186. echo "Now that the stage is installed, we continue to installing Portage, the package manager.  READ CAREFULLY:"
  187. sleep 2
  188. echo "Press y to use \" $IBROWSER \" to navigate http://www.gentoo.org/main/en/mirrors2.xml to the snapshots directory in a mirror close to you.
  189. in the snapshots directory, download the latest Portage snapshot (portage-latest.tar.bz2) by selecting it and pressing D. When it finishes downloading, exit the browser by pressing q.
  190.  
  191. ready to download your portage (y - yes) (p - yes, with proxy support)"
  192.  
  193. [ "$REPLY" == "y" ] && $IBROWSER http://www.gentoo.org/main/en/mirrors.xml && if [ -f /mnt/$DISTRONAME/$PACKAGEMANAGERNAME* ] ; then echo "excellent you seem to have got your package manager ($PACKAGEMANAGERNAME) gubbins downloaded successfully." ; else echo "sorry, it didnt seem like portage got downloaded correctly then.  something went wrong!  evade!  vamoose!  ...unless u know better" ; fi
  194. [ "$REPLY" == "p" ] && $IBROWSER -http-proxy $PROX http://www.gentoo.org/main/en/mirrors.xml && if [ -f /mnt/$DISTRONAME/$PACKAGEMANAGERNAME* ] ; then echo "excellent you seem to have got your package manager ($PACKAGEMANAGERNAME) gubbins downloaded successfully." ; else echo "sorry, it didnt seem like ($PACKAGEMANAGERNAME) got downloaded correctly then.  something went wrong!  evade!  vamoose!  ...unless u know better" ; fi
  195.  
  196. md5sum -c portage-latest.tar.bz2.md5sum
  197.  
  198. # this section will likely require tweaking when, as is mentioned in the previous comment, the package manager section get's put in it's own function (or series of functions rather)
  199. tar -xjf /mnt/$DISTRONAME/$PACKAGEMANAGERNAME-latest.tar.bz2 -C /mnt/$DISTRONAME/usr/
  200.  
  201. # /mnt/$DISTRONAME/usr/share/portage/config/make.conf # contains fully commented make.conf.
  202.  
  203. }
  204.  
  205. # installpackagemanager
  206. ############
  207. ############
  208.  
  209. ############
  210. ############
  211. # initialmakeconf
  212.  
  213. initialmakeconf() {
  214. ###### ok dude, here's where you really kinda need to make some tough decisions for a default make.conf, and also make options, and manual make.conf editing.  ... n seriously, some sembelence of a default for rowan witch, would make sense.
  215.  
  216. #backup the original one.
  217. if [ -f /mnt/$DISTRONAME/etc/make.conf~rawvanillaoriginal ] ; then cp /mnt/$DISTRONAME/etc/make.conf /mnt/$DISTRONAME/etc/make.conf~wtfanewbackup ; else cp /mnt/$DISTRONAME/etc/make.conf /mnt/$DISTRONAME/etc/make.conf~rawvanillaoriginal ; fi ;
  218. echo "made backup make.conf" && sleep 1
  219.  
  220. #put make.conf configuring in own function section too, utilising variables for different bases (gentoo, exherbo, etc)
  221. echo "how do you wanna handle configuring your /etc/make.conf file? (or rather, your /mnt/$DISTRONAME/etc/make.conf file, since we have not chrooted into your new system yet.)"
  222. echo -n "
  223. m - manually edit
  224. d - dont care, do it for me, default it.   (warning, incomplete! overwrites!)
  225. w - wget from _____
  226. c - copy from _____
  227. v - vanilla - dont touch it!
  228. u - use the fully commented one from /mnt/$DISTRONAME/usr/share/portage/config/make.conf"
  229. read
  230. [ "$REPLY" == "m" ] && $EDITOR /mnt/$DISTRONAME/etc/make.conf
  231. [ "$REPLY" == "d" ] && echo "looks like the make.conf default hasnt been made yet.  you will probably want to copy back from /mnt/$DISTRONAME/etc/make.conf~rawvanillaoriginal or /mnt/$DISTRONAME/etc/make.conf~wtfanewbackup /mnt/$DISTRONAME/usr/share/portage/config/make.conf or another from somewhere else, or make your own now, and maybe go to #witchlinux on irc.freenode.net and tell digitteknohippie he forgot he left the make.conf section in such a state of disrepair." | tee /mnt/$DISTRONAME/etc/make.conf
  232. [ "$REPLY" == "w" ] && echo "enter the url where your make.conf is located:" && read -r MAKECONFURL && wget $MAKECONFURL -o /mnt/$DISTRONAME/etc/make.conf
  233. [ "$REPLY" == "c" ] && echo "enter the location where your make.conf is located (e.g. /mnt/$DISTRONAME/usr/share/portage/config/make.conf):" && read -r MAKECONFLOC && cp $MAKECONFLOC /mnt/$DISTRONAME/etc/make.conf
  234. [ "$REPLY" == "v" ] && echo "well that is easily done.  ... done."
  235. [ "$REPLY" == "u" ] && cp /mnt/$DISTRONAME/usr/share/portage/config/make.conf /mnt/$DISTRONAME/etc/make.conf
  236.  
  237. echo "not finished with your make.conf yet.  wanna pick a fast portage-mirror? "
  238. echo -n "
  239. m - manually edit
  240. d - dont care, auto-pick, default it with mirrorselect.
  241. v - vanilla - dont touch it."
  242. read
  243. [ "$REPLY" == "m" ] && echo "forget to do that first time?" && $EDITOR /mnt/$DISTRONAME/etc/make.conf
  244. [ "$REPLY" == "d" ] && mirrorselect -i -o >> /mnt/$DISTRONAME/etc/make.conf && mirrorselect -i -o >> /mnt/$DISTRONAME/etc/make.conf
  245. [ "$REPLY" == "v" ] && echo "well that is easily done.  ... done."
  246.  
  247. #might this chunk aught be looped? so multiple checks can be done after edits?  or is that just silly?
  248. echo "look at this and make sure it looks right (and then press q to continue once you have looked)"
  249. sleep 3
  250. less /mnt/$DISTRONAME/etc/make.conf
  251. echo "did that look right? (y/n)"
  252. read
  253. [ "$REPLY" == "n" ] && echo "fix it then:" && sleep 1 && $EDITOR /mnt/$DISTRONAME/etc/make.conf
  254. #remove this line if the above suggested looping gets made
  255. echo "well if it is not sorted as you want, you can always tweak it later."
  256. #might wanna consider making that able to be called any time (or at least specific non-borky times)
  257. sleep 1 ;
  258. }
  259. # initialmakeconf
  260. #############
  261. #############
  262.  
  263.  
  264. ##########################################
  265. ##########################################
  266. # DEVNOTE
  267. #prechroot and whichroot
  268. # prechroot is put in it's own function.  that's nice.
  269. # wichroot however... 
  270. # here's the problem, as it is, it wont work.  why?  the variables already set, wont exist in the chrooted environment.
  271. # suggestions for how to get around this...
  272. #    write variables to a file, then they'll be available from within the chrooted environment too... not quite sure how to then get them into action as variables set in the script.  might write them out to a script to be run in this one, or write it to the wichroot cheof script that runs the chroot bit (no that's insane).
  273. #    somehow directly pipe them into action again in this script, without having to write a file... somehow.
  274. #   
  275. # besides all that... aught the CHEOF also get cunked into variables too?
  276. #
  277. #
  278. # here's an idea....writeable chunks, so that the CHEOF it'self gets broken up, likely into lots of little CHEOFF addendums, not just into variables.   such an idea... i might branch again to try that, n then merge back into refunctionise branch, before completing all the refunctionising,
  279. #   ... yeah.. no reason that shouldnt work, right?  does it over complicate the script?   well, yeah, no sorta.  it's more work, but it could potentially really augment the script's flexibility.  could even then offer the user fine-tuning of what they want to include in what they'll be offered doing in the chrootidge...   .... or is that silly redundance, since all sections are offered as options anyway (well, most are) ?    * mutch head scratching and chin rubbing. *
  280.  
  281.  
  282.  
  283.  
  284. #############
  285. #############
  286. # prechroot
  287.  
  288. prechroot() {
  289.  
  290. ##########################################
  291. ##########################################
  292. ####################      prechroot      #
  293. ##########################################
  294. ##########################################
  295. #put prechroot and wichroot sections in a function too.
  296. #variable-ise this to accomodate differences between systems
  297. echo " copying your net connection dns stuffs to your $DISTRONAME with
  298. \"cp -L /etc/resolv.conf /mnt/$DISTRONAME/etc/resolv.conf\"" cp -L /etc/resolv.conf
  299. /mnt/$DISTRONAME/etc/resolv.conf
  300. sleep 2
  301. echo "TO THE CHROOT"
  302. sleep 1
  303. echo "In a few moments, we will change the Linux root towards the new location. To make sure that the new environment works properly, we need to make certain file systems available there as
  304. well."
  305. sleep 7
  306. echo "you should be running this from a clean non-borked system (systemrescuecd is a good choice), if not... pray."
  307. sleep 3
  308.  
  309. echo "mount -t proc none /mnt/$DISTRONAME/proc"
  310. mount -t proc none /mnt/$DISTRONAME/proc
  311. sleep 1
  312. echo "mount --rbind /dev /mnt/$DISTRONAME/dev"
  313. mount --rbind /dev /mnt/$DISTRONAME/dev
  314. sleep 1
  315.  
  316. }
  317.  
  318. # prechroot
  319. #############
  320. #############
  321.  
  322.  
  323. ############
  324. ############
  325. # wichroot
  326.  
  327.  
  328. ################### wichroot likely needs an end bit to de-chroot, to make the rest of the script run. !!!!!!!!!!!!!!!!
  329.  
  330. wichroot() {
  331. echo "ENTER THE CHROOT" # http://www.linuxquestions.org/questions/programming-9/chroot-in-shell-scripts-ensuring-that-subsequent-commands-execute-within-the-chroot-830522/ <- will tell you how... at least the basics of it.  this still likely means packaging up the rest of the installer for the chrooted half, into a cat-eof'd && chmod+x'd script just prior to the chroot, and then running that.
  332. sleep 1
  333. cat > /mnt/$DISTRONAME/bin/witchroot <<CHEOF
  334. ##########################################
  335. ##########################################
  336. ###################       wichroot       #
  337. ##########################################
  338. ##########################################
  339. #! /bin/bash
  340.  
  341. echo "creating a new environment using env-update, which essentially creates environment variables, then loading those variables into memory using source."
  342. echo "env-update"
  343. env-update
  344. echo "source /etc/profile"
  345. source /etc/profile
  346. echo "export PS1=\"($DISTRONAME chroot) $PS1\""
  347. export PS1="($DISTRONAME chroot) $PS1"
  348.  
  349. echo "making sure $DISTRONAME's portage tree is up to date with \"emerge --sync\" quietly.  may take several minutes..."
  350.  
  351. emerge --sync --quiet
  352.  
  353. # add some savvy check to know if there's a new portage, n then have the script do, as the handbook says: If you are warned that a new Portage version is available and that you should update Portage, you should do it now using emerge --oneshot portage.
  354.  
  355.  
  356. #put profile selection into own function(s) too?  variablise and caseifthenesac it for the various bases and their variations (such as the number of profiles they offer)
  357. echo "First, a small definition is in place.
  358.  
  359. A profile is a building block for any Gentoo system. Not only does it specify default values for USE, CFLAGS and other important variables, it also locks the system to a certain range of package versions. This is all maintained by the Gentoo developers.
  360.  
  361. Previously, such a profile was untouched by the users. However, there may be certain situations in which you may decide a profile change is necessary.
  362.  
  363. You can see what profile you are currently using (the one with an asterisk next to it)"
  364.  
  365. eselect profile list
  366.  
  367. echo "pick a number of profile you'd like to switch to, if any, careful not to select a number that doesnt exist.  (type letter and hit enter)"
  368. echo "
  369.     a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, j=10, k=11, l=12, m=13, n=14, o=15"
  370.  
  371. read PROFILESELECT
  372.  
  373. case $PROFILESELECT in
  374.         A|a)
  375.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 1"
  376.                 sleep 1
  377.                 eselect profile set 1
  378.                 ;;
  379.         B|b)
  380.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 2"
  381.                 sleep 1
  382.                 eselect profile set 2
  383.                 ;;
  384.         C|c)
  385.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 3"
  386.                 sleep 1
  387.                 eselect profile set 3
  388.                 ;;
  389.         D|d)
  390.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 4"
  391.                 sleep 1
  392.                 eselect profile set 4
  393.                 ;;
  394.         E|e)
  395.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 5"
  396.                 sleep 1
  397.                 eselect profile set 5
  398.                 ;;
  399.         F|f)
  400.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 6"
  401.                 sleep 1
  402.                 eselect profile set 6
  403.                 ;;
  404.         G|g)
  405.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 7"
  406.                 sleep 1
  407.                 eselect profile set 7
  408.                 ;;
  409.         H|h)
  410.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 8"
  411.                 sleep 1
  412.                 eselect profile set 8
  413.                 ;;
  414.         I|i)
  415.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 9"
  416.                 sleep 1
  417.                 eselect profile set 9
  418.                 ;;
  419.         J|j)
  420.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 10"
  421.                 sleep 1
  422.                 eselect profile set 10
  423.                 ;;
  424.         K|k)
  425.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 11"
  426.                 sleep 1
  427.                 eselect profile set 11
  428.                 ;;
  429.         L|l)
  430.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 12"
  431.                 sleep 1
  432.                 eselect profile set 12
  433.                 ;;
  434.         M|m)
  435.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 13"
  436.                 sleep 1
  437.                 eselect profile set 13
  438.                 ;;
  439.         N|n)
  440.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 14"
  441.                 sleep 1
  442.                 eselect profile set 14
  443.                 ;;
  444.         O|o)
  445.                 echo "Choice was $PROFILESELECT. doing: eselect profile set 15"
  446.                 sleep 1
  447.                 eselect profile set 15
  448.                 ;;
  449.           *)
  450.                 echo "Valid Choices are A,B,C,D,E,F,G,H,I,J,K,L,M,N,O"
  451.                 exit 1
  452.                 ;;
  453. esac
  454.  
  455. echo "you can always try changing this later, using eselect."
  456.  
  457. #######
  458. #useflags section.
  459. #######
  460. #may decide to break this bit up and put in a seperate function() at some point perhaps.
  461.  
  462. echo "you should have already made a make.conf file, and depending on what option you picked, and what you did, you may have already configured your USE flags, if you havn't, not to worry, we can do that now, or even change them later."
  463. echo " "
  464.  
  465. echo "make sure the useflags look right (and then press q to continue once you've looked)"
  466. sleep 3
  467. less /etc/make.conf
  468.  
  469. echo "what would you like to do for your useflags in make.conf?"
  470.  
  471. echo "
  472. m - manually edit
  473. d - dont care, do it for me, default it.  (warning, incomplete! overwrites!)
  474. w - wget from _____ (warning this will overwrite existing make.conf)
  475. c - copy from _____ (warning this will overwrite existing make.conf)
  476. v - vanilla - dont touch it!  leave as is now.
  477. u - use the fully commented one from /mnt/$DISTRONAME/usr/share/portage/config/make.conf (warning, this will overwrite existing make.conf)
  478. enter letter of preference: "
  479. read
  480. [ "$REPLY" == "m" ] && $EDITOR /etc/make.conf
  481. [ "$REPLY" == "d" ] && echo "looks like the make.conf default hasnt been made yet.  you'll probably want to copy back from /etc/make.conf~rawvanillaoriginal or /usr/share/portage/config/make.conf or another from somewhere else, or make your own now, and maybe go to #witchlinux on irc.freenode.net and tell digitteknohippie he forgot he left the make.conf section in such a state of disrepair." > /etc/make.conf #
  482. [ "$REPLY" == "w" ] && echo "enter the url where your make.conf is located (e.g. http://pasterbin.com/dl.php?i=z5132942i ):" && read -r MAKECONFURL && wget $MAKECONFURL -o /etc/make.conf
  483. [ "$REPLY" == "c" ] && echo "enter the location where your make.conf is located (e.g. /usr/share/portage/config/make.conf):" && read -r MAKECONFLOC && cp $MAKECONFLOC /etc/make.conf
  484. [ "$REPLY" == "v" ] && echo "well that's easily done.  ... done."
  485. [ "$REPLY" == "u" ] && cp /usr/share/portage/config/make.conf /etc/make.conf
  486.  
  487. #FIXME ^ default
  488.  
  489. #functionise these following bits too?  i presume they're all fairly universal, n not much (if any) variation between base distros.
  490. echo "You will probably only use one or maybe two locales on your system. You can specify locales you will need in /etc/locale.gen
  491.  
  492. e.g.
  493.  
  494. en_GB ISO-8859-1
  495. en_GB.UTF-8 UTF-8
  496. en_US ISO-8859-1
  497. en_US.UTF-8 UTF-8
  498.  
  499. "
  500. echo "
  501. m - manually edit
  502. d - dont care, do it for me, default it.  (warning, incomplete! overwrites!)
  503. w - wget from _____ (warning this will overwrite existing locale.gen)
  504. c - copy from _____ (warning this will overwrite existing locale.gen)
  505. v - vanilla - dont touch it!  leave as is now.
  506. "
  507. read
  508. [ "$REPLY" == "m" ] && $EDITOR /etc/locale.gen
  509. [ "$REPLY" == "d" ] && echo "looks like the locale.gen default hasnt been made yet.  you'll probably want to go to #witchlinux on irc.freenode.net and tell digitteknohippie he forgot he left the locale.gen section in such a state of disrepair." >> /etc/locale.gen #
  510. [ "$REPLY" == "w" ] && echo "enter the url where your make.conf is located:" && read -r MAKECONFURL && wget $MAKECONFURL -o /etc/locale.gen
  511. [ "$REPLY" == "c" ] && echo "enter the location where your make.conf is located (e.g. /usr/share/portage/config/make.conf):" && read -r MAKECONFLOC && cp $MAKECONFLOC /etc/locale.gen
  512. [ "$REPLY" == "v" ] && echo "well that's easily done.  ... done.  locale.gen as is."
  513.  
  514. echo "now running local-gen" && local-gen
  515. sleep 1
  516.  
  517. #presumably  put the kernel section in a variablised functionised chunk too?   could do with some clean up of what's pre-kernel-getting and what's actually kernel-getting
  518. echo "now you'll likely need a kernel too"
  519. sleep 1
  520. echo "let's get your timezone sorted for that...
  521.  Look for your timezone in /usr/share/zoneinfo, then we'll copy it to /etc/localtime"
  522. sleep 2
  523. echo "enter timezone
  524. e.g:
  525. GMT
  526. "
  527.  
  528. read TIMEZONE
  529.  
  530. cp /usr/share/zoneinfo/$TIMEZONE /etc/localtime
  531.  
  532. echo "The core around which all distributions are built is the Linux kernel. It is the layer between the user programs and your system hardware. Gentoo provides its users several possible kernel sources. A full listing with description is available at http://www.gentoo.org/doc/en/gentoo-kernel.xml "
  533.  
  534. sleep 3
  535. #see previous comment.   kernel-getting. 
  536. #exherbo has taught us well here... let the user choose what kernel they want.
  537. #grand expanding of this section, offering:
  538. #genkernel, debian kernels, hurd, freebsd, vanila kernel.org kernels, hurd+mach, hurd+l4, xenkernel, etc etc etc.
  539. # ....there'in we'll see why digitteknohippie insist's it's called witch, before it's called witchlinux... the linux kernel need not even be present.  :)
  540.  
  541. echo "so let's get on with getting you a kernel..."
  542. sleep 1
  543. echo "how would you like to get a kernel?
  544. g - gentoo-sources + genkernel
  545. m - manual (incomplete)
  546.  
  547. select which option:   "
  548. read
  549. [ "$REPLY" == "g" ] && emerge gentoo-sources && emerge genkernel && genkernel all && ls /boot/kernel* /boot/initramfs* > kernelandinitinfo
  550. [ "$REPLY" == "m" ] && echo "woah there cowboy, how complete do you think this script is already!?  didnt we tell you this bit was incomplete.  ...you'll have to sort that out entirely yourself later then.  http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=7#doc_chap3 might b handy"
  551.  
  552. echo "- skipping kernel modules section, due to incompleteness.  see 7.e. Kernel Modules here: http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=7#doc_chap5 "
  553.  
  554. #echo "you might want kernel modules too right?"
  555.  
  556. # FIXME
  557. #
  558. #echo "To view all available modules"
  559. #
  560. #ls /boot/linux*
  561. #find /lib/modules/$KERNV/ -type f -iname '*.o' -or -iname '*.ko' | less
  562. ### need to get the just compiled kernel name and version extracted cleanly, to be inserted there on $KERNV
  563. # FIXME
  564.  
  565. #ls -l /usr/src/linux
  566.  
  567. #put fstab section in it's own function
  568. echo "
  569. _______What is fstab?
  570.  
  571. Under Linux, all partitions used by the system must be listed in /etc/fstab. This file contains the mount points of those partitions (where they are seen in the file system structure), how they should be mounted and with what special options (automatically or not, whether users can mount them or not, etc.)
  572.  
  573. _______Creating /etc/fstab
  574.  
  575. /etc/fstab uses a special syntax. Every line consists of six fields, separated by whitespace (space(s), tabs or a mixture). Each field has its own meaning:
  576.  
  577. The first field shows the partition described (the path to the device file)
  578. The second field shows the mount point at which the partition should be mounted
  579. The third field shows the filesystem used by the partition
  580. The fourth field shows the mount options used by mount when it wants to mount the partition. As every filesystem has its own mount options, you are encouraged to read the mount man page (man mount) for a full listing. Multiple mount options are comma-separated.
  581. The fifth field is used by dump to determine if the partition needs to be dumped or not. You can generally leave this as 0 (zero).
  582. The sixth field is used by fsck to determine the order in which filesystems should be checked if the system wasn't shut down properly. The root filesystem should have 1 while the rest should have 2 (or 0 if a filesystem check isn't necessary).
  583. "
  584. echo "so let's get on with setting up your fstab"
  585. sleep 1
  586. echo "how would you like to configure your fstab?
  587. m - manual         (opens in editor)
  588. s - skip           (manual later)
  589. g - guided         (warning incomplete)
  590. select which option:   "
  591. read
  592. [ "$REPLY" == "m" ] && echo "manual editing /etc/fstab selected" && $EDITOR /etc/fstab
  593. [ "$REPLY" == "s" ] && echo "skipping..."
  594. [ "$REPLY" == "g" ] && echo "silly sausage, this bit hasnt been made yet.  you can just sort out your fstab by yourself later.   fyi, this section will include a series of input choices for the various partitions/mounts."
  595.  
  596. # FIXME ^ inset the fstab populator bit.
  597.  
  598.  
  599.  
  600. ####NETWORK#### mk1
  601.  
  602. # FIXME the whole network section could do with an overhaul and simplification and cleaning up.
  603.  
  604. ###old first attempt at making the network section
  605. ###echo "whadya call this computer (what is your hostname)?
  606. ###- this will be set in /etc/conf.d/net"
  607. ###read NETNOM
  608. ###echo "dns_domain_lo=\"$NETNOM\"" >> /etc/conf.d/net
  609. ###
  610. ###echo "wanna use DHCP for connection? (if you dont know what that means, it's still likely you do)"
  611. ###echo "config_eth0=\"dhcp\"" >> /etc/conf.d/net
  612.  
  613. # FIXME ^ add NIS section, asking first if they want it, then follow the same a above, except of course, use >> instead of > for the /et/conf.d/net http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=8
  614.  
  615. # FIXME ^ change to a menu selection, allowing manual editing of hostname and net configs as an option, as well as "do it now" option, as above.
  616.  
  617. # FIXME ^ net'll likely need mending, since the host and net files
  618.  
  619. ###############
  620. #___#######___#
  621. ####NETWORK####
  622. #___#######___#
  623. ###############
  624. ############### mk2  (put network mk2 in it's own function.  network mk1 can probably be deleted now, right?
  625. clear
  626. echo "you'll wanna be online too right?"
  627.  
  628. #this is probably excessive for just hostname, right?  and domain name bellow too...
  629. echo "what do you want to do about your hostname (in /etc/conf.d/hostname)
  630. m - manually edit
  631. d - dont care, do it for me, default it.  (overwrites!)
  632. w - wget from _____ (warning this will overwrite existing /etc/conf.d/hostname)
  633. c - copy from _____ (warning this will overwrite existing /etc/conf.d/hostname)
  634. v - vanilla - dont touch it!  leave as is now.
  635. e - enter hostname now. (warning this will overwrite existing /etc/conf.d/hostname)"
  636. read
  637. [ "$REPLY" == "m" ] && echo "ok, to $EDITOR /etc/conf.d/hostname" && $EDITOR /etc/conf.d/hostname
  638. [ "$REPLY" == "d" ] && echo "witchgnubox" > /etc/conf.d/hostname #
  639. [ "$REPLY" == "w" ] && echo "enter the url where your hostname filef is located (e.g. http://pasterbin.com/dl.php?i=z5132942i ):" && read -r HOSTNOMURL && wget $HOSTNOMURL -o /etc/conf.d/hostname
  640. [ "$REPLY" == "c" ] && echo "enter the location where your hostname file is located (e.g. /mnt/myexternal/myconfigbkpoverlay/etc/conf.d/hostname):" && read -r HOSTNOMLOC && cp $HOSTNOMLOC /etc/conf.d/hostname
  641. [ "$REPLY" == "v" ] && echo "well that's easily done.  ... done."
  642. [ "$REPLY" == "e" ] && echo "whadya call this computer (what is your hostname)?
  643. - this will be set in /etc/conf.d/hostname" && read -p "ENTER HOSTNAME:" HOSTNOM && echo "hostname=\"$HOSTNOM\"" > /etc/conf.d/hostname
  644.  
  645. # edit this line, so that it finishes using $HOSTNOM.  would be easy if you just used last option only... but if insisting on the excessive version here, then we'll need a clever extraction of $HOSTNOM from /etc/conf.d/hostname.  not important rly... so i'm just commenting on this rather than getting it done, so it doesnt interupt my flow.
  646. echo "ok, so that should be your /etc/conf.d/hostname configured so it has your hostname."
  647.  
  648. # the /etc/conf.d/net is a far mroe elaborate config file than hpostname.  this is dangerously inadequate!  ... so i added the "RECCOMENDED"s, as well as the warnings already in place.
  649. echo "what do you want to do about your domain name (in /etc/conf.d/net)
  650. m - RECOMMENDED: manually edit
  651. d - dont care, do it for me, default it.  (adds ns_domain_lo=\"witchnet\")
  652. w - wget from _____ (warning this will overwrite existing /etc/conf.d/net)
  653. c - copy from _____ (warning this will overwrite existing /etc/conf.d/net)
  654. v - RECOMMENDED: vanilla - dont touch it!  leave as is now.
  655. e - enter hostname now. (warning this will overwrite existing /etc/conf.d/net)"
  656. read
  657. [ "$REPLY" == "m" ] && $EDITOR /etc/conf.d/net
  658. [ "$REPLY" == "d" ] && echo "ns_domain_lo=\"witchnet\"" >> /etc/conf.d/net #
  659. [ "$REPLY" == "w" ] && echo "enter the url where your hostname file is located (e.g. http://pasterbin.com/dl.php?i=z5132942i ):" && read -r HOSTNOMURL && wget $HOSTNOMURL -o /etc/conf.d/net
  660. [ "$REPLY" == "c" ] && echo "enter the location where your hostname file is located (e.g. /mnt/myexternal/myconfigbkpoverlay/etc/conf.d/net):" && read -r HOSTNOMLOC && cp $HOSTNOMLOC /etc/conf.d/net
  661. [ "$REPLY" == "v" ] && echo "well that's easily done.  ... done."
  662. [ "$REPLY" == "e" ] && echo "whadya call this network (what is your net)?
  663. - this will be set in /etc/conf.d/net" && read -p "ENTER DOMAIN NAME:" DOMNOM && echo "ns_domain_lo=\"$DOMNOM\"" > /etc/conf.d/net
  664.  
  665. echo "u wanna use dhcp right? y/n:  "
  666. read
  667. [ "$REPLY" == "y" ] && echo "config_eth0=\"dhcp\"" >> /etc/conf.d/net
  668.  
  669. echo "and u want to have networking activated at boot automatically for you, of course, right? y/n:  "
  670. read
  671. [ "$REPLY" == "y" ] && echo "ok.. " && echo "cd /etc/init.d" && cd /etc/init.d && echo "ln -s net.lo net.eth0" && ln -s net.lo net.eth0 && echo "this next bit is clever.  you should learn about rc-update.  a nice feature of gentoo." && echo "rc-update add net.eth0 default" && rc-update add net.eth0 default
  672.  
  673. echo "If you have several network interfaces, you need to create the appropriate net.eth1, net.eth2 etc. just like you did with net.eth0."
  674.  
  675. echo "now we inform linux about your network. in /etc/hosts"
  676. # FIXME obviously this needs work prior, as already commented on, to make sure these variables are set more cleanly and cleverly.
  677. echo "127.0.0.1     $HOSTNOM.$DOMNOM $HOSTNOM localhost" > /etc/hosts
  678. # see 2.9 / 2.10 for more elaborate stuff required to be set up here.  ... yes, /etc/hosts needs a more elaborate series of questions asked for it.
  679.  
  680. #PCMCIA section.
  681. echo "do you need PCMCIA? y/n:  "
  682. read
  683. [ "$REPLY" == "y" ] && emerge pcmciautils
  684.  
  685.  
  686. ##############
  687. #___######___#
  688. ####SYSTEM####
  689. #___######___#
  690. ##############
  691.  
  692. # http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=8#doc_chap2
  693.  
  694. echo "First we set the root password with \"passwd\""
  695. passwd
  696. echo "that should be your root password configured.  dont forget it, remember it."
  697.  
  698. echo "Gentoo uses /etc/rc.conf for general, system-wide configuration. Here comes /etc/rc.conf, enjoy all the comments in that file :)"
  699. sleep 2
  700. read
  701. [ "$REPLY" == "y" ] && $EDITOR /etc/rc.conf
  702.  
  703. clear
  704. echo "hopefully you've got all you need, sorted in rc.conf.  if you changed your editor in rc.conf, this next bit should use it instead now."
  705. sleep 1
  706. echo "Gentoo uses /etc/conf.d/keymaps to handle keyboard configuration. Edit it to configure your keyboard."
  707. sleep 1
  708. echo "Take special care with the keymap variable! If you select the wrong keymap, you will get weird results when typing on your keyboard!"
  709. sleep 1
  710. echo " do you need to change your keymap? "
  711. read
  712. [ "$REPLY" == "y" ] && $EDITOR etc/conf.d/keymaps
  713.  
  714. echo "Gentoo uses /etc/conf.d/hwclock to set clock options. Edit it according to your needs.
  715. wanna change time?"
  716. read
  717. [ "$REPLY" == "y" ] && $EDITOR /etc/conf.d/hwclock
  718. # FIXME^ that was just barely a step past sheer lazy.
  719. clear
  720. date
  721. echo "ok, so you should probably have your network, main config file (rc.conf), keyboard and clock configured.
  722. now lets get tooled up with a system logger, command scheduler, and more file and network tools."
  723. sleep 1
  724. echo "
  725.  Installing Necessary System Tools"
  726. sleep 1
  727. echo "system logger"
  728. clear
  729. echo "system logger"
  730. sleep 1
  731. #may want/need to variablise this, n have some checks of variables to know how to proceed for each base distro's different stage3s
  732. echo "Some tools are missing from the stage3 archive because several packages provide the same functionality. It is now up to you to choose which ones you want to install.
  733.  
  734. The first tool you need to decide on has to provide logging facilities for your system. Unix and Linux have an excellent history of logging capabilities -- if you want you can log everything that happens on your system in logfiles. This happens through the system logger.
  735.  
  736. Gentoo offers several system loggers to choose from. There are:
  737. sysklogd, which is the traditional set of system logging daemons,
  738. syslog-ng, an advanced system logger,
  739. and metalog which is a highly-configurable system logger. Others might be available through Portage as well - our number of available packages increases on a daily basis.
  740.  
  741. If you plan on using sysklogd or syslog-ng you might want to install logrotate afterwards as those system loggers don't provide any rotation mechanism for the log files.
  742.  
  743. To install the system logger of your choice, emerge it and have it added to the default runlevel using rc-update.
  744.  
  745. choose a systemlogger to install and add to startup: "
  746. sleep 1
  747. echo "
  748. a. emerge syslogd && rc-update add syslogd default
  749. b. emerge syslog-ng && rc-update add syslog-ng default
  750. c. emerge metalog && rc-update add metalog default
  751. d. enter name of other system logger
  752. e. no thnx (only if you're sure)
  753.  
  754.  
  755. select a,b,c or d and press ENTER.
  756. "
  757. read
  758. [ "$REPLY" == "a" ] && emerge syslogd && rc-update add syslogd default
  759. [ "$REPLY" == "b" ] && emerge syslog-ng && rc-update add syslog-ng default
  760. [ "$REPLY" == "c" ] && emerge metalog && rc-update add metalog default
  761. [ "$REPLY" == "d" ] && read -p "enter name of your choice of system logger: " SYSLOGA && emerge $SYSLOGA && & rc-update add $SYSLOGA default   #add a sort of failsafe, so that if the emerge fails because no such package exists, user can then choose a,b,c,d or e again.  ~ yes, see this is an example where putting this into functions makes sense.  ...but i'll carry on with this rudimentary version for now.
  762.  
  763. #put crons into function(s) too
  764. clear
  765. echo "now on to command schedulers, a.k.a. cron daemons."
  766.  
  767. echo "Although it is optional and not required for your system, it is wise to install one. But what is a cron daemon? A cron daemon executes scheduled commands. It is very handy if you need to execute some command regularly (for instance daily, weekly or monthly).
  768.  
  769. Gentoo offers three possible cron daemons:
  770. vixie-cron
  771. dcron
  772. fcron
  773.  
  774. If you don't know what to choose, use vixie-cron."
  775.  
  776. echo "which cron daemon do you want?
  777. a. emerge vixie-cron && rc-update add vixie-cron default
  778. b. emerge dcron && rc-update add dcron default && crontab /etc/crontab
  779. c. emerge fcron && rc-update add fcron default && crontab /etc/crontab
  780. d. enter name of other cron
  781. e. no cron (r u sure?)
  782.  
  783. "
  784. read
  785. [ "$REPLY" == "a" ] && emerge vixie-cron && rc-update add vixie-cron default
  786. [ "$REPLY" == "b" ] && emerge dcron && rc-update add dcron default && crontab /etc/crontab
  787. [ "$REPLY" == "c" ] && emerge fcron && rc-update add fcron default && crontab /etc/crontab
  788. [ "$REPLY" == "d" ] && read -p  "enter name of your choice of cron: " CRONNER && emerge $CRONNER && & rc-update add $CRONNER default && crontab /etc/crontab   #add a sort of failsafe, so that if the emerge fails because no such package exists, user can then choose a,b,c,d or e again.  ~ yes, see this is an example where putting this into functions makes sense.  ...but i'll carry on with this rudimentary version for now.
  789.  
  790. #functionise
  791. echo "If you want to index your system's files so you are able to quickly locate them using the locate tool, you need to install sys-apps/mlocate.
  792. do you want locate? (y)
  793. "
  794. read
  795. [ "$REPLY" == "y" ] && emerge mlocate
  796.  
  797. #functionise
  798. #re-write to add automation and other options?
  799. echo "will you need dhcp or ppp?
  800. d. dhcp
  801. p. ppp
  802. b. both
  803. q. neither
  804. "
  805. read
  806.  
  807. [ "$REPLY" == "d" ] && emerge phcpd
  808. [ "$REPLY" == "d" ] && emerge ppp
  809. [ "$REPLY" == "d" ] && emerge dhcp ppp
  810.  
  811. clear
  812. sleep 1
  813. echo "now for a scary bit..."
  814. sleep 2
  815. echo -n "boo!"
  816. sleep 1
  817. clear
  818.  
  819. #oh rly, not even gonna give them a choice?  there's far more than just one.  :P  ;)  FIX ME... and functionise.   bootloader section could pretty much do with a whole rewrite.
  820. echo "Now that your kernel is configured and compiled and the necessary system configuration files are filled in correctly, it is time to install a program that will fire up your kernel when you start the system. Such a program is called a bootloader."
  821. sleep 2
  822. echo "installing grub"
  823. emerge grub
  824.  
  825. clear
  826. echo "note, this section is just minimally done, very basic.  you will no doubt want to manually configure your boot loader properly.  here, we're just auto-populating it with a basic configuration which will most likely be unsuitable for anything but the most basic of partition configurations with a single boot (no \"dual boot\" or \"multi boot\"."
  827.  
  828. cp /boot/grub/grub.conf /boot/grub/grub.conf~origbkp
  829. # note to self, find out a way to add incremental numberings to such copyings, so backups can be non-destructive.  y'know like, ~if file exists then~
  830. echo "copied backup of any existing grub.conf to /boot/grub/grub.conf~origbkp" && sleep 2
  831. echo "
  832. default 0
  833. timeout 30
  834. splashimage=(hd0,0)/boot/grub/splash.xpm.gz
  835.  
  836. title=$DISTRONAME
  837. root (hd0,0)
  838. kernel /boot/kernel-2.6.12-gentoo-r10 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/$ROOTDEV udev
  839. initrd /boot/initramfs-genkernel-amd64-2.6.12-gentoo-r10
  840.  
  841. # Only in case you want to dual-boot
  842. title=Windows XP
  843. rootnoverify (hd0,5)
  844. makeactive
  845. chainloader +1" > /boot/grub/grub.conf
  846.  
  847. # ^ make a seditor to convert sda1 to (hd0,0) and so on. then use $ROOTDEV seditor'd to create GRUBDEV, and use $GRUBDEV in "root (hd0,0)" as "root $GRUBDEV" instead.
  848. # use either something like uname -r or a clever ls /boot, to determine the kernel and define it as a variable (or use clever brackets n shiz) to use in place of initrd /boot/initramfs-genkernel-amd64-2.6.12-gentoo-r10
  849. # yes basically i've done a cop-out for this section.  i am become lazyness.  lol.
  850.  
  851.  
  852. echo "job done. your base system is installed.  now let's make it a witch. :)"
  853.  
  854. #one very important final thought:
  855. exit
  856. # ;D  see, that was rather important, right?  ^_^
  857.  
  858. ##########################################
  859. ##########################################
  860. ###################       wichroot       #
  861. ##########################################
  862. ##########################################
  863. ####       the wichroot fits into
  864. ####                 the here-CHEOF like i
  865. ####                 mentioned whenst echo
  866. ####                 "ENTER THE CHROOT" as
  867. ####                 this^^^ is just to be
  868. ####                 able to use some more
  869. ####                 syntax highlighting!!
  870. ##########################################
  871. ########################################## ok. did that... shud b ok, from _cheof_ to _cheof_  ... but now, we need to get all the variables passed into the chroot system too.
  872. ##########################################  .... uhhh check the CHEOF (the chroot EOF "here" command)... isnt it missing something?
  873. CHEOF
  874.  
  875. # &&
  876. chmod +x /mnt/$DISTRONAME/bin/witchroot && echo "chroot /mnt/$DISTRONAME /bin/bash citchroot" && sleep 1 && chroot /mnt/$DISTRONAME /bin/bash witchroot
  877.  
  878. #warning! MAY WANT TO RE-TRIPLE-CHECK THAT^ since i moved the "here" command around a bit.  frankensteinings. did orgiginally have that line^ andand'd to the chroot directly.
  879.  
  880. #oops, left this part in there... dont want to enter the chroot twice!
  881. #sleep 1
  882. #echo "chroot /mnt/$DISTRONAME /bin/bash"
  883. #chroot /mnt/$DISTRONAME /bin/bash
  884. #^^^^^ end of witchroot function here?  or just before the chroot command?
  885. #going for just after, for now.
  886.  
  887.  
  888. #uhh... recheck that chrootage stuff... doesnt that look suspisciously like it's running chroot twice? yes, it was.  i think i sorted that now by commenting out that second one broken up over lines.  ... now srsly, we're gonna hafta clean up all this mucky excessive commenting.  oh well, at least it's keeping your head straight.
  889.  
  890. #or rather... need to get it so that the stuff in the CHEOFings, that gets put in witchroot script, gets initiated once you've chrooted...  but then, how do you tell it to execute that...   .... ah.   the issue remains. prolly better do as i said at the start of this chrootings, and get the gist of the basics from: http://www.linuxquestions.org/questions/programming-9/chroot-in-shell-scripts-ensuring-that-subsequent-commands-execute-within-the-chroot-830522/ and stop freaking out over it.
  891. sleep 1 ;
  892. }
  893.  
  894. # wichroot
  895. ############
  896. ############
  897.  
  898.  
  899.  
  900.  
  901. ##########
  902. ##########
  903. ##########
  904. ##########
  905. #### rewic
  906. ##########
  907. ##########
  908. ##########
  909. ##########
  910.  
  911. #insert rewic here, once it's sorted out
  912. rewic()  {
  913. # NOTE! this function in the script WAS (now removed) a franken-disection-hackage gutted from tazlitoforwitchcraftextractions, which is just a copy of the earliest tazlito to have write-iso included.  it still needs much re-reading n hackage to get to work, especially across all gentoo-esq (and other) distros.    ... so i just completely removed it for now.  i think it was 1.3... er... or 2.1  or..   sometime around there it got the writeiso feature.
  914. #all tazlito changed to rewic, and all slitaz changed to witch.  ;)  just so you know.
  915.  
  916. ###  let the hacking commence!
  917. #removed... ...devomer#
  918.  
  919. #might wanna consider nabbing some ideas from debian-live-helper and the linux-live scripts famed from the slackers. 
  920. #but tazlito's remasterer is rather the tits, so if we could get it to work instead, it'd be... " the tits "
  921. echo "rewic, the iso remastery stuff has been gutted from this version while we work out the installer stuff ~ no loss it didnt work yet anyway." ;
  922. }
  923.  
  924. ##########
  925. ##########
  926. ##########
  927. ##########
  928. # cauldren
  929. ##########
  930. ##########
  931. ##########
  932. ##########
  933.  
  934. cauldren()  {
  935.  
  936. ### dev note... should really gut out ALL functions, so no functions are defined within a function.  ... it'd make it much cleaner... and probably make it work.
  937. #### once the function gutting is done, remove this guff^
  938.  
  939. ## cauldren is called from the install option of witchcraft2011, and leads to the various installs (installgentoo, installfuntoo, etc)
  940.  
  941. #distroselectormk2 for now.
  942.  
  943. #dev notes n reminders
  944.  
  945. ## partitions n fs
  946. #mountings
  947. #stage3
  948. #chroot
  949. #package managment
  950. #configure  ~~~~~~
  951. #kernel
  952. #bootloader
  953. #users
  954. #startup daemons
  955. #final packages, configs n post-install scripts
  956. #cleanup & remove stage3 tarball & remove package manager tarball
  957.  
  958. #mntchrt and umntchrt
  959. #one builds a chroot of a folder and the other umounts it automagically
  960. # http://pastebin.com/T9Wb0GiB http://pastebin.com/ETPZ23Ja thnx to rstrcogburn.
  961.  
  962. # rstrcog's exherbo global useflags http://pastebin.com/QQbeUpk5
  963. # tho he prolly has new ones now.
  964. clear
  965. sleep 1
  966. echo "ok, so you want to install some hardcore 'nix."
  967. echo
  968. echo "this script presumes you have already prepared your hard drive partitions, and know where you will install to."
  969.  
  970. #cauldren first question
  971. echo "what do you want to do?"
  972. echo "
  973.     A.    simple install  -  less choices, control, flexibility.  just presets.
  974.     B.    proper install  -  pick which metadistro, and which desktop config.
  975.     C.    v leet install  -  do it all yourself"
  976.  
  977. read CauldrenOption
  978.  
  979. case $CauldrenOption in
  980.         A|a)
  981.                 echo "Choice was \"$CauldrenOption\". sorry, this part of the script is still under construction.  running it in a couple seconds anyway"
  982.                 sleep 5
  983.                 simpleinstall
  984.                 ;;
  985.         B|b)
  986.                 echo "Choice was \"$CauldrenOption\". sorry, this part of the script is still under construction.  running it in a couple seconds anyway"
  987.                 sleep 5
  988.                 stage3
  989.                 ;;
  990.         C|c)
  991.                 echo "Choice was \"$CauldrenOption\". this part of the script is complete.  for full manual install, simply press ctrl-C at any time to enter fully manual mode." && echo "exiting to full manual mode now" && exit
  992.                 ;;
  993.           *)
  994.                 echo "Valid Choices are A,B,C"
  995.                 exit 1
  996.                 ;;
  997. esac ;
  998. }
  999.  
  1000. ##########
  1001. ##########
  1002. ##########
  1003. ##########
  1004. ## partman
  1005. ##########
  1006. ##########
  1007. ##########
  1008. ##########
  1009.  
  1010. partmanselector () {
  1011.  
  1012. echo "once you've partitioned your hard drive satasfactorilly, exit the partition manager, and the script will continue."
  1013. echo "which partition manager do you want to use?"
  1014. echo "
  1015.     A.    fdisk
  1016.     B.    gparted
  1017.     C.    enter your own preference of partition manager"
  1018.  
  1019. read PARTITIONER
  1020.  
  1021. case $PARTITIONER in
  1022.         A|a)
  1023.                 echo "Choice was $PARTITIONER. launching..."
  1024.                 sleep 5
  1025.                 fdisk
  1026.                 echo "okies, i'm still working on the bit for creating file systems after using fdisk."
  1027.                 ;;
  1028.         B|b)
  1029.                 echo "Choice was $PARTITIONER. launching..."
  1030.                 sleep 5
  1031.                 gparted
  1032.                 ;;
  1033.         C|c)
  1034.                 echo "Choice was $PARTITIONER. "
  1035.                 echo "enter name of your prefered partition manager" && read -r PARTMANSEL
  1036.                 $PARTMANSEL
  1037.                 ;;
  1038.           *)
  1039.                 echo "Valid Choices are A,B,C, try again."
  1040.                 partmanselector
  1041.                 ;;
  1042. esac
  1043.  
  1044. echo "partitioning complete"; }
  1045.  
  1046.  
  1047. ##########
  1048. ##########
  1049. ##########
  1050. ##########
  1051. ### distro
  1052. ##########
  1053. ##########
  1054. ##########
  1055. ##########
  1056.  
  1057. distroselector() {
  1058. #distroselector first question
  1059. echo "what meta-distro do you want your witch based on?
  1060. 1) Gentoo
  1061. 2) Funtoo
  1062. 3) Exherbo
  1063. 4) Gentoo/BSD
  1064. 5) Gentoo/Hurd
  1065. 6) FreeBSD
  1066. 7) combo
  1067. 8) other
  1068.  
  1069. enter number preference of preference:"
  1070.  
  1071.  
  1072. read BASEDISTRO
  1073. case $BASEDISTRO in
  1074.         1)
  1075.                 echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
  1076.                 echo "this is where you get taken to the gentoo bit"
  1077.                 installgentoo
  1078.                 ;;
  1079.         2)
  1080.                 echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
  1081.                 echo "this is where you get taken to the funtoo bit"
  1082.                 installfuntoo
  1083.                 ;;
  1084.         3)
  1085.                 echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
  1086.                 echo "this is where you get taken to the exherbo bit"
  1087.                 installexherbo
  1088.                 ;;
  1089.         4)
  1090.                 echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
  1091.                 echo "this would be where you get taken to the Gentoo/BSD bit"
  1092.                 cauldren
  1093.                 ;;
  1094.         5)
  1095.                 echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
  1096.                 echo "this would be where you get taken to the Gentoo/Hurd bit"
  1097.                 cauldren
  1098.                 ;;
  1099.         6)
  1100.                 echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
  1101.                 echo "this would be where you get taken to the FreeBSD bit"
  1102.                 cauldren
  1103.                 ;;
  1104.         7)
  1105.                 echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
  1106.                 echo "this would be where you get taken to the bit that lets you custom pick each bit seperately (stage3, kernel, package manager, spintop, etc)... er, i think.   second thoughts, this might already have been an option by the time you're selecting which basedistro... oh well, there's no real harm in having it in here again, right?"
  1107.                 cauldren
  1108.                 ;;
  1109.         8)
  1110.                 echo "Choice was $BASEDISTRO, sorry, this part of the script is incomplete"
  1111.                 echo "idkwtf goes here...  something, surely."
  1112.                 cauldren
  1113.                 ;;
  1114.         *)
  1115.                 echo "Valid Choices are 1,2,3,4,5,6,7,8.  try again" && distroselector
  1116.                 exit 1
  1117.                 ;;
  1118. esac ;
  1119. }
  1120.  
  1121.  
  1122. ##########
  1123. ##########
  1124. ##########
  1125. ##########
  1126. ### gentoo
  1127. ##########
  1128. ##########
  1129. ##########
  1130. ##########
  1131.  
  1132. installgentoo() {
  1133. METADISTRO=GENTOO
  1134. #for further revisions, there's sense in sort-of modularising this with even more functions, so each option can be called from a series of options.  make sense?  good.
  1135.  
  1136. #this doesnt need a comment.  it's self explanitory, surely.
  1137. ARCH="uname -m"
  1138.  
  1139. # will need to get this bit made paludis savvy, giving the user the choice, but for now, just telling it to be portage, will do.
  1140. PACKAGEMANAGERNAME=portage
  1141.  
  1142. ###editor section to be improved
  1143. EDITOR=mcedit
  1144. echo "setting editor to $EDITOR"
  1145. #EDITOR=hash mcedit 2>&- || { echo >&2 "mcedit is not installed.  how about nano..."; nano 1; }
  1146. #echo "what is your prefered text editor?" && read -r EDITOR
  1147.  
  1148. #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:
  1149. #TXTBROWSER=hash links 2>&- || { echo >&2 "links is not installed.  how about lynx..."; lynx 1; }
  1150. #echo "what is your prefered text webbrowser?" && read -r TXTBROWSER
  1151. #   ... i think.  anyways, i'll not implement (uncomment) that just yet.  it'd mean making the appropriate changes bellow too.
  1152.  
  1153. echo "so when you use your browser to find and select your stage, package manager, kernel, etc later on in this script, it will use your proxy, if you need it."
  1154. echo "will you need to use a http-proxy to access the web? (y)(if not sure, probably not):" && read
  1155. [ "$REPLY" == "y" ] && echo "enter your proxy url (e.g.: proxy.server.com:8080)" && read -r PROX
  1156.  
  1157. #call the drive preparation function.
  1158. driveprep
  1159.  
  1160. #call the stage installation function
  1161. stageinstall
  1162.  
  1163. #call the package manager installation function
  1164. installpackagemanager
  1165.  
  1166. #call the function for initial configuration of make.conf
  1167. initialmakeconf
  1168.  
  1169. #call the preparation for chroot
  1170. prechroot
  1171.  
  1172. #call the wichroot
  1173. wichroot
  1174.  
  1175. #...and there we hit the end of the gentoo installation portion of witchcraft
  1176. #job done.  what's next... u want the deskfigselector() now dont you?
  1177. #good, cos it should already be lined up to run, thnx to the stage3 function (as a top level option from cauldren), which calls it straight after running the distroselector function.
  1178. #first you get run the witchcraft, thn you choose the cauldren, then you choose a proper stage3 install, then you get the distro, then you get the desktop.  ^_^ 
  1179. #... is how this path rolls.  ^_^
  1180.  
  1181. }
  1182.  
  1183. ##########
  1184. ##########
  1185. ##########
  1186. ##########
  1187. ### funtoo
  1188. ##########
  1189. ##########
  1190. ##########
  1191. ##########
  1192.  
  1193.  
  1194. installfuntoo() {
  1195. METADISTRO=FUNTOO
  1196. #section removed for re-functionising of the script. 
  1197. #these base distro choices, will set variables which will control the shape of various options (/install sections) suited to that distro (e.g. differences of stuff included in the stage3s)
  1198. #this will be really cool simple additions in some places, like if metadistro = funtoo then diddle-de-dee ~ maybe.  not rly decided on which route to take with sorting out for the multi-distro bases.
  1199. echo "script section incomplete.  open your irc software and join \#witchlinux on irc.freenode.net to get the latest of what's going on, and to join in, in building the script. :)"
  1200.  
  1201. }
  1202.  
  1203. installexherbo() {
  1204. METADISTRO=EXHERBO
  1205. #kitting out the script to handle exherbo installs too will be the coolest part of this.  it will ensure that the structure is more robust to handle multiple install types.
  1206. echo "this bit aint been made yet.  but it's easy enough.. just follow along http://www.exherbo.org/docs/install-guide.html, and enter it into this script the same way as was done for the
  1207. installgentoo and installfuntoo sections.  easy.   ... er... or do it right, n hook it up with all the cool variables, future proofing it."
  1208.  
  1209. }
  1210.  
  1211. installdebian() {
  1212. METADISTRO=DEBIAN
  1213. #hehe.  debootstrapping's close enough to a gentoo style stage three that we aught include it too.  :)  yay.
  1214. echo "this is another hole yet to be filled in the script.  you could consider a manual debootstrap debian install. http://www.debian-administration.org/articles/426 see?"
  1215. #possibly out of date, but a good suggestion of a place to start for adding debian-base to this script.
  1216.  
  1217. }
  1218.  
  1219. ##########
  1220. ##########
  1221. ##########
  1222. ##########
  1223. ## deskfig
  1224. ##########
  1225. ##########
  1226. ##########
  1227. ##########
  1228.  
  1229. deskfigselector() {
  1230.  
  1231. echo "deskfigselector is temporarily out of order while fixing main install"
  1232.  
  1233. #decomment when bringing deskfigselection back into comission.  ~ may also wanna change from stupid "select" style question, to a regular read, like tried n tested above.
  1234.  
  1235. #echo "what do you want your witch based on? (warning options are incomplete)"
  1236. #select SPINTOP in \
  1237. #    'VanillaBase (no gui desktop)' \
  1238. #    'rowan (anti-bloat tiling lightweight) ' \
  1239. #    'willow (like rowan, but more lax on bloat, for comfort)' \
  1240. #    'jamella (tiling wm showcase)' \
  1241. #    'select own desktop&applications set (enter link to script)' \
  1242. #    'semi-manual suggestion list' \
  1243. #    'full manual (like VanillaBase, but able to write a command)' \
  1244. #    'other  (idfk)' \
  1245. #do
  1246. #    case $REPLY in #or is that $REPLY sposa b $SPINTOP, no?  it baulked errors like that.
  1247. #        1 ) echo "ok, doing nothing here then, as is, bare $BASE" ;;
  1248. #        2 ) echo "good choice, a minimal but complete & useable desktop configuration."
  1249. #            echo "INSERT ROWAN SET INSTALLATION HERE emerges and configurations";;
  1250. #        3 ) echo "good choice, a lightweight but complete & useable desktop configuration."
  1251. #            echo "INSERT WILLOW APP INSTALLATION HERE emerges and configurations";;
  1252. #        4 ) echo "good choice, a showcase of all tiling window managers... "
  1253. #            echo "INSERT TILING WM INSTALLATION HERE emerges and configurations"
  1254. #            echo "INSERT TILING WM (non-repo)SOURCE INSTALLATIONS OPTION HERE and configurations"
  1255. #            echo "INSERT OPTION TO INSTALL ROWAN OR WILLOW OTHER APPS TOO emerges and configurations";;
  1256. #        5 ) echo "INSERT INSTRUCTIONS AND \"read\" USER INPUT PROMPT FOR LOCATION OF OWN INSTALL SCRIPT" ;;
  1257. #        6 ) echo "INSERT APP GROUP BY APP GROUP APPLICATION MULTIPLE CHOICE" ;;
  1258. #        7 ) echo "INSERT ABILITY TO ENTER ONE COMMAND (OR STRING OF COMMANDS) TO INSTALL DESIRED APPLICATIONS" ;;
  1259. #        8 ) echo "and idk what would go here, this is still just a dummy mock up while laying it all out." ;;
  1260. #        * ) print 'invalid.' ;;
  1261. #    esac ;
  1262. #    if [[ -n $SPINTOP ]]; then
  1263. #        echo "you have selected \"$SPINTOP\""
  1264. #        break
  1265. #    fi
  1266. #done
  1267.  
  1268. echo "sorry no deskfig selection yet"
  1269. }
  1270.  
  1271. # FIXME ^
  1272.  
  1273. ##########
  1274. ##########
  1275. ##########
  1276. ##########
  1277. ### script
  1278. ##########
  1279. ##########
  1280. ##########
  1281. ##########
  1282.  
  1283. #first question
  1284. echo "what do you want to do?"
  1285. echo "
  1286.     A.    write iso of current operating system (rewic)
  1287.     B.    install a new operating system (cauldren)
  1288.     C.    do it all yourself"
  1289.  
  1290. read WITCHCRAFTMODE
  1291.  
  1292. case $WITCHCRAFTMODE in
  1293.         A|a)
  1294.                 echo "Choice was $WITCHCRAFTMODE. sorry, this part of the script is still under construction.  running it in a couple seconds anyway"
  1295.                 sleep 5
  1296.                 rewic
  1297.                 ;;
  1298.         B|b)
  1299.                 echo "Choice was $WITCHCRAFTMODE. sorry, this part of the script is still under construction.  running it in a couple seconds anyway"
  1300.                 sleep 5
  1301.                 cauldren
  1302.                 ;;
  1303.         C|c)
  1304.                 echo "Choice was $WITCHCRAFTMODE. this part of the script is complete.  for full manual install, simply press ctrl-C at any time to enter fully manual mode."
  1305.                 echo "exiting to full manual mode now"
  1306.                 exit
  1307.                 ;;
  1308.           *)
  1309.                 echo "Valid Choices are A,B,C"
  1310.                 exit 1
  1311.                 ;;
  1312. esac
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332. # cool, now this script is leet.

Paste Details

Tags: witch

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right