zlookkernel.sh 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # This script has been provided by zerouno.
  2. # For further information, please take a look at the relevant LinuxQuestions.org thread:
  3. # https://www.linuxquestions.org/questions/slackware-14/slackpkg-lilo-elilo-initrd-4175628620/#post5849061
  4. lookkernel() {
  5. NEWKERNELMD5=$(md5sum /boot/vmlinuz 2>/dev/null)
  6. if [ "$KERNELMD5" != "$NEWKERNELMD5" ]; then
  7. KERNEL=$(readlink /boot/vmlinuz | sed 's/.*-\([1-9]\)/\1/')
  8. echo -e "\nYour kernel image was updated (found $KERNEL). You have to rebuild the bootloader.\nDo you want slackpkg to do it? (Y/n)"
  9. answer
  10. if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
  11. INITRD=/boot/initrd.gz
  12. if [ -e /boot/initrd-tree/command_line ];then
  13. OINITRD=$(cat /boot/initrd-tree/command_line|grep -- " -o "|sed -r 's/^.* -o *([^ ]*).*$/\1/')
  14. INITRD=${OINITRD:-$INITRD}
  15. if [ -f "$INITRD" ];then
  16. echo -en "Found $INITRD; rebuilding it with:\n "
  17. MKINITRD=$(sed -e "s/ *-k *[^ ]\+//g" -e "s/ *$/ -k $KERNEL/" /boot/initrd-tree/command_line)
  18. echo " $MKINITRD"
  19. echo "Do you want continue? (Y/n)"
  20. answer
  21. if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
  22. $MKINITRD
  23. if [ ! -d "/boot/initrd-tree/lib/modules/$KERNEL" ];then
  24. echo -e "\nWARNING! the initrd may failed to create\n"
  25. echo " The initrd may failed to create." >>$TMPDIR/error.log
  26. fi
  27. fi
  28. fi
  29. fi
  30. if [ -e /boot/efi/EFI/Slackware/elilo.conf ];then
  31. echo -e "\nFound elilo. Copying files to EFI partition"
  32. COPYDONE=""
  33. for tocopy in vmlinuz vmlinuz-generic vmlinuz-huge `basename $INITRD`;do
  34. if [ -e /boot/$tocopy ]&&[ -e /boot/efi/EFI/Slackware/$tocopy ]&&grep -E -q "= *$tocopy *$" /boot/efi/EFI/Slackware/elilo.conf ;then
  35. echo "Do you want to copy $tocopy to EFI partition? (Y/n)"
  36. answer
  37. if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
  38. cp -v /boot/$tocopy /boot/efi/EFI/Slackware/$tocopy && COPYDONE="$COPYDONE $tocopy"
  39. touch -r /boot/$tocopy /boot/efi/EFI/Slackware/$tocopy
  40. fi
  41. fi
  42. done
  43. if [ -z "$COPYDONE" ];then
  44. echo -e "\nWARNING! no files copied. You have to fix bootloader yourself\n"
  45. echo " No files copied to the EFI partition found. Fix it yourself" >>$TMPDIR/error.log
  46. fi
  47. elif [ -x /sbin/lilo ]&&[ -e /etc/lilo.conf ]; then
  48. echo -e "\nFound lilo. Do you want to run now: /sbin/lilo ? (Y/n)"
  49. answer
  50. if [ "$ANSWER" != "n" ] && [ "$ANSWER" != "N" ]; then
  51. if ! /sbin/lilo -t ;then
  52. echo "You need to fix your lilo configuration. Then press return to continue."
  53. read
  54. fi
  55. /sbin/lilo -v
  56. fi
  57. elif [ -e /boot/grub ]&&[ -x /usr/sbin/grub-install ];then
  58. echo -e "\nWARNING! Grub found but not supported by slackpkg. You have to fix it yourself\n"
  59. echo " Grub found but not supported by slackpkg. You have to fix it yourself" >>$TMPDIR/error.log
  60. else
  61. echo -e "\nWARNING! slackpkg can't found your bootloader configuration. You have to fix it yourself\n"
  62. echo " slackpkg can't found your bootloader configuration. You have to fix it yourself" >>$TMPDIR/error.log
  63. fi
  64. fi
  65. fi
  66. }