Created
December 7, 2020 20:26
-
-
Save andi242/e8f2b3c389438c76880bceb6f39be8c5 to your computer and use it in GitHub Desktop.
personal-arch-install.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| DISK=$1 | |
| # if no $1 ask for a disk to wipe | |
| if [ "$1" = "" ] | |
| then | |
| lsblk -o NAME,FSTYPE,MOUNTPOINT,FSUSE% | |
| echo "Here's the system disks, what should be deleted for install? (e.g. vda)" | |
| read DISK | |
| fi | |
| echo "##### check and delete existing partitioning" | |
| PARTS=$(lsblk | grep $DISK | wc -l ) | |
| if [ $PARTS -gt 1 ] | |
| then | |
| COUNT=1 | |
| while [ $COUNT -lt $PARTS ] | |
| do | |
| echo "deleting /dev/$DISK, partition $COUNT" | |
| parted /dev/$DISK rm $COUNT | |
| COUNT=$(( $COUNT + 1 )) | |
| done | |
| fi | |
| echo "##### press key to continue" | |
| read | |
| echo "##### partitioning" | |
| parted -s /dev/$DISK mklabel gpt mkpart primary fat32 1MiB 501MiB set 1 esp on mkpart primary ext4 501MiB 100% | |
| mkfs.fat -F32 /dev/"$DISK"1 | |
| mkfs.ext4 /dev/"$DISK"2 | |
| mount /dev/"$DISK"2 /mnt | |
| mkdir /mnt/boot | |
| mount /dev/"$DISK"1 /mnt/boot | |
| pacstrap /mnt base base-devel linux linux-firmware openssh vim networkmanager bash-completion git grub efibootmgr dosfstools gptfdisk | |
| genfstab -U /mnt > /mnt/etc/fstab | |
| arch-chroot /mnt /bin/bash <<EOF | |
| echo "##### setting timezone" | |
| ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime | |
| echo "##### setting locales" | |
| sed -i.bak 's/^#de_DE.UTF-8\ UTF-8/de_DE.UTF-8 UTF-8/g' /etc/locale.gen | |
| sed -i.bak 's/^#de_DE\ ISO-8859-1/de_DE ISO-8859-1/g' /etc/locale.gen | |
| locale-gen | |
| echo LANG=de_DE.UTF-8 > /etc/locale.conf | |
| echo KEYMAP=de-latin1-nodeadkeys > /etc/vconsole.conf | |
| echo "##### setting hostname" | |
| echo arch > /etc/hostname | |
| echo "##### setting rootpw" | |
| echo "root:1234"|chpasswd | |
| echo "##### install kernel and grub" | |
| mkinitcpio -P linux | |
| grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch_grub --recheck | |
| grub-mkconfig -o /boot/grub/grub.cfg | |
| echo "##### enabling networkmanager" | |
| systemctl enable NetworkManager | |
| echo "##### enabling sshd" | |
| systemctl enable sshd | |
| echo "##### adding user" | |
| useradd -mG wheel user | |
| sed -i.bak 's/^#\ %wheel\ ALL=(ALL)\ NOPASSWD:\ ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers | |
| echo "user:1234"|chpasswd | |
| echo "##### install yay" | |
| su - user -c "git clone https://aur.archlinux.org/yay-bin.git /tmp/yay" | |
| su - user -c "cd /tmp/yay ;makepkg -scri --noconfirm" | |
| echo "##### chroot finished" | |
| EOF | |
| echo "##### unmount all" | |
| umount -R /mnt | |
| echo "##### done #####" | |
| echo "##### check if everything is unmounted and reboot #####" | |
| df -h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment