wichroot_script.sh 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  1. #! /bin/bash
  2. ##########################################
  3. ##########################################
  4. ################### wichroot #
  5. ##########################################
  6. ##########################################
  7. ### variables assignment - will be rewritten into a new script and that script will be sent.
  8. DISTRONAME=placeholder
  9. PACKAGEMGR=placeholder
  10. METADISTRO=placeholder
  11. ROOTDEV=placeholder
  12. ### functions here to make life easier
  13. install_pkg() { # put the packages to be installed as a string.
  14. # so... what happens if the string is different? like in debian you install this but in gentoo you install that
  15. # as a rule of thumb choose the most generic one, then add a if statement to check for the name and install what it's supposed to be
  16. case "$PACKAGEMGR" in
  17. "portage")
  18. echo "Installing package $1 ..."
  19. emerge $1
  20. ;;
  21. "dpkg")
  22. echo "Installing package $1 ..."
  23. aptitude install $1
  24. ;;
  25. esac
  26. }
  27. update_pkg() {
  28. case "$PACKAGEMGR" in
  29. "portage")
  30. echo "updating with \"emerge --sync\" not so quietly though. may take several minutes..."
  31. emerge --sync
  32. echo "portage is now up to date."
  33. sleep 1
  34. # 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.
  35. ;;
  36. "dpkg") # little example
  37. echo "updating with \"aptitude update\" not so quietly though. may take several minutes..."
  38. aptitude update
  39. echo "your system is now up to date"
  40. sleep 1
  41. ;;
  42. esac
  43. }
  44. echo "creating a new environment by essentially creating environment variables, then loading those variables into memory using source."
  45. case "$METADISTRO" in
  46. "GENTOO")
  47. echo "env-update"
  48. env-update
  49. ;;
  50. esac
  51. echo "source /etc/profile"
  52. source /etc/profile
  53. echo "export PS1='\($DISTRONAME chroot\) \$PS1'"
  54. export PS1="\($DISTRONAME chroot\) $PS1"
  55. sleep 1
  56. sleep 2 && clear
  57. echo "making sure the $PACKAGEMGR tree of $DISTRONAME is up to date..."
  58. echo
  59. update_pkg
  60. sleep 2 && clear
  61. #################################################################################
  62. #this is the best work-around i've come up with yet to deal with passing the required variables to the chrooted environment. it's not ideal, i know, and i'm certain there's a more elegant solution out there, but for now, this will have to do.
  63. echo "since you're now well and truly in your newly chrooted environment, you need to set some variables again. ~ this is an unfortunate kludge solution. hack up, or put up. ~"
  64. echo
  65. echo "what is your prefered text editor? (type the name of it\'s executable as exists on host system):"
  66. read CHEDITOR
  67. export EDITOR="$CHEDITOR"
  68. #mibi move it to before the portage sync'ing?
  69. #################################################################################
  70. sleep 2 && clear
  71. gentoo_config() { ## GENTOO SPECIFIC
  72. #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)
  73. echo "First, a small definition is in place."
  74. sleep 1
  75. echo "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.
  76. 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.
  77. You can see what profile you are currently using (the one with an asterisk next to it)"
  78. echo "with eselect profile list:"
  79. sleep 1
  80. echo
  81. eselect profile list
  82. sleep 3
  83. echo
  84. echo "pick a number of profile you would like to switch to, if any, careful not to select a number that doesnt exist. (type letter and hit enter)"
  85. echo "Choose a number from 1 to 15. The default is marked with an asterick."
  86. read PROFILESELECT
  87. echo "Choice was $PROFILESELECT. doing: eselect profile set $PROFILESELECT"
  88. sleep 1
  89. eselect profile set $PROFILESELECT
  90. echo "you can always try changing this later, using eselect."
  91. }
  92. case "$METADISTRO" in
  93. "GENTOO")
  94. gentoo_config
  95. ;;
  96. esac
  97. sleep 2 && clear
  98. ######start of chroot, i added a cheditor and chbrowser bit. so this is redundant now... i hope, since i commented it out.
  99. ###editor section to be improved
  100. #echo "incase your chrooted environment doesnt like your editor choice from your host os you can get a new one here."
  101. #emerge -uqv nano
  102. #CHEDITOR=nano #FIX ME augment that shit soon
  103. #EDITOR=nano
  104. #echo "setting editor to $EDITOR " && sleep 1
  105. #######
  106. #useflags section.
  107. #######
  108. #may decide to break this bit up and put in a seperate function() at some point perhaps.
  109. useflags() {
  110. 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 have not, not to worry, we can do that now, or even change them later."
  111. echo
  112. echo "what would you like to do for your useflags in make.conf?"
  113. echo "
  114. m - manually edit
  115. d - dont care, do it for me, default it. (warning, incomplete! overwrites!)
  116. w - wget from _____ (warning this will overwrite existing make.conf)
  117. c - copy from _____ (warning this will overwrite existing make.conf)
  118. v - vanilla - dont touch it! leave as is now.
  119. u - use the fully commented one from /mnt/$DISTRONAME/usr/share/portage/config/make.conf (warning, this will overwrite existing make.conf)
  120. enter letter of preference: "
  121. read REPLY
  122. case "$REPLY" in
  123. m)
  124. $EDITOR /etc/make.conf
  125. ;;
  126. d)
  127. echo "looks like the make.conf default hasnt been made yet. you will 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."
  128. ;;
  129. w)
  130. echo "enter the url where your make.conf is located (e.g. http://pasterbin.com/dl.php?i=z5132942i ):"
  131. read MAKECONFURL
  132. wget $MAKECONFURL -o /etc/make.conf
  133. ;;
  134. c)
  135. echo "enter the location where your make.conf is located (e.g. /usr/share/portage/config/make.conf):"
  136. read MAKECONFLOC
  137. cp $MAKECONFLOC /etc/make.conf
  138. ;;
  139. v)
  140. echo "well that is easily done. ... done."
  141. ;;
  142. u)
  143. cp /usr/share/portage/config/make.conf /etc/make.conf
  144. ;;
  145. esac
  146. #FIXME ^ default
  147. }
  148. useflags
  149. sleep 2 && clear
  150. locale_select() {
  151. #functionise these following bits too? i presume they are all fairly universal, n not much (if any) variation between base distros.
  152. 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
  153. e.g.
  154. en_GB ISO-8859-1
  155. en_GB.UTF-8 UTF-8
  156. en_US ISO-8859-1
  157. en_US.UTF-8 UTF-8
  158. m - manually edit
  159. d - dont care, do it for me, default it. (warning, incomplete! overwrites!)
  160. w - wget from _____ (warning this will overwrite existing locale.gen)
  161. c - copy from _____ (warning this will overwrite existing locale.gen)
  162. v - vanilla - dont touch it! leave as is now."
  163. read REPLY
  164. case "$REPLY" in
  165. m)
  166. $EDITOR /etc/locale.gen
  167. ;;
  168. d)
  169. echo "looks like the locale.gen default hasnt been made yet. you will 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
  170. ;;
  171. w)
  172. echo "enter the url where your make.conf is located:"
  173. read MAKECONFURL
  174. wget $MAKECONFURL -o /etc/locale.gen
  175. ;;
  176. c)
  177. echo "enter the location where your make.conf is located (e.g. /usr/share/portage/config/make.conf):"
  178. read MAKECONFLOC
  179. cp $MAKECONFLOC /etc/locale.gen
  180. ;;
  181. v)
  182. echo "well that is easily done. ... done. locale.gen as is."
  183. ;;
  184. esac
  185. #consider changing to "locale-gen -a" ~ see man page, and try it out. or add that as an option above.
  186. echo "now running locale-gen" && locale-gen
  187. sleep 1
  188. }
  189. locale_select
  190. sleep 2 && clear
  191. kernel() {
  192. #presumably put the kernel section in a variablised functionised chunk too? could do with some clean up of what is pre-kernel-getting and what is actually kernel-getting
  193. echo "now you will likely need a kernel too"
  194. sleep 1
  195. echo "lets get your timezone sorted for that..."
  196. echo "Look for your timezone in /usr/share/zoneinfo, then we will copy it to /etc/localtime"
  197. sleep 2
  198. echo
  199. ls /usr/share/zoneinfo
  200. echo
  201. read -p "enter timezone (e.g. America, GMT): " TIMEZONE
  202. cp /usr/share/zoneinfo/$TIMEZONE /etc/localtime
  203. echo "okay."
  204. sleep 2 && echo
  205. 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 "
  206. sleep 3
  207. #see previous comment. kernel-getting.
  208. #exherbo has taught us well here... let the user choose what kernel they want.
  209. #grand expanding of this section, offering:
  210. #genkernel, debian kernels, hurd, freebsd, vanila kernel.org kernels, hurd+mach, hurd+l4, xenkernel, etc etc etc.
  211. # ....there-in we will see why digitteknohippie insist's it's called witch, before it's called witchlinux... the linux kernel need not even be present. :)
  212. echo "so lets get on with getting you a kernel..."
  213. sleep 1
  214. # figure out a nice way to do this
  215. echo "how would you like to get a kernel?"
  216. case "$METADISTRO" in
  217. "GENTOO") echo "i - gentoo-sources and genkernel " ;;
  218. "DEBIAN") echo "i - debian repositories " ;;
  219. esac
  220. echo "m - manual (incomplete)"
  221. echo
  222. read -p "select which option: "
  223. case "$REPLY" in
  224. i) ## here you go. start making it seperate.
  225. case "$METADISTRO" in
  226. "GENTOO")
  227. install_pkg "genkernel gentoo-sources"
  228. genkernel --menuconfig all
  229. # symlinking starts
  230. ln -s /boot/kernel* /boot/vmlinuz
  231. ln -s /boot/initramfs* /boot/initramfs.img
  232. ;;
  233. "DEBIAN") ## ask for kernel version since debian has different kernels
  234. ## added as a proof of concept. fill it in later
  235. ;;
  236. esac
  237. ;;
  238. m)
  239. echo "woah there cowboy, how complete do you think this script is already!? didnt we tell you this bit was incomplete. ...you will 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"
  240. ;;
  241. esac
  242. sleep 2
  243. 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 "
  244. #echo "you might want kernel modules too right?"
  245. # FIXME
  246. #
  247. #echo "To view all available modules"
  248. #
  249. #ls /boot/linux*
  250. #find /lib/modules/$KERNV/ -type f -iname '*.o' -or -iname '*.ko' | less
  251. ### need to get the just compiled kernel name and version extracted cleanly, to be inserted there on $KERNV
  252. # FIXME
  253. #ls -l /usr/src/linux
  254. }
  255. kernel
  256. sleep 2 && clear
  257. #put fstab section in it's own function
  258. fstab() {
  259. echo "
  260. _______What is fstab?
  261. 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.)
  262. _______Creating /etc/fstab
  263. /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:
  264. The first field shows the partition described (the path to the device file). you can specify a UUID here too.
  265. The second field shows the mount point at which the partition should be mounted
  266. The third field shows the filesystem used by the partition
  267. 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.
  268. 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).
  269. The sixth field is used by fsck to determine the order in which filesystems should be checked if the system wasn not shut down properly. The root filesystem should have 1 while the rest should have 2 (or 0 if a filesystem check is not necessary).
  270. ---------------
  271. so as you should already know, you configured your partitions some time ago. still remember them?
  272. if not, open up another terminal and type in 'chroot /mnt/$DISTRONAME'.
  273. Once you enter a new chroot environment type in 'sudo fdisk -l'
  274. if yes, great!
  275. "
  276. echo "so lets get on with setting up your fstab"
  277. sleep 1
  278. echo "how would you like to configure your fstab?
  279. m - manual (opens in editor)
  280. s - skip (manual later)
  281. g - guided (warning incomplete)
  282. select which option: "
  283. read
  284. case "$REPLY" in
  285. m)
  286. echo "manual editing /etc/fstab selected"
  287. $EDITOR /etc/fstab
  288. ;;
  289. s)
  290. echo "skipping..."
  291. ;;
  292. g)
  293. 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."
  294. ;;
  295. esac
  296. # FIXME ^ inset the fstab populator bit. && add the variable-ised root, home n boot partitions...
  297. }
  298. fstab
  299. sleep 2 && clear
  300. network() {
  301. ####NETWORK#### mk1
  302. # FIXME the whole network section could do with an overhaul and simplification and cleaning up.
  303. ###old first attempt at making the network section
  304. ###echo "whadya call this computer (what is your hostname)?
  305. ###- this will be set in /etc/conf.d/net"
  306. ###read NETNOM
  307. ###echo "dns_domain_lo=\"$NETNOM\"" >> /etc/conf.d/net
  308. ###
  309. ###echo "wanna use DHCP for connection? (if you dont know what that means, it is still likely you do)"
  310. ###echo "config_eth0=\"dhcp\"" >> /etc/conf.d/net
  311. # 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
  312. # 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.
  313. # FIXME ^ net'll likely need mending, since the host and net files
  314. ###############
  315. #___#######___#
  316. ####NETWORK####
  317. #___#######___#
  318. ###############
  319. ############### mk2 (put network mk2 in own function. network mk1 can probably be deleted now, right?
  320. sleep 2 && clear
  321. echo "you will wanna be online too right?"
  322. #this is probably excessive for just hostname, right? and domain name bellow too...
  323. echo "what do you want to do about your hostname (in /etc/conf.d/hostname)
  324. m - manually edit
  325. d - dont care, do it for me, default it. (overwrites!)
  326. w - wget from _____ (warning this will overwrite existing /etc/conf.d/hostname)
  327. c - copy from _____ (warning this will overwrite existing /etc/conf.d/hostname)
  328. v - vanilla - dont touch it. leave as is now.
  329. e - enter hostname now. (warning this will overwrite existing /etc/conf.d/hostname)"
  330. read
  331. case "$REPLY" in
  332. m)
  333. echo "ok, to $EDITOR /etc/conf.d/hostname"
  334. $EDITOR /etc/conf.d/hostname
  335. ;;
  336. d)
  337. echo "witchgnubox" > /etc/conf.d/hostname
  338. ;;
  339. w)
  340. echo "enter the url where your hostname filef is located (e.g. http://pasterbin.com/dl.php?i=z5132942i ):"
  341. read HOSTNOMURL
  342. wget $HOSTNOMURL -o /etc/conf.d/hostname
  343. ;;
  344. c)
  345. echo "enter the location where your hostname file is located (e.g. /mnt/myexternal/myconfigbkpoverlay/etc/conf.d/hostname):"
  346. read HOSTNOMLOC
  347. cp $HOSTNOMLOC /etc/conf.d/hostname
  348. ;;
  349. v)
  350. echo "well that is easily done. ... done."
  351. ;;
  352. e)
  353. read -p "whadya call this computer (what is your hostname)?
  354. - this will be set in /etc/conf.d/hostname
  355. ENTER HOSTNAME:" HOSTNOM
  356. echo "hostname=$HOSTNOM " > /etc/conf.d/hostname
  357. ;;
  358. esac
  359. sleep 2 && echo
  360. # 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 wikl need a clever extraction of $HOSTNOM from /etc/conf.d/hostname. not important rly... so i am just commenting on this rather than getting it done, so it doesnt interupt my flow.
  361. echo "ok, so that should be your /etc/conf.d/hostname configured as it has your hostname."
  362. sleep 2 && echo
  363. # 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.
  364. echo "what do you want to do about your domain name (in /etc/conf.d/net)
  365. m - RECOMMENDED: manually edit
  366. d - dont care, do it for me, default it. (adds ns_domain_lo=\"witchnet\")
  367. w - wget from _____ (warning this will overwrite existing /etc/conf.d/net)
  368. c - copy from _____ (warning this will overwrite existing /etc/conf.d/net)
  369. v - RECOMMENDED: vanilla - dont touch it! leave as is now.
  370. e - enter network name now. (warning this will overwrite existing /etc/conf.d/net)"
  371. read REPLY
  372. case "$REPLY" in
  373. m)
  374. $EDITOR /etc/conf.d/net
  375. ;;
  376. d)
  377. echo "ns_domain_lo=\"witchnet\"" >> /etc/conf.d/net
  378. ;;
  379. w)
  380. echo "enter the url where your hostname file is located (e.g. http://pasterbin.com/dl.php?i=z5132942i ):"
  381. read -r HOSTNOMURL
  382. wget $HOSTNOMURL -o /etc/conf.d/net
  383. ;;
  384. c)
  385. echo "enter the location where your hostname file is located (e.g. /mnt/myexternal/myconfigbkpoverlay/etc/conf.d/net):"
  386. read HOSTNOMLOC
  387. cp $HOSTNOMLOC /etc/conf.d/net
  388. ;;
  389. v)
  390. echo "well that is easily done. ... done."
  391. ;;
  392. e)
  393. echo "whadya call this network (what is your net)?
  394. - this will be set in /etc/conf.d/net"
  395. read -p "ENTER DOMAIN NAME:" DOMNOM
  396. echo "ns_domain_lo=\"$DOMNOM\"" > /etc/conf.d/net
  397. ;;
  398. esac
  399. sleep 2 && echo
  400. echo "u wanna use dhcp right? y/n: "
  401. read REPLY
  402. if [ "$REPLY" == "y" ]
  403. then
  404. echo "config_eth0=\"dhcp\"" >> /etc/conf.d/net
  405. fi
  406. echo "and u want to have networking activated at boot automatically for you, of course, right? y/n: "
  407. read REPLY
  408. if [ "$REPLY" == "y" ]
  409. then
  410. echo
  411. echo "ok.. "
  412. sleep 2
  413. echo "cd /etc/init.d"
  414. cd /etc/init.d
  415. echo "ln -s net.lo net.eth0"
  416. ln -s net.lo net.eth0
  417. echo "this next bit is clever. you should learn about rc-update. a nice feature of gentoo."
  418. sleep 2
  419. echo "rc-update add net.eth0 default"
  420. rc-update add net.eth0 default
  421. fi
  422. sleep 2 && echo
  423. 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."
  424. echo
  425. echo "now we inform linux about your network. in /etc/hosts"
  426. # FIXME obviously this needs work prior, as already commented on, to make sure these variables are set more cleanly and cleverly.
  427. echo "127.0.0.1 localhost" > /etc/hosts
  428. # 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.
  429. echo "need to manually edit it? [y/n]"
  430. read
  431. if [ "$REPLY" == "y" ]
  432. then
  433. $EDITOR /etc/hosts
  434. fi
  435. #PCMCIA section.
  436. echo "do you need PCMCIA? y/n: "
  437. read
  438. if [ "$REPLY" == "y" ]
  439. then
  440. install_pkg pcmciautils
  441. fi
  442. }
  443. network
  444. sleep 2 && clear
  445. ##############
  446. #___######___#
  447. ####SYSTEM####
  448. #___######___#
  449. ##############
  450. # http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=1&chap=8#doc_chap2
  451. echo "First we set the root password with \"passwd\""
  452. passwd
  453. echo "that should be your root password configured. dont forget it, remember it."
  454. sleep 2 && echo
  455. echo "Gentoo uses /etc/rc.conf for general, system-wide configuration. Here comes /etc/rc.conf, enjoy all the comments in that file :) ... iz u ready for this? (y):"
  456. read REPLY
  457. if [ "$REPLY" == "y" ]
  458. then
  459. $EDITOR /etc/rc.conf
  460. fi
  461. sleep 2 && clear
  462. echo "hopefully you have got all you need, sorted in rc.conf. if you changed your editor in rc.conf, this next bit should use it instead now."
  463. sleep 1
  464. echo "Gentoo uses /etc/conf.d/keymaps to handle keyboard configuration. Edit it to configure your keyboard."
  465. sleep 2
  466. echo "Take special care with the keymap variable. If you select the wrong keymap, you will get weird results when typing on your keyboard."
  467. sleep 1
  468. echo "-> do you need to change your keymap? [y/n]"
  469. read
  470. if [ "$REPLY" == "y" ]
  471. then
  472. $EDITOR /etc/conf.d/keymaps
  473. fi
  474. sleep 2 && clear
  475. echo "Gentoo uses /etc/conf.d/hwclock to set clock options. Edit it according to your needs. wanna change time? [y/n]"
  476. read
  477. if [ "$REPLY" == "y" ]
  478. then
  479. $EDITOR /etc/conf.d/hwclock
  480. fi
  481. # FIXME^ that was just barely a step past sheer lazy.
  482. sleep 2 && clear
  483. echo "so according to what you have got now, the date is:" && date
  484. sleep 3
  485. echo "ok, so you should probably have your network, main config file (rc.conf), keyboard and clock configured.
  486. now lets get tooled up with a system logger, command scheduler, and more file and network tools."
  487. sleep 1
  488. sleep 2 && clear
  489. echo ""
  490. echo "Installing Necessary System Tools"
  491. sleep 1
  492. #may want/need to variablise this, n have some checks of variables to know how to proceed for each base distros different stage3s
  493. 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.
  494. 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.
  495. Gentoo offers several system loggers to choose from. There are:
  496. - sysklogd, which is the traditional set of system logging daemons,
  497. - syslog-ng, an advanced system logger,
  498. 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.
  499. If you plan on using \"sysklogd\" or \"syslog-ng\" you might want to install \"logrotate\" afterwards as those system loggers do not provide any rotation mechanism for the log files.
  500. To install the system logger of your choice, emerge it and have it added to the default runlevel using rc-update.
  501. choose a systemlogger to install and add to startup: "
  502. sleep 1
  503. echo "
  504. a. emerge syslogd && rc-update add syslogd default
  505. b. emerge syslog-ng && rc-update add syslog-ng default
  506. c. emerge metalog && rc-update add metalog default
  507. d. enter name of other system logger
  508. e. no thnx (only if you are sure)
  509. select a,b,c or d and press ENTER.
  510. "
  511. read REPLY
  512. case $REPLY in
  513. a)
  514. install_pkg syslogd
  515. rc-update add syslogd default
  516. ;;
  517. b)
  518. install_pkg syslog-ng
  519. rc-update add syslog-ng default
  520. ;;
  521. c)
  522. install_pkg metalog
  523. rc-update add metalog default
  524. ;;
  525. d)
  526. read -p "enter name of your choice of system logger: " SYSLOGA
  527. install_pkg $SYSLOGA
  528. 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 will carry on with this rudimentary version for now.
  529. ;;
  530. esac
  531. sleep 2 && clear
  532. #put crons into function(s) too
  533. echo "now on to command schedulers, a.k.a. cron daemons."
  534. 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).
  535. Gentoo offers three possible cron daemons:
  536. - vixie-cron
  537. - dcron
  538. - fcron
  539. If you do not know what to choose, use vixie-cron."
  540. echo "which cron daemon do you want?
  541. a. emerge vixie-cron && rc-update add vixie-cron default
  542. b. emerge dcron && rc-update add dcron default && crontab /etc/crontab
  543. c. emerge fcron && rc-update add fcron default && crontab /etc/crontab
  544. d. enter name of other cron
  545. e. no cron (r u sure?)"
  546. read
  547. case "$REPLY" in
  548. a)
  549. install_pkg vixie-cron
  550. rc-update add vixie-cron default
  551. ;;
  552. b)
  553. install_pkg dcron
  554. rc-update add dcron default
  555. crontab /etc/crontab
  556. ;;
  557. c)
  558. install_pkg fcron
  559. rc-update add fcron default
  560. crontab /etc/crontab
  561. ;;
  562. d)
  563. read -p "enter name of your choice of cron: " CRONNER
  564. install_pkg $CRONNER
  565. rc-update add $CRONNER default
  566. 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 will carry on with this rudimentary version for now.
  567. ;;
  568. esac
  569. sleep 2 && clear
  570. #functionise
  571. echo "If you want to index your files so you are able to quickly locate them using the locate tool, you need to install sys-apps/mlocate.
  572. do you want locate? [y/n]"
  573. read
  574. if [ "$REPLY" == "y" ]
  575. then
  576. install_pkg mlocate
  577. fi
  578. sleep 2 && clear
  579. #functionise
  580. #re-write to add automation and other options?
  581. echo "will you need dhcp or ppp?
  582. d. dhcp
  583. p. ppp
  584. b. both
  585. q. neither
  586. "
  587. read
  588. case "$REPLY" in
  589. d) install_pkg dhcp ;;
  590. p) install_pkg ppp ;;
  591. b) install_pkg "dhcp ppp" ;;
  592. esac
  593. sleep 2 && clear
  594. #oh rly, not even gonna give them a choice? there is far more than just one. :P ;) FIX ME... and functionise. bootloader section could pretty much do with a whole rewrite.
  595. #give them syslinux too. it's a nice bootloader. maybe lilo.
  596. 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."
  597. sleep 2
  598. echo "so, do you want your bootloader to be on a current existing system? if not, we'll put the bootloader into your witch. [y/n]"
  599. read REPLY
  600. if [ $REPLY == "y" ]
  601. then
  602. echo "okay."
  603. sleep 1
  604. echo "this section is still incomplete, sorry. hack it up :D"
  605. # chroot into the main drive (hackish method). then configure the current bootloader there.
  606. # for syslinux you need to install to the witch too.
  607. # and to make sure i don't forget
  608. # copy chain.c32 over to /boot/extlinux/
  609. # then type this out:
  610. # label witchname - metadistro
  611. # kernel /boot/extlinux/chain.c32
  612. # append hd0 1
  613. # hd0 -> xth drive. like sda would be hd0, sdb would be hd1 and etc.
  614. # 1 -> partition 1. like /sda1 and /sdb1
  615. # that should clear things up.
  616. echo "i guess you should check out the file 'wichroot.sh' in 'procedure.d' and look at line 759 to 777 :D and figure out things on your own"
  617. else
  618. echo "note, this section is just minimally done, very basic. you will no doubt want to manually configure your boot loader properly. here, we are 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\"."
  619. echo "read more at http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10"
  620. echo "so which bootloader do you want?"
  621. echo "g - grub (grub grub grub)"
  622. echo "s - good old syslinux"
  623. read BOOTLOADER
  624. case $BOOTLOADER in
  625. g)
  626. echo "so you want grub."
  627. echo "installing grub in a moment. we'll install ncurses first."
  628. sleep 2
  629. install_pkg grub
  630. echo "a backup is created at /boot/grub/grub.conf.bk~"
  631. cp /boot/grub/grub.conf /boot/grub/grub.conf.bk~
  632. # note to self, find out a way to add incremental numberings to such copyings, so backups can be non-destructive. you know like, ~if file exists then~
  633. echo "copied backup of any existing grub.conf to /boot/grub/grub.conf~origbkp"
  634. sleep 2
  635. echo "
  636. default 0
  637. timeout 30
  638. splashimage=(hd0,0)/boot/grub/splash.xpm.gz
  639. title=$DISTRONAME - $METADISTRO
  640. root (hd0,0)
  641. kernel /boot/kernel-2.6.12-gentoo-r10 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/$ROOTDEV udev
  642. initrd /boot/initramfs-genkernel-amd64-2.6.12-gentoo-r10
  643. # Only in case you want to dual-boot
  644. title=Windows XP
  645. rootnoverify (hd0,5)
  646. makeactive
  647. chainloader +1" > /boot/grub/grub.conf
  648. ;;
  649. esac
  650. fi
  651. # tee that^ so the folks can see what you mean by:
  652. sleep 1
  653. echo "as an interim kluge until you hack up something better, some crap has been thrown in your bootloader section. so you will want to find out what your kernel and initrd are called and what bootloader kernel options you want passed to it, and edit those in apropriately."
  654. sleep 2
  655. # ^ 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.
  656. # 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
  657. # yes basically i've done a cop-out for this section. i am become lazyness. lol.
  658. # FIX ME ... FIX ME ... FIX MEEEEE. that boot section needs a serious re-work... lazy ass .... wtf.
  659. echo "job done. your base system is installed. now lets make it a witch. :)"
  660. #one very important final thought:
  661. exit
  662. # ;D see, that was rather important, right? ^_^
  663. ##########################################
  664. ##########################################
  665. ################### wichroot #
  666. ##########################################
  667. ##########################################
  668. #### the wichroot fits into
  669. #### the here-CHEOF like i
  670. #### mentioned whenst echo
  671. #### "ENTER THE CHROOT" as
  672. #### this^^^ is just to be
  673. #### able to use some more
  674. #### syntax highlighting!!
  675. ##########################################
  676. ########################################## 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.
  677. ########################################## .... uhhh check the CHEOF (the chroot EOF "here" command)... isnt it missing something?