#!/bin/sh # # Install new world and kernel built in /usr/src. This should be done in # single user mode, or at least on a very quiet system. Presumes system # has been built using update_fbsd # # Note that this does not follow the best recommended procedure, which # involves installing and booting the new kernel before installing the new # world. The risk is that a broken world will render a system unbootable # with both new and old kernel. Caveat emptor. See the FreeBSD Handbook and # /usr/src/UPDATING for more details. # # The latest version of this script and its companion, update_fbsd can be # found in http://halplant.com:88/software/FreeBSD/scripts/ # My kernel config file and sup files, along with other system config # files can be found in http://halplant.com:88/server/config/ # # (c) 2000-2004 Andrew J. Caines Redistribution and modification are welcome, # with proper attribution. No warranty. No money back. You broke it. export PATH=/usr/bin:/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin # Make all directories and kernel config redefinable on invocation ProgName=$(basename $0) SrcDir=${SrcDir:-/usr/src} ObjDir=${ObjDir:-/usr/obj} BaseDir=${BaseDir:-/usr/local/etc/csup} Kernel=${Kernel:-$(hostname -s | tr [:lower:] [:upper:])} # Syslog logging options for logger LoggerOpts="-i -t $ProgName" # Default is "-p user.notice" # Only install if we have a corresponding kernel build log KernelLog=$BaseDir/log/buildkernel_????-??-??.log if [ -f $KernelLog ] then Date=$(echo $KernelLog | cut -d_ -f2 | cut -d. -f1) else echo "No kernel build log. Aborting." >&2 exit 1 fi # Date the log files based on the kernel build, not today InstallLog=$BaseDir/log/installworld_$Date.log KernelLog=$BaseDir/log/installkernel_$Date.log install_world() { cd $SrcDir logger $LoggerOpts 'Starting install of world. Log file '$InstallLog make installworld 1> $InstallLog 2>&1 && logger $LoggerOpts 'Finished install of world. Log file '$InstallLog } install_kernel() { cd $SrcDir logger $LoggerOpts 'Starting install of kernel. Log file '$KernelLog make installkernel KERNCONF=$Kernel 1> $KernelLog 2>&1 && logger $LoggerOpts 'Finished install of kernel. Log file '$KernelLog echo "************************************" echo "* Don't forget to run mergemaster! *" echo "************************************" } case $1 in world) install_world ;; kernel) install_kernel ;; '') install_world && install_kernel ;; *) echo "Usage: $0 (world|kernel)" >&2 ;; esac