From 2d98607697ecddd8df09b0b30cf7633f93d5baed Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Sat, 21 Mar 2020 13:08:34 +0000
Subject: [PATCH] changes to chroot

---
 arch-install.sh |   37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/arch-install.sh b/arch-install.sh
index e33e945..1fdae21 100644
--- a/arch-install.sh
+++ b/arch-install.sh
@@ -2,34 +2,37 @@
 
 HOSTNAME=VM
 RPASS=root
+DISK=/dev/vda
+PARTNO=1
+LOCALE=en_US.UTF-8
 
 # Partition disk
 (
 echo n # Add a new partition
 echo p # Primary partition
-echo 1 # Partition number
+echo   # Partition number
 echo   # First sector (Accept default: 1)
 echo   # Last sector (Accept default: varies)
 echo w # Write changes
-) | sudo fdisk /dev/sda
-mkfs.ext4 /dev/sda1
+) | sudo fdisk $DISK
+mkfs.ext4 "$DISK$PARTNO"
 
 # Mount and install
-mount /dev/sda1 /mnt
-pacstrap base linux linux-firmware grub dhcpcd vim qemu-guest-agent
+mount "$DISK$PARTNO" /mnt
+pacstrap /mnt base linux linux-firmware grub dhcpcd vim qemu-guest-agent
 genfstab -U /mnt >> /mnt/etc/fstab
 
-# Setup system in chroot
-arch-chroot /mnt "ln -sf /usr/share/zoneinfo/UTC /etc/localtime;
-				  echo en_US.UTF-8 >> /etc/locale.gen;
-				  locale-gen;
-				  echo LANG=en_US.UTF-8 > /etc/locale.conf;
-				  echo $HOSTNAME > /etc/hostname;
-				  printf \"127.0.0.1\tlocalhost\n::1\t\tlocalhost\n127.0.1.1\t$HOSTNAME.localdomain $HOSTNAME\" > /etc/hostname;
-				  systemctl enable dhcpcd qemu-guest-agent;
-				  mkinitcpio -P;
-				  echo root:$RPASS | chpasswd;
-				  grub-install /dev/sda;
-				  grub-mkconfig -o /boot/grub/grub.cfg"
+# Setup locale
+arch-chroot /mnt ln -sf /usr/share/zoneinfo/UTC /etc/localtime
+sed -i -e "s/#$LOCALE/$LOCALE/" /mnt/etc/locale.gen
+arch-chroot /mnt locale-gen
+echo "LANG=$LOCALE" > /mnt/etc/locale.conf
+echo $HOSTNAME > /mnt/etc/hostname
+printf "127.0.0.1\tlocalhost\n::1\t\tlocalhost\n127.0.1.1\t$HOSTNAME.localdomain $HOSTNAME" > /mnt/etc/hosts
+arch-chroot /mnt systemctl enable dhcpcd qemu-ga
+arch-chroot /mnt mkinitcpio -P
+arch-chroot /mnt sh -c "echo root:$RPASS | chpasswd"
+arch-chroot /mnt grub-install $DISK
+arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
 
 reboot

--
Gitblit v1.9.3