#!/bin/bash set -e set -u GRUBCFG=/etc/grub.d/40_custom # initramfs state directory (Debian/Ubuntu) INITRAMFS_STATEDIR="/var/lib/initramfs-tools" error() { echo "$@" >&2 exit 1 } if [ $# -ne 1 ] ; then error "Usage: `basename $0` " fi KERN_DIR=$1 if [ ! -d "$KERN_DIR" ] ; then error "Bad kernel directory." fi getversion() { local version version=$(cat $KERN_DIR/include/config/kernel.release) if [ "x" = "x$version" ] ; then error "Could not determine version" fi echo "$version" } moveconfig() { echo "Moving config file to /boot ..." >&2 sudo cp .config /boot/config-$KVERSION echo "done." >&2 } copyvmlinuz() { echo "Copying vmlinuz to /boot ..." >&2 sudo cp "$KERN_DIR/arch/x86/boot/bzImage" /boot/vmlinuz-$KVERSION echo "done." >&2 } doinitramfs() { local initrdimage initrdimage="/boot/initrd.img-$KVERSION" if [ -e "$INITRAMFS_STATEDIR/$KVERSION" -o -e "$initrdimage" ] ; then echo "Removing old initramfs ... " >&2 sudo update-initramfs -k $KVERSION -d echo "done." >&2 fi echo "Creating initramfs (ignore module errors) ... " >&2 sudo update-initramfs -k $KVERSION -c echo "done." >&2 } installgrubmenuentry() { local entryname entryname=$1 sudo tee -a "$GRUBCFG" > /dev/null <&2 # installgrubmenuentry "$entryname" # echo "done." #else # echo "Grub menuentry seems to exist already." >&2 #fi sudo update-grub echo "You need to grub-set-default manually." >&2