Mercurial > hg > zsh-env
view removeKernel @ 188:757255b99cff default tip
Der Pfad von nano hat sich geƤndert
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Tue, 14 Mar 2023 07:19:52 +0100 |
parents | 249b37a8c917 |
children |
line wrap: on
line source
#!/bin/bash if [ `whoami` != "root" ]; then echo "$0 must be run as root!" exit 1 fi if [ $# -lt 3 ]; then echo "usage: $0 <major minor micro [revision], e.g. 2 6 21 r4>" exit 1 fi MAJOR=$1 MINOR=$2 MICRO=$3 if [ $# -gt 3 ]; then REVISION=$4 fi FULL_VERSION="${MAJOR}.${MINOR}.${MICRO}" if [[ "${REVISION}" != "" ]]; then FULL_VERSION="${FULL_VERSION}-${REVISION}" fi ARCH=`uname -m` if [ "$ARCH" = "i686" ]; then ARCH="x86" fi KERNEL_FLAVOR="" KERNEL_EBUILD="vanilla-sources" if [[ "$(grep gentoo-sources /var/lib/portage/world)" != "" ]]; then KERNEL_FLAVOR="-gentoo" KERNEL_EBUILD="gentoo-sources" fi LOGFILE=/tmp/removeKernel-$$.log # unmerge the kernel cd /usr/src KERNEL_DIR="linux-${MAJOR}.${MINOR}.${MICRO}${KERNEL_FLAVOR}" if [[ "${REVISION}" != "" ]]; then KERNEL_DIR="${KERNEL_DIR}-${REVISION}" fi if [[ -d $KERNEL_DIR ]]; then KERNEL_NAME="${KERNEL_EBUILD}-${FULL_VERSION}" echo "unmerge kernel $KERNEL_NAME" >> $LOGFILE 2>&1 emerge --unmerge $KERNEL_NAME >> $LOGFILE 2>&1 echo "remove $KERNEL_DIR" >> $LOGFILE 2>&1 rm -r $KERNEL_DIR >> $LOGFILE 2>&1 fi # remove modules cd /lib/modules LIB_DIR="${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}" if [[ -d ${LIB_DIR} ]]; then echo "remove modules from $(pwd)/${LIB_DIR}" >> $LOGFILE 2>&1 rm -r ${LIB_DIR} >> $LOGFILE 2>&1 fi # remove the kernel and stuff, check if /boot is mounted first MOUNTED=`mount | grep /boot` if [ "$MOUNTED" = "" ]; then echo "mount /boot" >> $LOGFILE 2>&1 mount /boot >> $LOGFILE 2>&1 fi cd /boot SYSTEM_MAP="System.map-${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}" if [[ -f ${SYSTEM_MAP} ]]; then rm ${SYSTEM_MAP} >> $LOGFILE 2>&1 fi if [[ -f ${SYSTEM_MAP}.old ]]; then rm ${SYSTEM_MAP}.old >> $LOGFILE 2>&1 fi INITRAMFS="initramfs-${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}.img" if [[ -f ${INITRAMFS} ]]; then rm ${INITRAMFS} >> $LOGFILE 2>&1 fi if [[ -f ${INITRAMFS}.old ]]; then rm ${INITRAMFS}.old >> $LOGFILE 2>&1 fi KERNEL="vmlinuz-${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}" if [[ -f $KERNEL ]]; then rm $KERNEL >> $LOGFILE 2>&1 fi if [[ -f $KERNEL.old ]]; then rm $KERNEL.old >> $LOGFILE 2>&1 fi cd /var/tmp/genkernel INITRAMFS="initramfs-${ARCH}-${FULL_VERSION}${KERNEL_FLAVOR}-${ARCH}" if [[ -f ${INITRAMFS} ]]; then rm ${INITRAMFS} >> $LOGFILE 2>&1 fi # if we got until here, just remove the logfile again rm $LOGFILE