89 lines
2.8 KiB
Bash
89 lines
2.8 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
kernel_version=$(ls -1 /usr/lib/modules/ 2>/dev/null | grep -E '\-xanmod[0-9]*$' | sort -V | tail -n 1)
|
|
|
|
if [ -z "$kernel_version" ]; then
|
|
echo "Error: Could not determine kernel version"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Detected kernel $kernel_version, running system hooks..."
|
|
|
|
kernel_path="/boot/vmlinuz-$kernel_version"
|
|
modules_vmlinuz="/usr/lib/modules/$kernel_version/vmlinuz"
|
|
|
|
if [ ! -f "$kernel_path" ]; then
|
|
if [ -f "$modules_vmlinuz" ]; then
|
|
echo "Copying kernel image to /boot..."
|
|
cp "$modules_vmlinuz" "$kernel_path"
|
|
chmod 755 "$kernel_path"
|
|
else
|
|
echo "Error: Kernel image not found in /boot or modules directory"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if command -v dracut >/dev/null 2>&1; then
|
|
initramfs_img="/boot/initramfs-$kernel_version.img"
|
|
echo "Creating initramfs for $kernel_version using dracut..."
|
|
dracut --force --kmoddir "/usr/lib/modules/$kernel_version" "$initramfs_img" "$kernel_version"
|
|
echo "Initramfs created: $initramfs_img"
|
|
fi
|
|
|
|
if command -v mkinitcpio >/dev/null 2>&1; then
|
|
echo "Creating initramfs for $kernel_version using mkinitcpio..."
|
|
mkinitcpio -k "$kernel_version" -g "/boot/initramfs-$kernel_version.img"
|
|
fi
|
|
|
|
if command -v update-initramfs >/dev/null 2>&1; then
|
|
echo "Creating initramfs for $kernel_version using update-initramfs..."
|
|
update-initramfs -c -k "$kernel_version"
|
|
fi
|
|
|
|
if command -v mkinitfs >/dev/null 2>&1; then
|
|
echo "Creating initramfs for $kernel_version using mkinitfs..."
|
|
mkinitfs -o "/boot/initramfs-$kernel_version" "$kernel_version"
|
|
fi
|
|
|
|
echo "Updating bootloader configuration..."
|
|
|
|
if command -v grubby >/dev/null 2>&1; then
|
|
echo "Adding kernel to bootloader using grubby..."
|
|
initrd_path="/boot/initramfs-$kernel_version.img"
|
|
|
|
if grubby --info="$kernel_path" >/dev/null 2>&1; then
|
|
echo "Kernel already registered in bootloader"
|
|
else
|
|
grubby --add-kernel="$kernel_path" \
|
|
--initrd="$initrd_path" \
|
|
--title="Red OS Linux ($kernel_version) - Xanmod" \
|
|
--copy-default
|
|
echo "Kernel added to bootloader"
|
|
fi
|
|
|
|
elif command -v update-grub >/dev/null 2>&1; then
|
|
echo "Updating GRUB configuration..."
|
|
update-grub
|
|
|
|
elif command -v grub2-mkconfig >/dev/null 2>&1; then
|
|
echo "Updating GRUB2 configuration..."
|
|
grub2-mkconfig -o /boot/grub2/grub.cfg
|
|
|
|
elif command -v grub-mkconfig >/dev/null 2>&1; then
|
|
echo "Updating GRUB configuration..."
|
|
grub-mkconfig -o /boot/grub/grub.cfg
|
|
else
|
|
echo "Warning: No bootloader configuration tool found. Please update your bootloader manually."
|
|
fi
|
|
|
|
echo ""
|
|
echo "=========================================="
|
|
echo "Kernel $kernel_version installed successfully!"
|
|
echo ""
|
|
echo "To boot into this kernel:"
|
|
echo "1. Reboot your system"
|
|
echo "2. Select 'linux-xanmod' from the GRUB menu"
|
|
echo "=========================================="
|