Files
vms/distros/archlinux/rolling/http/in-chroot.sh
T

52 lines
1.5 KiB
Bash
Raw Normal View History

2023-08-13 18:44:20 -05:00
#!/usr/bin/env bash
set -ex
2023-12-30 05:37:32 +00:00
#disk="${1}"
2025-01-22 14:42:50 -06:00
# Do host-specific things
virt="${2}"
# Values I've found so far
# "microsoft" == Hyper-V
# "oracle" == VirtualBox
# "KVM" == KVM/Qemu
2023-08-13 18:44:20 -05:00
# Set locale info to reasonable defaults
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
sed -i -E -e 's/#(en_US.UTF-8 UTF-8)/\1/' /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=en" > /etc/vconsole.conf
echo "vagrant" > /etc/hostname
# Configure systems
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant-nopasswd
echo 'Defaults !requiretty' >> /etc/sudoers
sed -i 's/.*UseDNS.*/UseDNS no/' /etc/ssh/sshd_config
cat > /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf <<EOF
# For now the vagrant insecure key is an rsa key
# https://github.com/hashicorp/vagrant/issues/11783
PubkeyAcceptedKeyTypes=+ssh-rsa
EOF
ssh-keygen -A
systemctl enable sshd
systemctl enable NetworkManager
# Configure and install grub
sed -i -E -e 's/GRUB_CMDLINE_LINUX="(.*)"/GRUB_CMDLINE_LINUX="\1 net.ifnames=0 biosdevnames=0"/' /etc/default/grub
2023-12-30 05:37:32 +00:00
grub-install --target=x86_64-efi --efi-directory /boot
grub-install --target=x86_64-efi --efi-directory /boot --removable
2023-08-13 18:44:20 -05:00
grub-mkconfig -o /boot/grub/grub.cfg
# Create and configure the vagrant user
groupadd vagrant
2023-08-22 00:18:02 -05:00
useradd vagrant -g vagrant -G wheel -m
[ -d /home/vagrant ] || exit 1
2023-08-13 18:44:20 -05:00
echo "vagrant:vagrant" | chpasswd
2023-08-25 11:51:45 -05:00
if [ "${virt}" == "microsoft" ]; then
pacman -S --noconfirm hyperv
systemctl enable hv_kvp_daemon
systemctl enable hv_vss_daemon
2023-12-30 05:37:32 +00:00
fi
2025-01-22 14:42:50 -06:00
sleep 60