Skip to content

Instantly share code, notes, and snippets.

@MCMXCIII
Created February 28, 2024 14:51
Show Gist options
  • Save MCMXCIII/4de4e421758fe3e222c717d6ca8f974c to your computer and use it in GitHub Desktop.
Save MCMXCIII/4de4e421758fe3e222c717d6ca8f974c to your computer and use it in GitHub Desktop.
Script
#!/bin/bash
# Function to prompt user for boot method selection
prompt_boot_method() {
echo "Select boot method:"
echo "1. BIOS"
echo "2. UEFI"
read -p "Enter your choice (1 or 2): " boot_choice
case $boot_choice in
1) BOOT_METHOD="BIOS";;
2) BOOT_METHOD="UEFI";;
*) echo "Invalid choice. Please select 1 or 2."
prompt_boot_method;;
esac
}
# Function to prompt user for disk selection
prompt_disk_selection() {
lsblk
read -p "Enter the disk (e.g., /dev/sda) to install the system on: " install_disk
if ! [[ -b $install_disk ]]; then
echo "Invalid disk. Please enter a valid disk (e.g., /dev/sda)."
prompt_disk_selection
fi
}
# Prompt user for boot method
prompt_boot_method
# Prompt user for disk selection
prompt_disk_selection
# Proceed with installation based on selected boot method and disk
echo "Selected boot method: $BOOT_METHOD"
echo "Selected disk: $install_disk"
# 3. Prepare the hard disk
sudo wipefs --all $install_disk
# Partition the disk based on selected boot method
if [ "$BOOT_METHOD" = "BIOS" ]; then
sudo fdisk $install_disk <<EOF
o
n
p
1
+512M
a
1
n
p
2
w
EOF
else
sudo fdisk $install_disk <<EOF
g
n
1
+512M
t
1
1
n
2
w
EOF
fi
# Format and label the file systems for each partition
sudo mkfs.fat -F 32 ${install_disk}1 -n EFI
sudo fatlabel ${install_disk}1 EFI
sudo mkfs.ext4 ${install_disk}2 -L Exherbo
sudo e2label ${install_disk}2 Exherbo
# Mount the root partition and navigate to it
sudo mount ${install_disk}2 /mnt/exherbo
cd /mnt/exherbo
# Get the latest archive of Exherbo from Stages and verify the consistency of the file
curl -O https://stages.exherbolinux.org/x86_64-pc-linux-gnu/exherbo-x86_64-pc-linux-gnu-gcc-current.tar.xz
curl -O https://stages.exherbolinux.org/x86_64-pc-linux-gnu/exherbo-x86_64-pc-linux-gnu-gcc-current.tar.xz.sha256sum
sha256sum -c exherbo-x86_64-pc-linux-gnu-current.tar.xz.sha256sum
# Extract the stage
tar xJpf exherbo*xz
# Update /mnt/exherbo/etc/fstab based on boot method
if [ "$BOOT_METHOD" = "UEFI" ]; then
echo "/dev/sda1 /boot vfat defaults 0 0" >> /mnt/exherbo/etc/fstab
else
echo "/dev/sda1 /boot ext2 defaults 0 0" >> /mnt/exherbo/etc/fstab
fi
# Update /mnt/exherbo/etc/fstab for root and home partitions
cat <<EOF >> /mnt/exherbo/etc/fstab
${install_disk}2 / ext4 defaults 0 0
${install_disk}3 /home ext4 defaults 0 2
EOF
# Chroot into the system
sudo mount --rbind /dev /mnt/exherbo/dev
sudo mount --bind /sys /mnt/exherbo/sys
sudo mount -t proc none /mnt/exherbo/proc
sudo mount ${install_disk}1 /mnt/exherbo/boot
sudo chroot /mnt/exherbo /bin/bash -c "source /etc/profile; PS1=\"(Exherbo) \$PS1\""
# Update the install
sudo vi /etc/paludis/bashrc /etc/paludis/*.conf
sudo cave sync
sudo cave resolve --execute -x world
# Make it bootable
sudo git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux /kernel
cd /kernel
sudo git checkout tags/v5.0.7
sudo make nconfig
sudo make
sudo make modules_install
sudo cave resolve --execute -1 --skip-phase test sys-apps/systemd
sudo bootctl install
sudo bash -c 'echo "sys-apps/systemd efi" >> /etc/paludis/options.conf'
sudo kernel-install add 5.0.7 /boot/vmlinuz-5.0.7
sudo kernel-install remove {kernel-version}
sudo bash -c 'echo "kanto" > /etc/hostname'
sudo bash -c 'echo "127.0.0.1 localhost kanto" > /etc/hosts'
sudo localdef -i en_US -f UTF-8 en_US.UTF-8
sudo bash -c 'echo "LANG=en_US.UTF-8" > /etc/locale.conf'
sudo ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
sudo hwclock --systohc --utc
sudo reboot
# Post-installation tasks
sudo rm /exherbo-x86_64-pc-linux-gnu-current.tar.xz
sudo cave purge
sudo cave update-world --set stages
sudo useradd -m -G adm,disk,wheel,cdrom,audio,video,usb,users taupiqueur
sudo passwd taupiqueur
sudo cave resolve --execute app-admin/sudo
sudo bash -c 'echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers'
# Configuring your desktop, Useful commands, Creating your own packages, Share your configuration, Contributing steps remain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment