linux-xanmod-bin 6.17.6-2
This commit is contained in:
93
linux-xanmod-bin/postinstall.sh
Normal file
93
linux-xanmod-bin/postinstall.sh
Normal file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
# Post-install script for linux-xanmod-bin
|
||||
|
||||
set -e
|
||||
|
||||
# Get kernel version from the installed files
|
||||
kernel_version=$(basename /usr/lib/modules/*-xanmod1 2>/dev/null | head -n 1)
|
||||
|
||||
if [ -z "$kernel_version" ]; then
|
||||
echo "Error: Could not determine kernel version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "/boot/vmlinuz-$kernel_version" ]; then
|
||||
echo "Error: Kernel image /boot/vmlinuz-$kernel_version not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Detected kernel $kernel_version, running system hooks..."
|
||||
|
||||
# For RedOS/RHEL/Fedora systems with dracut
|
||||
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
|
||||
|
||||
# For Arch-based systems with mkinitcpio
|
||||
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
|
||||
|
||||
# For Debian-based systems with update-initramfs
|
||||
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
|
||||
|
||||
# For Alpine Linux with mkinitfs
|
||||
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
|
||||
|
||||
# Update GRUB configuration
|
||||
echo "Updating bootloader configuration..."
|
||||
|
||||
# For RHEL/Fedora/RedOS with grubby (BLS - Boot Loader Specification)
|
||||
if command -v grubby >/dev/null 2>&1; then
|
||||
echo "Adding kernel to bootloader using grubby..."
|
||||
kernel_path="/boot/vmlinuz-$kernel_version"
|
||||
initrd_path="/boot/initramfs-$kernel_version.img"
|
||||
|
||||
# Check if kernel already exists in grubby
|
||||
if grubby --info="$kernel_path" >/dev/null 2>&1; then
|
||||
echo "Kernel already registered in bootloader"
|
||||
else
|
||||
# Add kernel entry
|
||||
grubby --add-kernel="$kernel_path" \
|
||||
--initrd="$initrd_path" \
|
||||
--title="Red OS Linux ($kernel_version) - Xanmod" \
|
||||
--copy-default
|
||||
echo "Kernel added to bootloader"
|
||||
fi
|
||||
|
||||
# For Debian/Ubuntu with update-grub
|
||||
elif command -v update-grub >/dev/null 2>&1; then
|
||||
echo "Updating GRUB configuration..."
|
||||
update-grub
|
||||
|
||||
# For other systems with grub2-mkconfig
|
||||
elif command -v grub2-mkconfig >/dev/null 2>&1; then
|
||||
echo "Updating GRUB2 configuration..."
|
||||
grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||
|
||||
# For systems with grub-mkconfig
|
||||
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 "=========================================="
|
||||
Reference in New Issue
Block a user