Advertisement
Guest User

Gentoo-Installer.sh

a guest
Apr 13th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.17 KB | None | 0 0
  1.  
  2. #This program is free software: you can redistribute it and/or modify
  3. #it under the terms of the GNU General Public License as published by
  4. #the Free Software Foundation, either version 3 of the License, or
  5. #(at your option) any later version.
  6.  
  7. #This program is distributed in the hope that it will be useful,
  8. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. #GNU General Public License for more details.
  11.  
  12. #You should have received a copy of the GNU General Public License
  13. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14.  
  15. #######################################################################
  16.  
  17. echo "Loading additional kernel modules"
  18.  
  19. if [ modprobe8139too ]; then
  20.     modprobe8139too
  21. else
  22.     echo "modprobe8139too failed to load....exiting"
  23.     exit 1
  24. fi
  25.  
  26.  
  27. #######################################################################
  28.  
  29.  
  30. echo "Please enter root password"
  31.  
  32. passwd
  33.  
  34. #######################################################################
  35.  
  36. echo "Adding user account"
  37.  
  38. if [ $(id -u) -eq 0 ]; then
  39.     read -p "Enter username : " username
  40.     read -s -p "Enter password : " password
  41.     egrep "^$username" /etc/passwd >/dev/null
  42.     if [ $? -eq 0 ]; then
  43.         echo "$username exists!"
  44.         exit 1
  45.     else
  46.         pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
  47.         useradd -m -G $pass $username
  48.         [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
  49.     fi
  50. else
  51.     echo "Only root may add a user to the system"
  52.     exit 2
  53. fi
  54.  
  55. #######################################################################
  56.  
  57. while true; do
  58.     read -p "Would you like to start the SSH daemon?" yn
  59.     case $yn in
  60.         [Yy]* ) /etc/init.d/sshd start;;
  61.         [Nn]* ) exit;;
  62.     esac
  63. done
  64.  
  65. #######################################################################
  66.  
  67. echo "Configuring network with net-setup eth0"
  68.  
  69. net-setup eth0
  70.  
  71. #######################################################################
  72.  
  73. #Using Dynamic Host Control Protocol for network configuration
  74.  
  75. #dhcpd eth0
  76.  
  77. #If you're system administrator requires hostname and domainname to be
  78. #provided by the DHCP server use the following command instead
  79.  
  80. #dhcpcd -HD eth0
  81.  
  82. #######################################################################
  83.  
  84. echo "Creating 2MB partition for GRUB2"
  85.  
  86. parted -a optimal /dev/sda
  87. mklabel gpt
  88. unit mib
  89. mkpart primary 1 3
  90. name 1 grub
  91. set 1 bios_grub on
  92. print
  93. sleep 5
  94.  
  95. echo "Creating boot partition 128MB"
  96.  
  97. mkpart primary 3 131
  98. name 2 boot
  99. mkpart primary 131 643
  100. name 3 swap
  101. mkpart primary 643 -1
  102. name 4 rootfs
  103. set 2 boot on   #parted automatically switches to EFI when the boot option
  104.                 #is set on the partition
  105. parted print
  106. sleep 5
  107.  
  108. #######################################################################
  109.  
  110. echo "Creating swap"
  111.  
  112. mkswap /dev/sda3
  113.  
  114. echo "Activating swap"
  115.  
  116. swapon /dev/sda3
  117.  
  118. #######################################################################
  119.  
  120. echo "Mounting drives"
  121. mount /dev/sda4 /mnt/gentoo
  122. mkdir /mnt/gentoo/boot
  123. mount /dev/sda2 /mnt/gentoo/boot
  124. #chmod 1777 /mnt/gentoo/ tmp    #If /tmp/ resides on seperate partition
  125.                                 #This changes its permissions AFTER
  126.                                 #mounting.
  127.                                
  128. #######################################################################
  129.  
  130. echo "Installing tarball is the date correct?"
  131.  
  132. date
  133. sleep 5
  134.  
  135. cd /mnt/gentoo
  136. echo "Select download stage"
  137. links https://www.gentoo.org/downloads/mirrors/
  138. tar xvjpf stage3-*.tar.bz2 --xattrs
  139. echo "Update the /mnt/gentoo/etc/portage/make.conf file to match personal preference and save"
  140. nano -w /mnt/gentoo/etc/portage/make.conf
  141.  
  142. #######################################################################
  143.  
  144. echo "Installing base system"
  145. mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
  146. mkdir /mnt/gentoo/etc/portage/repos.conf
  147. cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
  148. cp -L /etc/resolv.conf /mnt/gentoo/etc/
  149. mount -t proc proc /mnt/gentoo/proc
  150. mount --rbind /sys /mnt/gentoo/sys
  151. mount --make-rslave /mnt/gentoo/sys
  152. mount --rbind /dev /mnt/gentoo/dev
  153. mount --make-rslave /mnt/gentoo/dev
  154. chroot /mnt/gentoo /bin/bash
  155. source /etc/profile
  156. export PS1="(chroot) $PS1"
  157. emerge-webrsync
  158. emerge --sync
  159. eselect news list
  160. eselect news read
  161. eselect profile list
  162. eselect profile set 2
  163. eselect profile list
  164. eselect profile set 5
  165. eselect profile set default/linux/amd64/13.0/systemd
  166. eselect profile list
  167. emerge --ask --update --deep --newuse @world
  168. emerge --info | grep ^USE
  169. less /usr/portage/profiles/use.desc
  170. nano -w /etc/portage/make.conf
  171. ls /usr/share/zoneinfo
  172. echo "Europe/London" > /etc/timezone
  173. emerge --config sys-libs/timezone-data
  174. echo "en_GB.UTF-8 UTF-8" > /etc/locale.gen
  175. env-update && source /etc/profile && export PS1="(chroot) $PS1"
  176.  
  177. #######################################################################
  178.  
  179. echo "Done installing base system its now up to you to manually configure the kernel and optimise it to your needs"
  180. sleep 3
  181. echo "Good luck!"
  182. links https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel
  183.  
  184. #######################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement