#!/bin/sh # $Id: installkernel,v 1.2 2004/05/07 17:16:41 at Exp $ #-------------------------------------------------------------------- # Copyright (C) 2000, 2002 by MandrakeSoft, # Chmouel Boudjnah , # Redistribution of this file is permitted under the terms of the GNU # Public License (GPL) #-------------------------------------------------------------------- # Copyright (C) 2003, 2004 by ALT Linux Team, # Alexey Tourbin . #-------------------------------------------------------------------- # description: Install a kernel to /boot and add an entry for grub and lilo : ${INSTALLKERNEL_CONFIG:=/etc/sysconfig/installkernel} if [ -f "$INSTALLKERNEL_CONFIG" ]; then . "$INSTALLKERNEL_CONFIG" fi if [ -n "$DURING_INSTALL" ]; then echo "$0: DURING_INSTALL=$DURING_INSTALL; supposed to run later" 1>&2 exit 0 fi usage() { cat <&2 Usage: $0 [options] KERNEL_VERSION -n, --nolaunch don't launch lilo; -R, --remove remove bootloader entry and prepare to remove kernel; -m, --memtest it's all about memtest86, not Linux kernel; -h, --help this help. EOF [ -n "$1" ] && exit "$1" || exit 2 } LEGACY=algyNdsSCiLc ARGV=`getopt -n "$0" -o nRmh$LEGACY -l nolaunch,remove,memtest,help -- "$@"` || usage eval set -- "$ARGV" while :; do case "$1" in -n|--nolaunch) NOLAUNCH=$1; shift ;; -R|--remove) REMOVE=$1; shift ;; -m|--memtest) MEMTEST=$1; shift ;; -h|--help) shift; usage 0 ;; --) shift; break ;; -[$LEGACY]) echo "$0: legacy option $1 ignored" >&2 ;; *) echo "$0: unrecognized option: $1" >&2; exit 1 ;; esac done VERSION="$1" : ${BOOTDIR:=/boot} if OLD_KERNEL=`realpath "$BOOTDIR/vmlinuz" 2>/dev/null`; then OLD_VERSION="${OLD_KERNEL##*/vmlinuz-}" fi cd "$BOOTDIR" if [ -z "$REMOVE" -a -z "$MEMTEST" ]; then ln -snf "vmlinuz-$VERSION" vmlinuz ln -snf "initrd-$VERSION.img" initrd.img if [ -z "${VERSION##*-up-*}" ]; then ln -snf "vmlinuz-$VERSION" vmlinuz-up ln -snf "initrd-$VERSION.img" initrd-up.img fi if [ -z "${VERSION##*-smp-*}" ]; then ln -snf "vmlinuz-$VERSION" vmlinuz-smp ln -snf "initrd-$VERSION.img" initrd-smp.img fi elif [ -z "$MEMTEST" ]; then rm -f "initrd-$VERSION.img" fi cd - : ${LILO_CONF:=/etc/lilo.conf} : ${GRUB_MENU_LST:=$BOOTDIR/grub/menu.lst} : ${GRUB_DEVICE_MAP:=$BOOTDIR/grub/device.map} : ${PERL:=/usr/bin/perl} : ${LILO:=/sbin/lilo} : ${DETECTLOADER:=/usr/sbin/detectloader} : ${MKINITRD:=/sbin/mkinitrd} # make initrd "$MKINITRD" -f --ifneeded "$BOOTDIR/initrd-$VERSION.img" "$VERSION" # check perl if [ ! -x "$PERL" ]; then echo "$0: warning: $PERL not available; supposed to run manually..." PERL="echo $PERL" fi # modify lilo config if [ -f "$LILO_CONF" -a -x "$sharfile/lilo" ]; then if [ -z "$REMOVE" -a -z "$MEMTEST" -a -n "$OLD_VERSION" ]; then "$PERL" "$sharfile/lilo" "$OLD_VERSION" fi "$PERL" "$sharfile/lilo" $MEMTEST $REMOVE "$VERSION" fi # modify grub config if [ -f "$GRUB_MENU_LST" -a -f "$GRUB_DEVICE_MAP" -a -x "$sharfile/grub" ]; then if [ -z "$REMOVE" -a -z "$MEMTEST" -a -n "$OLD_VERSION" ]; then "$PERL" "$sharfile/grub" "$OLD_VERSION" fi "$PERL" "$sharfile/grub" $MEMTEST $REMOVE "$VERSION" fi # launch lilo if [ -z "$LOADER" -a -x "$DETECTLOADER" ]; then LOADER=`$PERL $DETECTLOADER -q` fi if [ "$LOADER" = LILO -a -z "$NOLAUNCH" ]; then "$LILO" >/dev/null ||: fi