home *** CD-ROM | disk | FTP | other *** search
- #! /bin/bash
-
- # Script to create an initial LILO config file.
- #
- # Usage:
- # mk_boot_floppy [root_dir]
- #
- # root_dir: the directory the root partition is mounted to (defaults to "/")
- #
- # Example:
- #
- # mk_boot_floppy /blub
- #
- # As an alternative, specify the root device using the environment variable
- # rootdev; e.g. rootdev=/dev/hda mk_boot_floppy
- #
- # on errors:
- # exit code > 0
- #
- # Version 1.07
- #
- # Author: Steffen Winterfeldt <wfeldt@suse.de>
- # (c) 1999 SuSE GmbH
-
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # general configurable parameters
-
- # the kernel images to use; must be in $boot_dir
- kernel=vmlinuz
-
- # initial ram disks (corresponding to $kernels); dto. in $boot_dir
- initrd=initrd
-
- # if we need an append line (*not* for the frame buffer vga=xxxx argument)
- append=
-
- # for frame buffers; the number *must* be in hex, without any leading 0x
- # e.g. vga=0301
- vga=
-
- # boot floppy image (may be empty -> no floppy created)
- floppy=floppy
-
- # show boot prompt and wait for $prompt/10 seconds (empty -> no prompt)
- prompt=30
-
-
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # adapt these only if needed
-
- syslinux=/usr/sbin/syslinux
-
- # *full* paths
- boot_dir=/boot
-
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # should be nothing to change below...
-
- tmp_msg=/tmp/msg$$
- tmp_boot=/tmp/boot$$
- tmp_mnt=/tmp/mnt$$
- is_mounted=
-
- clean_up () {
- [ "$is_mounted" ] && umount $tmp_mnt
- rm -f $tmp_msg $tmp_boot
- [ -d $tmp_mnt ] && rmdir $tmp_mnt
- }
-
- error () {
- echo "$2"
- clean_up
- exit $1
- }
-
- get_device () {
- x1=`mount 2>/dev/null | grep "on $1 "`
- x2=`echo \`echo "$x1" | wc -l\``
- x3=`echo "$x1" | cut -f 1 -d " "`
-
- if [ "$x2" = 1 -a -b "$x3" ] ; then
- echo "$x3"
- fi
- }
-
- dos_image_144 () {
- [ "$1" ] || return
- (
- echo -ne "\037\213\010\010\226j\2758\002\003tigz\000\223\357\346\340\230"
- echo -ne "\226\265\327\202\211\271\044\223\341\355\215\215\274M\001\042"
- echo -ne "\254\027\276o\274xC@}\203Q\324#\226\200\027L\036\211\047\335\326"
- echo -ne "\044\274\3162\363QHr,\140\022>k\371\364\354\356\263\272\367\037"
- echo -ne "\337\274\352[{\253O\311[3H\356\351\256\370\243j\233f\310\226]"
- echo -ne "_5\343\235\333\363WA2\367E\353\242\212\337\267\037\344a\000\202"
- echo -ne "\3727\217Wn\237s\371\350\332\273\267\331\030F\301(\030\005\243"
- echo -ne "\140\024\014\006\260\357)\353\252\204\007\377\031\032\304\030"
- echo -ne "\000\036\332-\245\015\006\000\000"
- ) | gunzip -c | gunzip -c >$1
- }
-
- root_dir="$1"
- [ "$root_dir" ] || root_dir=/
- if [ -z "$rootdev" ] ; then
- rootdev=`get_device "$root_dir"`
- fi
- [ "$rootdev" ] || error 21 "usage: mk_boot_floppy [root_dir]"
- root_dirx="$root_dir"
- [ "$root_dirx" = / ] && root_dirx=
- echo "using \"$rootdev\" as root device (mounted on \"$root_dir\")"
-
- [ -x $syslinux ] || error 22 "no syslinux installed"
-
- dos_image_144 $tmp_boot
- $syslinux -s $tmp_boot || error 23 "syslinux failed"
-
- k="$root_dirx$boot_dir/$kernel"
- [ -f "$k" ] || error 24 "no kernel image: \"$k\""
- i="$root_dirx$boot_dir/$initrd"
-
- echo -n "creating boot disk \"$root_dirx$boot_dir/$floppy\" for kernel \"$k\", "
-
- if [ -f "$i" ] ; then
- echo "initrd \"$i\""
- else
- echo "no initrd"
- i=
- fi
-
- mkdir $tmp_mnt
- mount -tmsdos -oloop $tmp_boot $tmp_mnt 2>/dev/null || {
- error 25 "failed to mount image"
- }
- is_mounted=1
-
- cp $k $tmp_mnt/linux || error 26 "failed to add kernel"
- [ "$i" ] && {
- cp $i $tmp_mnt/$initrd || error 26 "failed to add initrd"
- }
-
- echo -n >$tmp_msg
- cp $tmp_msg $tmp_mnt/message
-
- xx1=
- [ "$i" ] && xx1=" initrd=$initrd"
- xx2=
- [ "$vga" ] && xx2=" vga=$vga"
- cat <<-blubber >$tmp_msg
- default linux
- append$xx1 rw root=$rootdev$xx2 $append
- display message
- blubber
- if [ "$prompt" ] ; then
- echo "prompt 1" >>$tmp_msg
- echo "timeout $prompt" >>$tmp_msg
- fi
-
- cp $tmp_msg $tmp_mnt/syslinux.cfg || error 26 "failed to add syslinux.cfg"
-
- umount $tmp_mnt
- is_mounted=
-
- cp $tmp_boot $root_dirx$boot_dir/$floppy || error 27 "failed to install boot floppy"
-
- clean_up
-
-