#!/bin/sh # # Local version: 0.9.1 # Copyright (c) 2008 Peter Kuyarov, All rights reserved # Thu Feb 21 08:20:52 MST 2008 # script to automate build/install kernel/world # scripts@pknet.net # # all work is done at end of file, first are all functions # type 'buildworld.sh help' for usage info # # scripts@pknet.net # http://peterk.org/scripts/ # export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/usr/local/vpopmail/bin:/root/bin # # user configurable variables # default kernel config file is hostname but in all caps # default [kernel=`hostname -s | tr '[a-z;]' '[A-Z.]'`] # kernel=`hostname -s | tr '[a-z;]' '[A-Z.]'` # #build stuff faster # default [makecmd='make -j4'] # makecmd='make -j4' # # log file of build status # default [/var/log/buildworld_log] # buildworld_log=/var/log/buildworld.log # # end user configurable variables # #functions for buildworld help() { printf "Usage:\n" printf " buildworld.sh [and one or more of the following options:] \n" printf " rmobj\n" printf " buildworld [does NOT rmobj]\n" printf " buildkernel\n" printf " installkernel\n" printf " installworld\n" printf " buildall [build world and kernel-does rmobj]\n" printf " installall [install kernel and world]\n" printf " If using more than one option, they should be in order\n" exit 1 } warning_msg() { echo "$1" echo "Press ctrl+c to cancel" count=5 while [ $count -gt 0 ] do printf " $count " count=$(($count-1)) sleep 1 done printf " 0 \n" } rmobj() { cd /usr/obj && \ touch /usr/obj/JUNK && \ rm -rf /usr/obj/* && \ echo RMOBJ - `date` >> $buildworld_log } buildworld() { if [ `ls /usr/obj | wc -l` -gt 0 ] then warning_msg " Appears /usr/obj has objects You should probably do 'rmobj' first" fi cd /usr/src && \ $makecmd buildworld && \ echo BUILD - `date` >> $buildworld_log } buildkernel() { cd /usr/src && \ $makecmd buildkernel KERNCONF=$kernel && \ echo BKERNEL - `date`>>$buildworld_log } installkernel() { cd /usr/src && \ $makecmd installkernel KERNCONF=$kernel && \ echo IKERNEL -`date`>>$buildworld_log } installworld() { cd /usr/src && \ $makecmd installworld && \ echo INSTALL - `date` >> $buildworld_log } buildall() { rmobj buildworld buildkernel } installall() { installkernel installworld } # test arguments, do work if [ $# -lt 1 ] then help fi if [ $# -gt 0 ] then $1 && $2 && $3 && $4 && $5 || ( printf "\nError - '$0 $*' failed\n"; help ) fi