#!/bin/sh <<@ LILO QUICK INSTALLATION ----------------------- This installation script installs LILO and generates the configuration file /etc/lilo.conf. It uses safe defaults for most configuration options. Please read the documentation (preferably the more complete LaTeX version, doc.tex) before making changes to the configuration generated by QuickInst. To run QuickInst, simply type ./QuickInst If the normally used root partition is mounted below root (e.g. during system installation), set the environment variable ROOT to the name of the directory on which the root partition is mounted and run QuickInst, e.g. ROOT=/root ./QuickInst A subshell can be spawned at each prompt. Type ! to get an interactive shell that has to be left with exit . Type !command args ... to execute a command and immediately return to QuickInst. QuickInst can only be used to install LILO on IDE (AT-BUS) or SCSI hard disks. The LILO version must be 15 or later, the kernel should be 0.99pl12 or later. Owners of some disk adapters may have to create a DISK section (see section "Disk geometry" in the accompanying documentation) to describe the disk geometry. WARNING: QuickInst may get confused if you're running it in a directory that contains a mixture of old and new LILO distributions. To be safe, always extract new LILO distributions in their own, new directory. ------------- End of description. What follows is program code. ------------- @ CFG_SUFFIX=/etc CFG_DIR=$ROOT$CFG_SUFFIX CFG_FILE=$CFG_DIR/lilo.conf BOOT_SUFFIX=/boot BOOT_DIR=$ROOT$BOOT_SUFFIX SBIN_DIR=$ROOT/sbin locate() { var=$1 while shift && [ ! -z "$1" ]; do for p in `echo $PATH | sed 's/:/ /g'`; do if [ -x $p/$1 ]; then eval $var=$p/$1 return 0 fi done done return 1 } probe() { [ ! -z "`dd if=$1 bs=1 count=1 2>/dev/null | tr '\0' x`" ] return } bootflag() { [ "XY" = "`(dd of=/dev/null bs=510 count=1; dd bs=2 count=1 | tr -c '\125\252' . | tr '\125\252' XY) <$1 2>/dev/null`" ] return } krnltype() { if [ "YX" = "`(dd bs=2 count=1 | tr -c '\001\013' . | tr '\001\013' XY) \ <$1 2>/dev/null`" ]; then echo compound else echo image fi } get() { while true; do echo -n "$1 " if [ -z "$3" ]; then echo -n "(no default) " else echo -n "[$3] " fi read line line="`echo "$line" | sed 's/^ *\([^ ]\(\|.*[^ ]\)\) *$/\1/'`" if [ -z "$line" ]; then if [ -z "$3" ]; then echo "No default, please specify a value." continue fi line=$3 fi if [ "x$line" = "x!" ]; then cat </dev/null; then sh -c "`echo \"$line\" | sed 's/^!//'`" else eval $2="$line" break fi done } yesno() { while true; do get "$1" line $2 if echo "$line" | egrep -i '^y(|e(|s))$' >/dev/null; then return 0 fi if echo "$line" | egrep -i '^no?$' >/dev/null; then return 1 fi echo "YES or NO, please." done } echo if [ $ROOT/etc/lilo = `pwd` ]; then cat </dev/null; then : ; else echo "You probably have to be root to install LILO." echo if yesno "Try to install LILO anyway ?" no; then : ; else echo exit 1 fi echo fi badlib="" if [ "`echo 'X(Y)' | sed 's/\(X\)(Y)/\1/'`" != "X" ]; then echo "Your sed doesn't behave like sed." badlib=y fi if [ "`echo 'X(Y)' | grep '^X(Y)'`" != "X(Y)" ]; then echo "Your grep doesn't behave like grep." badlib=y fi if [ "`echo 'X(Y)' | egrep '^(X)\(Y\)'`" != "X(Y)" ]; then echo "Your egrep doesn't behave like egrep." badlib=y fi if [ ! -z "$badlib" ]; then echo "Your libraries might be broken." echo exit 1 fi cat </dev/null; then boot=$root fi cat </dev/null; then if probe "$inp"; then boot=$inp break else cat </dev/null | \ tr -c 'LIO' '?'`" = "LILO" ]; then cat </dev/null` newboot="" if [ $boot != "$oldboot" -a ! -z "`echo "$boot" | sed 's|'$dev'/[sh]d.||'`" ]; then echo if [ -z "$oldboot" ]; then echo "There's no active partition on $disk" msg="Activate $boot ?" else echo "Currently active partition of $disk is $oldboot" msg="Change it to $boot ?" fi if yesno "$msg"; then newboot=`echo $boot | sed 's,'$dev'/[sh]da,,'` cat </dev/null; then kernel=$inp break else echo "Use only absolute path names, e.g. /linux" fi else echo "No such file." fi done cat <$CFG_FILE.tmp # LILO configuration created by QuickInst 20 `date | tr -s x ' '` boot = $boot compact delay = 5 # optional, for systems that boot very quickly vga = normal # force sane state root = current # use "current" root `krnltype $kernel` = $kernel EOF if [ "`echo $kernel | sed 's,/\([^/]*\)$,\1,'`" != "linux" ]; then echo " label = linux" >>$CFG_FILE.tmp fi echo if yesno "Define additional kernels ?"; then default="" for n in $kernel.old /vmlinux.old /boot/vmlinuz.old /linux.old \ /boot/linux.old /zImage.old /boot/zImage.old; do if [ -f $ROOT/$n ]; then default=$n break fi done cat </dev/null; then echo "`krnltype $inp` = $inp" >>$CFG_FILE.tmp if [ ! -f $ROOT$inp ]; then echo "File doesn't exist now. - Making entry optional." echo " optional" >>$CFG_FILE.tmp fi else echo "Use only absolute path names, e.g. /linux" fi default="done" done fi if [ "$boot" = "$first" ]; then cat </dev/null; then if probe "$inp"; then if bootflag $inp; then loader="" if echo "$inp" | egrep "^${second}[1-4]\$" >/dev/null; then echo "It's on your second disk. Is this ..." if yesno "... OS/2 ?"; then loader="os2_d.b" else if yesno "... OS using the BIOS (e.g. DOS) ?"; then loader="any_d.b" fi fi fi ( echo "other = $inp" echo -n " table = " echo $inp | sed 's/[1-4]$//' if [ ! -z "$loader" ]; then echo " loader = $BOOT_DIR/$loader" fi ) >>$CFG_FILE.tmp get "Label" inp $default_lbl default_lbl="" default="done" echo " label = $inp" >>$CFG_FILE.tmp else echo "$inp does not have a valid boot signature." fi else cat <&1 then : ; else touch $errflag fi ) | tee $outfile if [ -f $errflag ]; then rm $errflag if egrep 'geo_query_dev HDIO_|: Got bad geometry' <$outfile >/dev/null then cat </dev/null; then cat <