Add Archlinux

This commit is contained in:
Greg Hellings
2023-08-13 18:44:20 -05:00
parent 14413542f5
commit c2a53828a1
13 changed files with 225 additions and 40 deletions
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -ex
disk="${1}"
# 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
grub-install --target=i386-pc "${disk}"
grub-mkconfig -o /boot/grub/grub.cfg
# Create and configure the vagrant user
groupadd vagrant
useradd vagrant -g vagrant -G wheel -d /home/vagrant
echo "vagrant:vagrant" | chpasswd
# Configure vagrant user's SSH key
mkdir -m 0700 -p ~vagrant/.ssh
cat > ~vagrant/.ssh/authorized_keys << EOKEYS
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
EOKEYS
chmod 600 ~vagrant/.ssh/authorized_keys
chown -R vagrant:vagrant ~vagrant/
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
#vim: set ft=bash:
set -ex
port="${1}" # HTTP port that packer is running on
loadkeys en # Probably not necessary in a script, but here we are
if [ -e /dev/vda ]; then
disk="/dev/vda"
elif [ -e /dev/sda ]; then
disk="/dev/sda"
else
exit 1 # Need to teach the script which device to use in this case
fi
# The sed bit is just to strip out the extra fluff, like comments
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${disk}
o # create new GPT partition table
n # new
p # primary partition
1 # part number
# default start
# default to full disk
p # print, for debugging
r # return to normal mode
w # write the partition table and exit
EOF
#t # set partition type
#1 # on partition 1
#4 # BIOS boot
# Format and mount partitions
mkfs.ext4 "${disk}1"
mount "${disk}1" /mnt
# Bootstrap system
pacstrap -K /mnt base linux nano sudo networkmanager openssh grub python3
genfstab -L /mnt >> /mnt/etc/fstab
# Run stuff in the chroot
curl -o /mnt/in-chroot.sh http://10.0.2.2:"${port}"/in-chroot.sh
arch-chroot /mnt /usr/bin/bash /in-chroot.sh "${disk}"
rm /mnt/in-chroot.sh
reboot
+54
View File
@@ -0,0 +1,54 @@
install
text
reboot
network --bootproto=dhcp --activate
url --url=http://mirror.centos.org/centos/7/os/x86_64/
repo --name=updates --baseurl=http://mirror.centos.org/centos/7/updates/x86_64/
lang en_US.UTF-8
keyboard us
timezone --utc Etc/UTC
rootpw --plaintext vagrant
user --name=vagrant --groups=vagrant --password=vagrant --plaintext
zerombr
clearpart --all --initlabel
autopart --type=plain
bootloader --timeout=1
%packages
@core
which
libselinux-python
# mandatory packages in the @core group
-btrfs-progs
-iprutils
-kexec-tools
-plymouth
# default packages in the @core group
-*-firmware
-dracut-config-rescue
-kernel-tools
-libsysfs
-microcode_ctl
-NetworkManager*
-postfix
-rdma
%end
%post --erroronfail
yum -y update
cat <<EOF > /etc/sudoers.d/vagrant
Defaults:vagrant !requiretty
vagrant ALL=(ALL) NOPASSWD: ALL
EOF
chmod 440 /etc/sudoers.d/vagrant
ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules
cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
EOF
%end
@@ -0,0 +1,15 @@
distro = "arch"
version = "2023.08.01"
iso = {
url = "http://dfw.mirror.rackspace.com/archlinux/iso/2023.08.01/archlinux-x86_64.iso"
checksum = "3bf1287333de5c26663b70a17ce7573f15dc60780b140cbbd1c720338c0abac5"
}
boot_command = [
"<tab><wait> net.ifnames=0<wait> <wait>bi<wait>osdevnames=0<enter>",
"<wait60>", # Wait for system to come up?
"curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh<enter>",
"<wait5>",
"/usr/bin/bash /tmp/install.sh {{ .HTTPPort }}<enter>"
]
http_directory = "distros/arch/2023.08.01/http/"
boot_wait = "10s"
+5
View File
@@ -0,0 +1,5 @@
2023.08.01:
- arch: x86_64
provider: qemu
- arch: x86_64
provider: virtualbox-iso