FreeBSD Kernel config and compile script

  • Embedded Gallery2 is not available.
  • Embedded Gallery2 is not available.

FreeBSD Kernel config and compile script

Change KERNEL_CONFIG to point at the name of your kernel configuration file and run.
No real checking that you are allowed to do the things in this script so there is the potential for it to fail at some point and no account is taken of this.

It is still very much worth reading the handbook page on compiling a custom kernel, this just makes it easier to repeatedly compile the kernel for testing.

KERNEL_CONFIG='IONODE'
CONF_DIR='/usr/src/sys/i386/conf'
CONFIG_TOOL='/usr/sbin/config'

#edit the KERNEL config file
ee $CONF_DIR/$KERNEL_CONFIG

cd $CONF_DIR
$CONFIG_TOOL $KERNEL_CONFIG
cd ../../compile/$KERNEL_CONFIG
pwd

#inquire as to the users intentions
echo -n "Do you wish to compile and install the custom kernel now? [y/N]?"
read compile_kern_flag

#check to see if nothing was entered by the user
if [ -z "$compile_kern_flag" ]
then
  echo "Not compiling"
else
  #if we got an answer from the user then test it.
  if [ $compile_kern_flag = "y" ]
  then
    #clean up from previous kernel compiles
    make clean
    
    #make system dependencies
    make depend
    
    #build the kernel
    make
    
    #install the kernel
    make install
  fi
fi

#inquire as to the users intentions
echo "Do you wish to reboot now? [y/N]?"
read reboot_flag

#check to see if nothing was entered by the user
if [ -z "$reboot_flag" ]
then
  echo "Not rebooting"
else
  #if we got an answer from the user then test it.
  if [ $reboot_flag = "y" ]
  then
    echo "Attempting reboot"
    shutdown -r now
  else
    echo "Not rebooting"
  fi
fi