Gentoo installation script
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. #!/usr/bin/env sh
  2. Bootstrap() {
  3. # Confirm the user has setup their disks
  4. echo "Please partition and mount your disks before continuing!"
  5. read -ep "Proceed with installation? [Y/N]: " Proceed && \
  6. if echo $Proceed | grep -iq "^n" ; then exit; fi
  7. # Set time via ntpd
  8. ntpd -q -g
  9. # Download and extract stage3 tarball
  10. cd /mnt/gentoo
  11. S3_ARCH="amd64" && S3_DATE="20170727"
  12. wget http://distfiles.gentoo.org/releases/${S3_ARCH}/autobuilds/${S3_DATE}/stage3-${S3_ARCH}-nomultilib-${S3_DATE}.tar.bz2 && \
  13. tar xvjpf stage3-*.tar.bz2 --xattrs --numeric-owner
  14. # Mount hardware devices
  15. mount -t proc /proc /mnt/gentoo/proc && \
  16. mount --rbind /sys /mnt/gentoo/sys && \
  17. mount --make-rslave /mnt/gentoo/sys && \
  18. mount --rbind /dev /mnt/gentoo/dev && \
  19. mount --make-rslave /mnt/gentoo/dev
  20. # Setup '/swapfile'
  21. SwapFile="/mnt/gentoo/swapfile"
  22. if [ ! -e $SwapFile ]; then
  23. fallocate -l 2G $SwapFile && \
  24. mkswap $SwapFile && \
  25. chmod 0600 $SwapFile && \
  26. swapon $SwapFile
  27. fi
  28. # Configure Portage
  29. wget -O /mnt/gentoo/etc/portage/make.conf \
  30. https://raw.githubusercontent.com/jcmdln/gein/master/etc/portage/make.conf
  31. rm -rf /mnt/gentoo/etc/portage/package.use && \
  32. wget -O /mnt/gentoo/etc/portage/package.use \
  33. https://raw.githubusercontent.com/jcmdln/gein/master/etc/portage/package.use
  34. #wget -0 /mnt/gentoo/etc/portage/package.env \
  35. # https://raw.githubusercontent.com/jcmdln/gein/master/etc/portage/package.env
  36. # Setup Portage mirrors
  37. mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf && \
  38. mkdir -vp /mnt/gentoo/etc/portage/repos.conf && \
  39. cp -v /mnt/gentoo/usr/share/portage/config/repos.conf \
  40. /mnt/gentoo/etc/portage/repos.conf/gentoo.conf && \
  41. cp -vL /etc/resolv.conf /mnt/gentoo/etc/
  42. # Chroot into '/mnt/gentoo'
  43. cd /mnt/gentoo && chroot /mnt/gentoo /bin/bash
  44. }
  45. Minimal() {
  46. # Automate counting available cores and other hardware tasks
  47. export CPU_CORES=$(grep -c ^processor /proc/cpuinfo)
  48. echo "CPU_CORES=$(grep -c ^processor /proc/cpuinfo)" >> /etc/profile
  49. # Reload profile and update PS1
  50. source /etc/profile && export PS1="(chroot) $PS1"
  51. # Sync Portage and select profile
  52. emerge-webrsync && eselect profile list && \
  53. read -ep "Which profile?: " Target_Profile && \
  54. eselect profile set $Target_Profile && \
  55. emerge -av --update --deep --newuse @world
  56. # Set desired timezone
  57. ls /usr/share/zoneinfo && \
  58. read -ep "Target region: " Target_Region && \
  59. ls /usr/share/zoneinfo/${Target_Region} && \
  60. read -ep "Target city: " Target_City && \
  61. TimeZone=${Target_Region}"/"${Target_City} && \
  62. echo "${TimeZone}" > /etc/timezone && \
  63. emerge --config sys-libs/timezone-data
  64. # Set desired locales
  65. nano /etc/locale.gen && \
  66. locale-gen && locale -a && eselect locale list && \
  67. read -ep "Target locale: " Target_Locale && \
  68. eselect locale set ${Target_Locale}
  69. # Update environment
  70. env-update && source /etc/profile && export PS1="(chroot) $PS1"
  71. # Emerge and install Linux kernel
  72. emerge -av \
  73. sys-kernel/gentoo-sources \
  74. sys-kernel/linux-firmware \
  75. sys-apps/pciutils \
  76. sys-kernel/genkernel &&
  77. cd /usr/src/linux && \
  78. make -j${CPU_CORES} defconfig && \
  79. make -j${CPU_CORES} menuconfig && \
  80. make -j${CPU_CORES} && \
  81. make -j${CPU_CORES} modules_install && \
  82. make -j${CPU_CORES} install && \
  83. genkernel --install initramfs
  84. # Configure '/etc/fstab/'
  85. echo "/swapfile none swap sw 0 0" >> /etc/fstab && \
  86. nano /etc/fstab
  87. # Install neworking packages &
  88. emerge -av --noreplace net-misc/netifrc && \
  89. emerge -av net-misc/dhcpcd
  90. # Set desired hostname and update '/etc/hosts'
  91. read -ep "Hostname: " Target_Hostname && \
  92. echo hostname="$Target_Hostname" > /etc/conf.d/hostname
  93. # Configure and install Grub
  94. emerge -av sys-boot/grub:2 && \
  95. read -ep "Where to install Grub: " Grub_Target && \
  96. grub-install $Grub_Target && \
  97. grub-mkconfig -o /boot/grub/grub.cfg
  98. # Install 'sudo' and if CPU is Intel, install microcode
  99. emerge -av sudo
  100. if grep -Rqi 'intel' /proc/cpuinfo; then
  101. emerge -av intel-microcode
  102. fi
  103. # Set root password and optionally setup user
  104. passwd
  105. read -ep "Setup a standard user? [Y/N]: " Proceed
  106. if echo $Proceed | grep -iq "^y"; then
  107. read -ep "Username: " Target_User && \
  108. useradd -m -G wheel $Target_User && \
  109. passwd $Target_User
  110. wget -qO- https://github.com/jcmdln/tilde/archive/master.zip | \
  111. tar xvz -C /home/$Target_user
  112. fi
  113. }
  114. Desktop() {
  115. MAKEOPTS="-j1" emerge -av dev-util/cmake && \
  116. emerge -av x11-base/xorg-drivers && \
  117. emerge -av \
  118. x11-misc/xdotool \
  119. x11-misc/wmctrl && \
  120. env-update && \
  121. source /etc/profile && \
  122. export PS1="(chroot) $PS1" && \
  123. emerge -av \
  124. app-editors/vim \
  125. app-misc/ranger \
  126. app-misc/tmux \
  127. dev-vcs/git \
  128. media-fonts/dejavu \
  129. media-gfx/scrot \
  130. media-sound/alsa-utils \
  131. media-sound/cmus \
  132. media-video/ffmpeg \
  133. net-misc/youtube-dl \
  134. www-client/elinks \
  135. x11-misc/dmenu \
  136. x11-misc/i3lock \
  137. x11-misc/i3status \
  138. x11-terms/rxvt-unicode \
  139. x11-wm/i3
  140. emacs -av \
  141. media-video/mpv \
  142. www-client/chromium \
  143. www-client/firefox
  144. }
  145. Laptop() {
  146. emerge -av \
  147. app-laptop/laptop-mode-tools \
  148. net-wireless/wpa_supplicant \
  149. net-misc/connman && \
  150. rc-update add laptop_mode default
  151. }
  152. #Server() {}
  153. #Virtual() {}
  154. Cleanup() {
  155. rm -rf /stage3*.tar.bz2 \
  156. /var/tmp/portage/
  157. emerge -av \
  158. app-portage/gentoolkit \
  159. app-admin/eclean-kernel && \
  160. eclean-dist --deep --fetch-restricted && \
  161. eclean packages
  162. emerge -v -uDN @world && \
  163. emerge -av --depclean && \
  164. emerge --update --changed-use --deep @world
  165. cd /usr/src && tar -Jcvf linux-backup.tar.gz /usr/src/linux-* && \
  166. cd /usr/src/linux && rm -rf */
  167. }
  168. ## Execution #####################################
  169. case $1 in
  170. bootstrap|-b)
  171. Bootstrap
  172. ;;
  173. minimal|-m)
  174. Minimal && \
  175. Cleanup
  176. ;;
  177. desktop|-d)
  178. Minimal && \
  179. Desktop && \
  180. Cleanup
  181. ;;
  182. laptop|-l)
  183. Minimal && \
  184. Desktop && \
  185. Laptop && \
  186. Cleanup
  187. ;;
  188. server|-s)
  189. echo "WIP"
  190. #Minimal && \
  191. #Server && \
  192. #Cleanup
  193. ;;
  194. virtual|-v)
  195. echo "WIP"
  196. #Minimal && \
  197. #Virtual && \
  198. #Cleanup
  199. ;;
  200. *) echo "Available options for gein:"
  201. echo " bootstrap (-b), minimal (-m), desktop (-d), laptop (-l), server (-s), virtual (-v)"
  202. ;;
  203. esac