Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. #!/bin/bash
  2. # WARNING: this script will destroy data on the selected disk.
  3. # This script can be run by executing the following:
  4. # curl -sL https://git.io/vAoV8 | bash
  5. set -uo pipefail
  6. trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
  7.  
  8. echo "Updating mirror list"
  9. mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.original
  10. rankmirrors -n 6 /etc/pacman.d/mirrorlist.original > /etc/pacman.d/mirrorlist
  11.  
  12. ### Get infomation from user ###
  13. hostname=$(dialog --stdout --inputbox "Enter hostname" 0 0) || exit 1
  14. clear
  15. : ${hostname:?"hostname cannot be empty"}
  16.  
  17. user=$(dialog --stdout --inputbox "Enter admin username" 0 0) || exit 1
  18. clear
  19. : ${user:?"user cannot be empty"}
  20.  
  21. password=$(dialog --stdout --passwordbox "Enter admin password" 0 0) || exit 1
  22. clear
  23. : ${password:?"password cannot be empty"}
  24. password2=$(dialog --stdout --passwordbox "Enter admin password again" 0 0) || exit 1
  25. clear
  26. [[ "$password" == "$password2" ]] || ( echo "Passwords did not match"; exit 1; )
  27.  
  28. devicelist=$(lsblk -dplnx size -o name,size | grep -Ev "boot|rpmb|loop" | tac)
  29. device=$(dialog --stdout --menu "Select installtion disk" 0 0 0 ${devicelist}) || exit 1
  30. clear
  31.  
  32. ### Set up logging ###
  33. exec 1> >(tee "stdout.log")
  34. exec 2> >(tee "stderr.log")
  35.  
  36. timedatectl set-ntp true
  37.  
  38. ### Setup the disk and partitions ###
  39. swap_size=$(free --mebi | awk '/Mem:/ {print $2}')
  40. swap_end=$(( $swap_size + 129 + 1 ))MiB
  41.  
  42. parted --script "${device}" -- mklabel gpt \
  43. mkpart ESP fat32 1Mib 129MiB \
  44. set 1 boot on \
  45. mkpart primary linux-swap 129MiB ${swap_end} \
  46. mkpart primary ext4 ${swap_end} 100%
  47.  
  48. # Simple globbing was not enough as on one device I needed to match /dev/mmcblk0p1
  49. # but not /dev/mmcblk0boot1 while being able to match /dev/sda1 on other devices.
  50. part_boot="$(ls ${device}* | grep -E "^${device}p?1$")"
  51. part_swap="$(ls ${device}* | grep -E "^${device}p?2$")"
  52. part_root="$(ls ${device}* | grep -E "^${device}p?3$")"
  53.  
  54. wipefs "${part_boot}"
  55. wipefs "${part_swap}"
  56. wipefs "${part_root}"
  57.  
  58. mkfs.vfat -F32 "${part_boot}"
  59. mkswap "${part_swap}"
  60. mkfs.f2fs -f "${part_root}"
  61.  
  62. swapon "${part_swap}"
  63. mount "${part_root}" /mnt
  64. mkdir /mnt/boot
  65. mount "${part_boot}" /mnt/boot
  66.  
  67. ### Install and configure the basic system ###
  68. pacstrap /mnt base base-devel connman wpa_supplicant
  69. genfstab -t PARTUUID /mnt >> /mnt/etc/fstab
  70. echo "${hostname}" > /mnt/etc/hostname
  71.  
  72. arch-chroot /mnt bootctl install
  73.  
  74. cat <<EOF > /mnt/boot/loader/loader.conf
  75. default arch
  76. EOF
  77.  
  78. cat <<EOF > /mnt/boot/loader/entries/arch.conf
  79. title Arch Linux
  80. linux /vmlinuz-linux
  81. initrd /initramfs-linux.img
  82. options root=PARTUUID=$(blkid -s PARTUUID -o value "$part_root") rw
  83. EOF
  84.  
  85. echo "LANG=en_AU.UTF-8" > /mnt/etc/locale.conf
  86.  
  87. arch-chroot /mnt useradd -mU -s /usr/bin/zsh -G wheel,uucp,video,audio,storage,games,input "$user"
  88. arch-chroot /mnt chsh -s /usr/bin/zsh
  89.  
  90. echo "$user:$password" | chpasswd --root /mnt
  91. echo "root:$password" | chpasswd --root /mnt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement