linux-deployment-scripts/configs/scripts/install.sh

43 lines
1.2 KiB
Bash
Raw Normal View History

2024-11-09 20:59:14 +01:00
#!/bin/bash
2024-11-11 07:35:15 +01:00
# This file is part of VM-Experiments.
# Licensed under the GPL-3.0-or-later. See LICENSE for details.
2024-11-09 20:59:14 +01:00
2024-11-14 20:59:06 +01:00
read -p "Are you sure you want to install? (Type 'NO' to cancel, uppercase.)" install
if [ "$install" = "NO" ]; then
reboot
fi
2024-11-10 18:03:47 +01:00
trap '' SIGINT SIGTERM
2024-11-09 20:59:14 +01:00
parted -s /dev/sda mklabel msdos
parted -s /dev/sda mkpart primary linux-swap 0% 2GiB
parted -s /dev/sda mkpart primary ext4 2GiB 100%
mkswap /dev/sda1
mkfs.ext4 /dev/sda2
mount /dev/sda2 /mnt
swapon /dev/sda1
tar -xzvf /rootfs.tar.gz -C /mnt
genfstab -U /mnt >>/mnt/etc/fstab
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
2024-11-11 17:30:12 +01:00
if chroot /mnt /bin/bash -c "command -v grub2-mkconfig &>/dev/null"; then
2024-11-10 18:03:47 +01:00
chroot /mnt /bin/bash -c "grub2-mkconfig -o /boot/grub/grub.cfg"
2024-11-11 17:30:12 +01:00
elif chroot /mnt /bin/bash -c "command -v grub-mkconfig &>/dev/null"; then
2024-11-10 18:03:47 +01:00
chroot /mnt /bin/bash -c "grub-mkconfig -o /boot/grub/grub.cfg"
fi
2024-11-11 17:30:12 +01:00
if chroot /mnt /bin/bash -c "command -v grub2-install &>/dev/null"; then
2024-11-10 18:03:47 +01:00
chroot /mnt /bin/bash -c "grub2-install /dev/sda"
2024-11-11 17:30:12 +01:00
elif chroot /mnt /bin/bash -c "command -v grub-install &>/dev/null"; then
2024-11-10 18:03:47 +01:00
chroot /mnt /bin/bash -c "grub-install /dev/sda"
fi