Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.68 KB | None | 0 0
  1. # check inteernet connection
  2. if [[ ! $(curl -Is http://www.google.com/ | head -n 1) =~ "200 OK" ]]; then
  3.   echo "Your Internet seems broken. Press Ctrl-C to abort or enter to continue."
  4.   read
  5. fi
  6.  
  7. # BRAZELLL!!111!!ONZE11!!
  8. loadkeys br-abnt2
  9.  
  10. # create partition table
  11. parted -s /dev/sda mktable msdos
  12. # boot partition
  13. parted -s /dev/sda mkpart primary 0% 100m
  14. # root partition
  15. parted -s /dev/sda mkpart primary 100m 100%
  16.  
  17. # /boot (no journaling needed)
  18. mkfs.ext2 /dev/sda1
  19.  
  20. # / (better fs for better performance)
  21. mkfs.btrfs /dev/sda2
  22.  
  23. # mouting partitions
  24. mount /dev/sda2 /mnt
  25. mkdir /mnt/boot
  26. mount /dev/sda1 /mnt/boot
  27.  
  28. # rankmirrors to make this faster (though it takes a while)
  29. mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig
  30. rankmirrors -n 6 /etc/pacman.d/mirrorlist.orig >/etc/pacman.d/mirrorlist
  31.  
  32. # enabled countrys
  33. declare -a Cnts=("United States" "Brazil" "Portugal")
  34.  
  35. # output a file with each country
  36. for Cnt in "${arr[@]}"
  37. do
  38.   awk -v GG=$Cnt '{if(match($0,GG) != "0")AA="1";if(AA == "1"){if( length($2) != "0"  )print substr($0,2) ;else AA="0"} }' /etc/pacman.d/mirrorlist > /etc/pacman.d/$Cnt.newmirrorlist
  39. done
  40.  
  41. # merge files
  42. awk 'FNR==1{print ""}1' *.newmirrorlist > /etc/pacman.d/mirrorlist.pacnew
  43.  
  44. # rank each mirror
  45. rankmirrors /etc/pacman.d/mirrorlist.pacnew >/etc/pacman.d/mirrorlist
  46.  
  47. # and remove tmp files
  48. rm *.newmirrorlist mirrorlist.pacnew
  49.  
  50. # update pacman databases
  51. pacman -Syy
  52.  
  53. # install
  54. pacstrap -i /mnt base base-devel
  55.  
  56. # update fstab
  57. genfstab -U -p /mnt >> /mnt/etc/fstab
  58.  
  59. # finally chroot
  60. arch-chroot /mnt pacman -S syslinux --noconfirm
  61.  
  62. # copy ranked mirrorlist over
  63. cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
  64.  
  65. # huge chroot calls here
  66. arch-chroot /mnt /bin/bash <<EOF
  67. # set initial hostname
  68. echo "archlinux-vm" >/etc/hostname
  69.  
  70. # set initial timezone to America/Sao_Paulo
  71. ln -s /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
  72.  
  73. # setup locale
  74. locale >/etc/locale.conf
  75. echo "en_GB.UTF-8 UTF-8" >>/etc/locale.gen
  76. echo "pt_BR.UTF-8 UTF-8" >>/etc/locale.gen
  77.  
  78. # generate locale
  79. locale-gen
  80.  
  81. # no modifications to mkinitcpio.conf should be needed
  82. mkinitcpio -p linux
  83.  
  84. # install syslinux bootloader
  85. syslinux-install_update -i -a -m
  86.  
  87. # update syslinux config with correct root disk
  88. sed 's/root=.*/root=\/dev\/sda2 ro/' < /boot/syslinux/syslinux.cfg > /boot/syslinux/syslinux.cfg.new
  89.  
  90. mv /boot/syslinux/syslinux.cfg.new /boot/syslinux/syslinux.cfg
  91.  
  92. # set root password to "root"
  93. echo root:batata | chpasswd
  94.  
  95. # enable internet
  96. systemctl enable dhcpcd@eth0.service
  97.  
  98. # no more chroot things
  99. EOF
  100.  
  101. # unmount
  102. umount /mnt/{boot,}
  103.  
  104. echo "Done! Unmount the CD image from the VM, then type 'reboot'."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement