You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2KB

  1. #!/bin/sh
  2. PATH=/usr/bin:/bin
  3. if [ -z "$1" ]; then
  4. echo "usage: $0 <version> <suffix>"
  5. exit 1
  6. fi
  7. name="$1"
  8. if [ -n "$2" ]; then
  9. name="$1-$2"
  10. fi
  11. tmpd=/tmp/_boot_$name.backup
  12. mkdir $tmpd
  13. echo "Backing up /boot to $tmpd..."
  14. cp -r /boot/* $tmpd/
  15. current_initramfs=`find /boot -maxdepth 1 -type f |grep "\.img" |cut -d'/' -f3`
  16. current_kernel=`find /boot -maxdepth 1 -type f |grep -v "$current_initramfs" |grep -v '\.keep' |cut -d'/' -f3`
  17. echo "Replacing '$current_kernel' and '$current_initramfs'..."
  18. find /boot -maxdepth 1 -type f |grep -v "\.keep" |xargs rm -f
  19. echo "Kernel copy to '/boot/kernel-$name'"
  20. cp /usr/src/linux/arch/x86_64/boot/bzImage /boot/kernel-$name
  21. dra=`dracut --kernel-image /boot/kernel-$name -m "rootfs-block base" --no-kernel --force 2>&1 |grep "initramfs\(.*\)done" |cut -d'/' -f3 |cut -d"'" -f1`
  22. if [ -n "$dra" ]; then
  23. mv "/boot/$dra" "/boot/initramfs-$name.img"
  24. echo "Initramfs 'initramfs-$name.img' installed"
  25. else
  26. echo "Error@dracut"
  27. exit
  28. fi
  29. echo "Replacing grub entries.."
  30. sed -i "s/$current_initramfs/initramfs-$name.img/g" /boot/grub/grub.cfg
  31. sed -i "s/$current_kernel/kernel-$name/g" /boot/grub/grub.cfg
  32. echo "grub entries replaced"
  33. echo "should be good!"