Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/bin/bash
- #######################################################
- # Automatic kernel compilescript with old conf (gentoo)
- # by ZappeL 2011
- #
- # requires root-privileges, awk, sort and a configured
- # kernel is needed
- #######################################################
- LINUX=/usr/src/linux
- NEWEST=$(find /usr/src/ -name 'linux-*-gentoo*' -print | sort -r | grep "" -m1)
- CUR=/usr/src/linux-$(uname -r)
- let JOBS=$(cat /proc/cpuinfo | grep "cpu cores" -m 1 | awk '{print $4}')+1
- echo -en "Checking symlink..."
- if [ -L $LINUX ]; then
- echo -en "\nRemoving old symlink.."
- rm $LINUX
- fi
- if [ ! -L $LINUX ]; then
- echo -e "\t\t\t\t\t\t [ok]"
- else
- echo -e "\t\t\t\t\t\t [error]"
- fi
- echo -en "Creating new symlink for: "$NEWEST".."
- ln -s $NEWEST $LINUX
- if [ -L $LINUX ]; then
- echo -e "\t\t [ok]"
- else
- echo -e "\t\t [error]"
- fi
- echo -en "Checking /boot directory.."
- if [ -d /boot/ ]; then
- echo -en "\nFound /boot directory. \nChecking its contents.."
- let BCNT=$(ls /boot/ | wc -l)-1
- if [ $BCNT -lt 3 ]; then
- echo -en "\nTt seems that the /boot directory is empty. \nTrying to mount it.."
- mount /boot
- let BCNT=$(ls /boot/ | wc -l)-1
- if [ $BCNT -gt 2 ]; then
- echo -e "\t\t\t\t\t\t [ok]"
- else
- echo -e "\t\t\t\t\t\t [error]"
- echo -e "Problem with your /boot direcoty. \nPLEASE CHECK YOUR INSTALLATION!"
- exit
- fi
- else
- echo -e "\t\t\t\t\t\t [ok]"
- fi
- else
- echo -e "\t\t\t\t\t [error]"
- echo -e "No /boot direcoty found.. \nPLEASE CHECK YOUR INSTALLATION!"
- exit
- fi
- echo -en "Getting current .config.."
- if [ -f "$CUR/.config" ];then
- echo -e "\t\t\t\t\t [ok]"
- else
- echo -e "\t\t\t\t\t [error]\nCould not find current config, make sure it is placed in:"
- echo -e $CUR/.config
- exit
- fi
- echo -en "Copying config file.."
- cp $CUR/.config $LINUX >/dev/null 2>&1
- if [ -f $LINUX/.config ];then
- echo -e "\t\t\t\t\t\t [ok]"
- else
- echo -e "\t\t\t\t\t\t [error]\nCould not copy .config to "$LINUX".\nPlease copy the file manually."
- exit
- fi
- echo -e "Preparing to build the kernel.."
- cd $LINUX
- echo -en "Building the Kernel, please standby..."
- BZI=$(make -j$JOBS -s | awk '{print $2}')
- echo -e "\t\t\t\t [ok]"
- echo -en "Checking kernel image.."
- if [ -f $LINUX/$BZI ]; then
- echo -e "\t\t\t\t\t\t [ok]"
- else
- echo -e "\t\t\t\t\t\t [error]\nCoukd not find kernel image!\n Givin up!"
- exit
- fi
- echo -en "Installing the kernel.."
- make -s modules_install
- make -s install
- if [ -e $(find /usr/src/ -name 'linux-*-gentoo*' -print | sort -r | grep '' -m1 | awk '{printf "/boot/vmlinuz%s\n",substr($1,15,255)}') ]; then
- echo -e "\t\t\t\t\t\t [ok]\nInstalltion complete.\nNext step is to check your bootloader configuration or simply reboot the system!"
- else
- echo -e "\t\t\t\t\t\t [error]\nInstallation failed!\nPlease try manual installtion of the kernel."
- fi
- exit
Advertisement
Add Comment
Please, Sign In to add comment