home *** CD-ROM | disk | FTP | other *** search
Text File | 2002-11-06 | 111.8 KB | 4,625 lines |
- #!/bin/sh
- #
- # linuxrc - automatic hardware probing, source mounting and lizard calling
- #
- # Copyright (C) 1999-2001 Ralf Flaxa, Caldera (Deutschland) GmbH,
- # Erlangen, Germany
- #
- # $Id: linuxrc,v 1.239 2001/03/13 12:58:53 rf Exp $
- #
- #
- # Required external binaries still used by this linuxrc:
- # ======================================================
- # agetty
- # bdflushd
- # bootpc
- # cat
- # chmod
- # chown
- # cut
- # date !
- # do_netcalc
- # fgrep
- # freeramdisk
- # get_val
- # gzip
- # gunzip
- # hostname
- # ifconfig
- # insmod
- # kill
- # klogd
- # libc
- # ln
- # losetup
- # lsmod
- # mkdir
- # mknod
- # mount
- # ps
- # rm
- # route
- # sed
- # set_val
- # sh
- # sleep
- # swapon
- # sync
- # sysinfo
- # syslogd
- # touch
- # umount
- # uname
- # updated
- #
- # Required external files still used by this linuxrc:
- # ===================================================
- # /dev/*
- # /etc/fstab
- # /etc/hosts
- # /etc/lizard.cnf
- # /etc/passwd
- # /etc/rc.d/rc.rootfs
-
- #
- # Global settings
- #
- export PATH="/sbin:/usr/sbin:/bin:/usr/bin"
- export TERM=linux
- export BOOT_IMAGE
- export ER_FLAG
- export FORCE_REBOOT=false
- export FORCE_HWINFO=false
- export ANSWER
-
- #
- # parse global variables and configuration for lizard
- #
- . /etc/lizard.cnf
-
- #
- # Functions
- #
-
-
- Debug()
- {
- echo "$@" >> $FILE_LOG_DEBUG
- echo "$@" >> /var/log/lizard
- }
-
-
- Info()
- {
- echo "$@" | sed 's/://g'
- }
-
-
- Error()
- {
- chvt 1
- echo "Error: $@"
- echo "press <return> to abort."
- read ans
- }
-
-
- Panic()
- {
- chvt 1
- echo "Panic: $@" >> /dev/console
- echo "Panic: $@" >> $FILE_LOG_DEBUG
- echo "press <return> to continue or \"sh\" for a shell." >> /dev/console
- echo "press <return> to continue or \"sh\" for a shell." >> $FILE_LOG_DEBUG
- read ans
- if [ "$ans" = "sh" ]; then
- echo "Spawning shell. Press <exit> to continue when done." >> /dev/console
- /bin/sh
- fi
- }
-
-
- Kill_Proc_By_Name()
- {
- local name
- local pids
- local i
-
- for name in $@ ; do
- pids="`ps ax | fgrep "$name" | fgrep -v fgrep | cut -c1-6 `"
- for i in $pids ; do
- sync
- case "$name" in
- "booter")
- kill -15 $i > /dev/null 2>&1
- ;;
- "XF86_VGA16")
- kill -15 $i > /dev/null 2>&1
- sleep 1
- kill -15 $i > /dev/null 2>&1
- ;;
- *)
- kill -1 $i > /dev/null 2>&1
- kill -9 $i > /dev/null 2>&1
- ;;
- esac
- done
- done
- }
-
-
- # simple init replacement
- Respawn_getty()
- {
- case $2 in
- start)
- while [ ! -f /etc/nologin ] ; do
- touch /etc/$1.active
- /sbin/agetty 38400 $1 linux
- done
- rm -f /etc/$1.active
- ;;
- stop)
- touch /etc/nologin
- Kill_Proc_By_Name agetty
- while [ 1 ]; do
- if [ -f /etc/tty$1.active ]; then
- Debug "tty$1 still active, please log out."
- sleep 2
- else
- break
- fi
- done
- ;;
- esac
- }
-
- Unmount_install_partitions()
- {
- local dev
- local mountp
- local rest
- local tries
-
- cd /
- sync
- Debug "unmounting all /mnt/root based filesystems..."
- for tries in 1 2 3 ; do
- while read dev mountp rest ; do
- if `echo $mountp | fgrep /mnt/root >/dev/null` ; then
- umount $mountp
- fi
- done < /proc/mounts
- done
- }
-
- Unmount_All()
- {
- cd /
- sync
- Debug "before unmounting all filesystems..."
- sync
- df >> $FILE_LOG_DEBUG 2>&1
- ps auxww >> $FILE_LOG_DEBUG 2>&1
- Debug "unmounting all filesystems..."
- umount -a >> $FILE_LOG_DEBUG 2>&1
- sync
- umount $DIR_SOURCE/live >> $FILE_LOG_DEBUG 2>&1
- umount $DIR_SOURCE >> $FILE_LOG_DEBUG 2>&1
- umount $DIR_SOURCE_TMP >> $FILE_LOG_DEBUG 2>&1
- umount $DIR_LIZARD >> $FILE_LOG_DEBUG 2>&1
- umount $DIR_TARGET >> $FILE_LOG_DEBUG 2>&1
- umount /mnt >> $FILE_LOG_DEBUG 2>&1
- umount /root >> $FILE_LOG_DEBUG 2>&1
- umount /proc/bus/usb >> $FILE_LOG_DEBUG 2>&1
- # proc is mounted multiple times for some reason
- while umount /proc ; do true ; done >> $FILE_LOG_DEBUG 2>&1
- # try again.
- umount -a >> $FILE_LOG_DEBUG 2>&1
- }
-
-
- Breakpoint()
- {
- local really=false
-
- if [ "X$1" = 'X--force' ]; then
- really=true
- shift 1
- Debug "forced breakpoint: $@"
- fi
- if [ "$ER_FLAG" = "911" ]; then
- Debug "er=911 breakpoint: $@"
- really=true
- fi
- if [ "$really" = "true" ]; then
- Debug "login on tty2 and fix whatever is necessary ;-)"
- Debug "after that switch back to tty5 and press <return> to continue."
- read ans < $FILE_LOG_DEBUG
- Debug "continuing..."
- fi
- }
-
-
- Swapoff_All()
- {
- # release all swap partitions
- for i in `cat /proc/swaps | sed '1d' | cut -d' ' -f 1` ; do
- swapoff $i
- done
- }
-
-
- Mini_init()
- {
- local i
-
- case $1 in
- boot)
- mount /proc
- # disable screen blank
- echo "]"
-
- updated &
- bdflushd &
-
- mount -n -o rw,remount /
- rm -f /fastboot
- rm -f /etc/mtab*
- mount -avt nonfs,nomsdos,nohpfs >> $FILE_LOG_DEBUG 2>&1
- swapon -a
- rm -f /var/lock/LCK*
- rm -f /var/run/*
- rm -rf /tmp; mkdir /tmp; chmod 1777 /tmp
- touch /var/run/utmp
- chmod 644 /var/run/utmp
-
- # preparing modules area
- for i in kernel/drivers/block \
- kernel/drivers/cdrom \
- kernel/drivers/net \
- kernel/drivers/ide \
- kernel/drivers/parport \
- kernel/drivers/pnp \
- kernel/drivers/sound \
- kernel/drivers/scsi \
- kernel/drivers/usb \
- kernel/net/sunrpc \
- kernel/fs \
- pcmcia ; do
- mkdir -p /lib/modules/`uname -r`/$i
- done
-
- if [ -x /sbin/syslogd ]; then
- /sbin/syslogd
- fi
- if [ -x /sbin/klogd ]; then
- /sbin/klogd
- fi
-
- hostname noname
-
- # Allow logins
- rm -f /etc/nologin
-
- # allow emergency handling
- # prepare command line parsing
- rm -f /tmp/cmdline
- for i in `cat /proc/cmdline` ; do
- echo $i >> /tmp/cmdline
- done
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep 911`" ]; then
- ER_FLAG=911
- fi
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep hwinfo`" ]; then
- FORCE_HWINFO="true"
- fi
- ;;
- multi)
- if [ -z "`sed -n '/^lizard=/s/^lizard=//p' /tmp/cmdline`" \
- -o "$ER_FLAG" = "911" ]; then
- # jwc
- Respawn_getty tty2 start &
- Respawn_getty tty3 start &
- fi
- ;;
- single)
- Respawn_getty tty2 stop
- Respawn_getty tty3 stop
- ;;
- shutdown)
- # FIXME: in case of any trouble or a cmdline switch save initrd
- if [ "$ER_FLAG" = "911" ]; then
- Prepare_save_initrd
- fi
- Prepare_free_initrd
- Kill_Proc_By_Name cardmgr
- Kill_Proc_By_Name nfsiod syslogd klogd updated
- echo "2" > /proc/sys/kernel/printk
- Swapoff_All
- Unmount_All
- ;;
- esac
- }
-
-
- Install_aborted()
- {
- local ans
-
- chvt 7
- $CMD_BOOTER add_menu "T4 Oops! Desktop/LX installation failed!"
- $CMD_BOOTER add_menu "T5 Please refer to the printed documentation."
- $CMD_BOOTER add_menu "T6 Press <return> for more information."
- $CMD_BOOTER show
- read ans < /dev/tty7
-
- # Kill $CMD_BOOTER for now (until $CMD_BOOTER can handle dialogs)
- Kill_Proc_By_Name booter
-
- # Force writing a hwinfo file in case of install failure
- FORCE_HWINFO="true"
-
- # Force a reboot over a initrd quit
- FORCE_REBOOT=true
-
- # tell them what happened and how to proceed
- while [ 1 ]; do
- echo "c" > /dev/tty1
- chvt 1
- cat << EOF
-
- The Lycoris install wizard was unable to install Desktop/LX on your
- system. One possible reason is that your hardware is not (yet) supported
- by Desktop/LX. Please visit http://www.lycoris.com/ for newer versions of
- Desktop/LX.
-
- Please insert a formatted floppy and type "hwinfo". This will write an
- install report to your floppy in a file called hwinfo0.txt. Edit this
- file, adding some comments about your hardware, and e-mail it to
- hwinfo@lycoris.com. This information provides valuable feedback for us
- and will allow us to try to support your hardware in future versions
- of Desktop/LX. Please watch our web site for updates and new versions.
-
- To write the install report to a floppy type "hwinfo".
- To spawn a shell type "sh".
- To reboot your system type "reboot".
-
- EOF
- echo -n "Your choice: "
- read ans
- echo
- if [ "$ans" = "hwinfo" ]; then
- Write_hwinfo
- elif [ "$ans" = "reboot" ]; then
- break
- elif [ "$ans" = "sh" ]; then
- /bin/sh
- else
- echo "Error: invalid answer"
- sleep 3
- fi
- done
- return 0
- }
-
-
- Lizard_File_Glob()
- {
- local script="$1"
- local eth0_ip="$2"
- local eth0_net="$3"
-
- local lizarddir=$DIR_LIZARD
-
- if [ "`echo $script | cut -c 1,1`" = '/' ]; then
- lizarddir=
- fi
-
- if [ -f $lizarddir/${script}.${eth0_ip} ]; then
- echo "$lizarddir/${script}.${eth0_ip}"
- else
- if [ -f $lizarddir/${script}.${eth0_net} ]; then
- echo "$lizarddir/${script}.${eth0_net}"
- else
- if [ -f $lizarddir/${script} ]; then
- echo "$lizarddir/${script}"
- else
- return 1
- fi
- fi
- fi
- return 0
- }
-
-
- Autoget_Lizard_Config()
- {
- local eth0_ip=""
- local eth0_mask=""
- local nfs_server1_ip=""
- local nfs_server1_path=""
-
- local eth0_net=""
-
- local lizarddir=$DIR_LIZARD
- local rulesfile=$lizarddir/rules
- local lizard_line
- local lizard_dev=""
-
- local dummy
-
- # those are the filenames used in and parsed out of the rules file
- local start_script
- local profile
- local xconfig
- local pkgsel
- local fsinfo
- local finish_script
-
- # check whether we actually WANT a lizard install
- lizard_line="`sed -n '/^lizard=/s/^lizard=//p' /tmp/cmdline`"
- if [ -z "$lizard_line" ]; then
- Debug "no lizard mode requested"
- return 0
- fi
-
- # check whether we overwrote the lizard location
- if [ "$lizard_line" = "floppy" ]; then
- lizard_dev="/dev/fd0H1440"
- elif [ -n "`echo $lizard_line | sed -n '/:/p'`" ]; then
- nfs_server1_ip="`echo $lizard_line | cut -d':' -f 1`"
- nfs_server1_path="`echo $lizard_line | cut -d':' -f 2`"
- # If NFS install then use defaults for lizard config location
- if [ -n "$1" -a "$1" != "none" ]; then
- eth0_ip="$1"
- eth0_mask="$2"
- eth0_net="`do_netcalc -n ${eth0_ip} ${eth0_mask}`"
- fi
- elif [ "$lizard_line" = "auto" ]; then
- # If NFS install then use defaults for lizard config location
- if [ -n "$1" -a "$1" != "none" ]; then
- eth0_ip="$1"
- eth0_mask="$2"
- nfs_server1_ip="$3"
- nfs_server1_path="`dirname $4`/lizard"
- eth0_net="`do_netcalc -n ${eth0_ip} ${eth0_mask}`"
- fi
- else
- lizard_dev="$lizard_line"
- fi
-
- # look for lizard data
- Debug "trying to mount lizard dir ... "
- mkdir -p $lizarddir
- if [ -n "$lizard_dev" ]; then
- if [ "$lizard_dev" = "/dev/fd0H1440" ]; then
- chvt 4
- echo > /dev/tty4
- echo -n "Please insert config floppy for LIZARD unattended install and press return." > /dev/tty4
- read ans < /dev/tty4
- chvt 7
- fi
- Debug "Trying mount -o ro -t ext2 $lizard_dev $lizarddir ..."
- umount $lizard_dev > /dev/null 2>&1
- mount -o ro -t ext2 $lizard_dev $lizarddir > /tmp/lizardmountout 2> /tmp/lizardmounterr || return 1
- else
- Debug "mount -o ro,bg,intr,nolock -t nfs ${nfs_server1_ip}:${nfs_server1_path} $lizarddir ..."
- mount -o ro,bg,intr,nolock -t nfs ${nfs_server1_ip}:${nfs_server1_path} $lizarddir > /tmp/lizardmountout 2> /tmp/lizardmounterr || return 1
- fi
- if [ ! -f $rulesfile ]; then
- Debug "no rules file found"
- umount $lizarddir > /dev/null 2>&1
- return 1
- fi
- # parse rules file for hostname entry
- sed -n "/^hostname[ ]*${eth0_ip}[ ]*/p" $rulesfile > /tmp/rules
- if [ -s /tmp/rules ]; then
- Debug "found hostname match in rules file"
- else
- # parse rules file for network entry
- sed -n "/^network[ ]*${eth0_net}[ ]*/p" $rulesfile > /tmp/rules
- if [ -s /tmp/rules ]; then
- Debug "found network match in rules file"
- else
- # parse rules file for floppy entry
- sed -n "/^floppy[ ]*/p" $rulesfile > /tmp/rules
- if [ -s /tmp/rules ]; then
- Debug "found floppy match in rules file"
- else
- Debug "no match in rules file found"
- return 1
- fi
- fi
- fi
- read dummy dummy start_script profile xconfig pkgsel fsinfo finish_script < /tmp/rules
- Debug "FILE_LIZARD_START=$start_script"
- FILE_LIZARD_START="`Lizard_File_Glob $start_script $eth0_ip $eth0_net`"
- Debug "actual FILE_LIZARD_START=$FILE_LIZARD_START"
- Debug "FILE_LIZARD_PROFILE=$profile"
- FILE_LIZARD_PROFILE="`Lizard_File_Glob $profile $eth0_ip $eth0_net`"
- Debug "actual FILE_LIZARD_PROFILE=$FILE_LIZARD_PROFILE"
- Debug "FILE_LIZARD_XCONFIG=$xconfig"
- FILE_LIZARD_XCONFIG="`Lizard_File_Glob $xconfig $eth0_ip $eth0_net`"
- Debug "actual FILE_LIZARD_XCONFIG=$FILE_LIZARD_XCONFIG"
- Debug "FILE_LIZARD_PKGS=$pkgsel"
- FILE_LIZARD_PKGS="`Lizard_File_Glob $pkgsel $eth0_ip $eth0_net`"
- Debug "actual FILE_LIZARD_PKGS=$FILE_LIZARD_PKGS"
- Debug "FILE_LIZARD_FSINFO=$fsinfo"
- FILE_LIZARD_FSINFO="`Lizard_File_Glob $fsinfo $eth0_ip $eth0_net`"
- Debug "actual FILE_LIZARD_FSINFO=$FILE_LIZARD_FSINFO"
- Debug "FILE_LIZARD_FINISH=$finish_script"
- FILE_LIZARD_FINISH="`Lizard_File_Glob $finish_script $eth0_ip $eth0_net`"
- Debug "actual FILE_LIZARD_FINISH=$FILE_LIZARD_FINISH"
- Breakpoint "after Autoget_Lizard_Config"
- return 0
- }
-
- Ask_Ether_Config()
- {
- local bpf=/tmp/bootpc.out
- local reply
-
- echo "Manual input of network information:" >> /dev/tty1
- chvt 1
-
- echo -n "Enter the fully qualified hostname: "
- read reply
- echo "HOSTNAME=$reply" > $bpf
-
- echo -n "Enter the IP address : "
- read reply
- echo "IPADDR=$reply" >> $bpf
-
- echo -n "Enter the netmask : "
- read reply
- echo "NETMASK=$reply" >> $bpf
-
- echo -n "Enter the broadcast address : "
- read reply
- echo "BROADCAST=$reply" >> $bpf
-
- echo -n "Enter the network IP address : "
- read reply
- echo "NETWORK=$reply" >> $bpf
-
- echo -n "Enter the router IP address : "
- read reply
- echo "GATEWAYS=$reply" >> $bpf
-
- echo -n "Enter the DNS server IP address : "
- read reply
- echo "DNSSRVS=$reply" >> $bpf
-
- echo -n "Enter the NFS server IP address : "
- read reply
- echo "SERVER=$reply" >> $bpf
-
- echo -n "Enter the path to the root of CD 1 on the NFS server : "
- read reply
- echo "BOOTFILE=$reply" >> $bpf
-
- chvt 7
- return 0
- }
-
- Autoget_Ether_Config()
- {
- local retval
- local bpf=/tmp/bootpc.out
- local fqhn=
- local query_type=bootpc
- local eth0_ip=
- local eth0_mask=
- local eth0_bcast=
- local eth0_net=
- local router1_ip=
- local tftp_server1_ip=
- local tftp_filename=
- local dns_server1_ip=
- local nfs_server1_ip=
- local nfs_server1_path=
-
- if [ ! -x /bin/bootpc ]; then return 1 ; fi
-
- Do_fix_ePanic af_packet
-
- ifconfig eth0 down >> $FILE_LOG_DEBUG 2>&1
- ifconfig lo down >> $FILE_LOG_DEBUG 2>&1
-
- ifconfig lo 127.0.0.1 netmask 255.0.0.0 broadcast 127.255.255.255 >> $FILE_LOG_DEBUG 2>&1
- route add -net 127.0.0.0 netmask 255.0.0.0 dev lo >> $FILE_LOG_DEBUG 2>&1
-
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep asknet`" ]; then
- query_type=asknet
- echo "asking for network information..." >> $FILE_LOG_DEBUG
- Ask_Ether_Config
- retval=$?
- Breakpoint "after asknet branch"
- else
- ifconfig eth0 0.0.0.0 >> $FILE_LOG_DEBUG 2>&1
- echo "running bootpc..." >> $FILE_LOG_DEBUG
- /bin/bootpc -t 6 | sed '/GATEWAYS=\"83.84/d' > $bpf 2>&1
- retval=$?
- Breakpoint "after bootpc request"
- fi
-
- ifconfig eth0 down >> $FILE_LOG_DEBUG 2>&1
- ifconfig lo down >> $FILE_LOG_DEBUG 2>&1
-
-
- # the pcnet32 driver hangs in promiscous mode - reload it
- # No longer true for 2.4 kernel. I hope. MM 20010115
- #if [ -n "`cat /proc/modules | sed -n '/^pcnet32/p'`" ]; then
- # rmmod pcnet32
- # Do_Load_Module pcnet32
- # sleep 1
- #fi
-
- if [ $retval -ne 0 ]; then
- echo "$query_type returns with <$retval>" >> $FILE_LOG_DEBUG
- Do_fix_ePanic bootpc || return 1
- # return 1
- fi
-
- if [ ! -s $bpf ]; then
- echo "$query_type returns no output" >> $FILE_LOG_DEBUG
- Do_fix_ePanic bootpc || return 1
- # return 1
- fi
-
- echo "$query_type returns:" >> $FILE_LOG_DEBUG
- cat $bpf >> $FILE_LOG_DEBUG
-
- netdev="`get_val -f $bpf DEVICE`"
- if [ -z "$netdev" ]; then
- netdev="eth0"
- fi
- fqhn="`get_val -f $bpf HOSTNAME`"
- eth0_ip="`get_val -f $bpf IPADDR`"
- eth0_mask="`get_val -f $bpf NETMASK`"
- eth0_bcast="`get_val -f $bpf BROADCAST`"
- eth0_net="`get_val -f $bpf NETWORK`"
- if [ -z "$eth0_net" ]; then
- eth0_net="`do_netcalc -n $eth0_ip $eth0_mask`"
- fi
- # fix bootpc.out to only contain one value per entry
- router1_ip="`get_val -f $bpf GATEWAYS | sed 's/ .*//'`"
- set_val -f $bpf GATEWAYS "$router1_ip"
- dns_server1_ip="`get_val -f $bpf DNSSRVS | sed 's/ .*//'`"
- set_val -f $bpf DNSSRVS "$dns_server1_ip"
- tftp_server1_ip="`get_val -f $bpf SERVER | sed 's/ .*//'`"
- set_val -f $bpf SERVER "$tftp_server1_ip"
- tftp_filename="`get_val -f $bpf BOOTFILE | sed 's/ .*//'`"
- set_val -f $bpf BOOTFILE "$tftp_filename"
-
- echo "configuring network..." >> $FILE_LOG_DEBUG
- ifconfig lo 127.0.0.1 netmask 255.0.0.0 broadcast 127.255.255.255 >> $FILE_LOG_DEBUG 2>&1
- route add -net 127.0.0.0 netmask 255.0.0.0 dev lo >> $FILE_LOG_DEBUG 2>&1
- ifconfig $netdev $eth0_ip netmask $eth0_mask broadcast $eth0_bcast >> $FILE_LOG_DEBUG 2>&1
- route add -net $eth0_net netmask $eth0_mask dev $netdev >> $FILE_LOG_DEBUG 2>&1
- route add default gw $router1_ip dev $netdev >> $FILE_LOG_DEBUG 2>&1
- if [ "X$1" = "Xnomount" ]; then
- return 0
- fi
- if [ -z "$tftp_server1_ip" -o -z "$tftp_filename" ]; then
- return 1
- fi
- mount -o ro,bg,intr,nolock -t nfs ${tftp_server1_ip}:${tftp_filename} $DIR_SOURCE > /tmp/nfsmountout 2> /tmp/nfsmounterr || return 1
-
- Autoget_Lizard_Config ${eth0_ip} ${eth0_mask} ${tftp_server1_ip} ${tftp_filename} || return 1
- return 0
- }
-
-
- Do_Load_Module()
- {
- local ans=/tmp/ans
- # local err=/tmp/err
- local err=/dev/null
- local modpath=/lib/modules/`uname -r`
- local subpath=
- local module=
- local driver=
- local modparam=
- local modlist=/tmp/modules.initrd
- local override_list=/tmp/modules.override
- local override_module=false
-
- driver="$1"
- shift 1
- modparam="$@"
-
- # lame little dependency hack - jwc
- if [ "$driver" = "usb-uhci" ]; then
- Debug "${driver} requires usbcore."
- echo "${driver} requires usbcore." >> $err
- Do_Load_Module usbcore
- fi
-
- # check whether it's already loaded
- /sbin/lsmod | sed -n "/^$driver/p" > $ans
- if [ -s $ans ]; then
- echo "$driver is already loaded" >> $err
- return 0
- fi
-
- # check whether it's available and prepare it for loading
- for subpath in kernel/drivers/block/ \
- kernel/drivers/cdrom \
- kernel/drivers/char/ \
- kernel/drivers/char/agp \
- kernel/drivers/char/joystick \
- kernel/drivers/char/rio \
- kernel/drivers/ide \
- kernel/drivers/net/ \
- kernel/drivers/parport \
- kernel/drivers/pnp \
- kernel/drivers/scsi \
- kernel/drivers/sound/ \
- kernel/drivers/sound/emu10k1 \
- kernel/drivers/usb/ \
- kernel/drivers/usb/serial \
- kernel/drivers/usb/storage \
- kernel/fs/ \
- kernel/net/sunrpc \
- pcmcia ; do
- mkdir -p $modpath/$subpath
- module="$modpath/$subpath/${driver}.o"
- override_module=false
- if [ -s /floppy/lib/modules/override/${subpath}/${driver}.o ]; then
- echo "Found override for ${driver} (no gz)" >> $err
- mkdir -p /override/$modpath/${subpath}
- module="/override/$module"
- cp -a /floppy/lib/modules/override/${subpath}/${driver}.o $module
- override_module=true
- break
- elif [ -s /floppy/lib/modules/override/${subpath}/${driver}.o.gz ]; then
- echo "Found override for ${driver} (gz)" >> $err
- mkdir -p /override/$modpath/${subpath}
- module="/override/$module"
- gzip -dcf /floppy/lib/modules/override/${subpath}/${driver}.o.gz > $module
- override_module=true
- break
- elif [ -s $module ]; then
- break
- elif [ -s $module.gz ]; then
- gunzip $module.gz
- break
- elif [ -s /source/$module ]; then
- module=/source/$module
- break
- elif [ -s /floppy/$module ]; then
- module=/floppy/$module
- break
- elif [ -s /floppy/$module.gz ]; then
- gzip -dcf /floppy/$module.gz > $module
- break
- fi
- module=
- done
-
- if [ -z "$module" ]; then
- echo "$driver not found anywhere" >> $err
- return 1
- fi
-
- while [ 1 ]; do
- Debug "trying <insmod $module $modparam> ... "
- echo "trying <insmod $module $modparam> ... " >> $err
- /sbin/insmod $module $modparam >> $err 2>&1 && break
- /sbin/rmmod $driver >/dev/null 2>&1
- Debug "insmod ${driver} failed. compressing module."
- echo "insmod ${driver} failed. compressing module." >> $err
- gzip -9 $module >/dev/null 2>&1
- return 1
- done
- Debug "insmod ${driver} succeeded."
- echo "insmod ${driver} succeeded." >> $err
- echo "$driver" >> $modlist
- if [ "$override_module" = "true" ]; then
- Debug "override module tagged."
- echo "$driver" >> $override_list
- #Debug "override module saved (hardlinked) for later copy."
- #mkdir /override/`dirname $module`
- #ln -f $module /override/$module
- fi
- mkdir -p /etc/modules/options
- if [ -n "$modparam" ]; then
- echo "$modparam" > /etc/modules/options/$driver
- else
- rm -f /etc/modules/options/$driver
- fi
- return 0
- }
-
-
- Load_Default_Modules()
- {
- local driver=
-
- for driver in $@ ; do
- Do_Load_Module $driver ""
- done
- return 0
- }
-
-
- Do_Autoprobe()
- {
- local what=
- local how=
-
- # CD probelists (sbpcd takes too much time)
- local cd_probelist_kernel="cdu31a mcd mcdx sbpcd aztcd sonycd535 gscd arcd bpcd bpmcd dscd eicd epcd kicd oicd pwcd cm206 optcd sjcd isp16"
- # parallel port devices cause trouble :-(
- local cd_probelist="cdu31a mcd mcdx aztcd sonycd535 gscd cm206 optcd sjcd isp16"
- local cd_probelist_cautious="mcd gscd bpcd"
-
- # SCSI probelists (g_NCR5380 hangs)
- local scsi_probelist_kernel="advansys BusLogic u14-34f ultrastor aha152x aha1542 aha1740 aic7xxx fdomain in2000 g_NCR5380 NCR53c406a qlogicfas pas16 seagate t128 dtc eata_pio wd7000 eata AM53C974 ppa"
- local scsi_probelist="advansys BusLogic u14-34f ultrastor aha152x aha1542 aha1740 aic7xxx fdomain in2000 NCR53c406a qlogicfas pas16 seagate t128 dtc eata_pio wd7000 eata ppa"
- local scsi_probelist_cautious="BusLogic aha1542 aic7xxx fdomain"
-
- # net probelists
- local ether_probelist_kernel="de4x5 dgrs epic100 hp100 pcnet32 8139too 3c59x tulip e100 ac3200 smc-ultra32 at1700 smc-ultra smc9194 wd 3c503 hp hp-plus seeq8005 e2100 ne at1500 fmv18x eth16i 3c509 3c515 znet eexpress eepro depca ewrk3 apricot 3c501 3c507 3c505 de600 de620 ni52 ni65 lance"
- # the at1500 is part of the e2100 ?
- # the 3c501 is always misdetected :-(
- # the seeq8005 and znet are not modularized :-(
- # eepro and eexpress hang sometimes :-(
- # parallel port devices cause trouble :-(
- # tlan loads always :-(
- local ether_probelist="de4x5 dgrs epic100 hp100 pcnet32 8139too 3c59x tulip e100 ac3200 smc-ultra32 at1700 smc-ultra smc9194 wd 3c503 hp hp-plus e2100 ne fmv18x eth16i 3c509 3c515 depca ewrk3 apricot 3c507 3c505 ni52 ni65 lance"
- local ether_probelist_cautious="epic100 smc-ultra wd ne 3c509"
-
- local driver=
- local modparam=
- local retval=
- local success=
- local probelist_full=
- local probelist_cautious=
- local probelist_real=
-
- what="$1"
- shift 1
-
- $CMD_BOOTER item $what
-
- case $what in
- all)
- # simulate full kernel autoprobing by load & test of all modules
- # first we probe for CDROMs, then for SCSI hosts and last for ethernet
- probelist_full="$cd_probelist $scsi_probelist $ether_probelist"
- probelist_cautious="$cd_probelist_cautious $scsi_probelist_cautious $ether_probelist_cautious"
- ;;
- HDEVPCI)
- if [ ! -f /proc/bus/pci/devices ] ; then
- $CMD_BOOTER none
- return 1
- fi
- cat /proc/bus/pci/devices|\
- while read xid pciid rest ; do
- :>/tmp/havedevice_$pciid
- done
- while read xid driver ; do
- if [ x$xid = "xdriver" ] ; then
- curdriver=$driver
- else
- if [ -f /tmp/havedevice_$xid ] ; then
- Do_Load_Module $curdriver
- retval=$?
- if [ $retval -eq 0 ]; then
- success=1
- fi
- fi
- fi
- done </etc/pcidrivers
- if [ -n "$success" ] ; then
- $CMD_BOOTER ok
- return 0
- else
- $CMD_BOOTER skip
- return 1
- fi
- ;;
- HCDATAPI)
- if [ -n "`cat /proc/ide/hd?/media 2> /dev/null | fgrep cdrom`" ]; then
- $CMD_BOOTER ok
- return 0
- else
- $CMD_BOOTER none
- return 1
- fi
- ;;
- CD|HCDOTHER)
- # we skip that probe if we have either ATAPI or SCSI cdroms
- # for speed issues
- if [ -f /proc/sys/dev/cdrom/info ] ; then
- if [ -n "`cat /proc/sys/dev/cdrom/info|sed -e 's/drive name:.*[a-z]/HAVE_CDROM/g'|fgrep HAVE_CDROM`" ] ; then
- $CMD_BOOTER skip
- return 0
- fi
- fi
- probelist_full="$cd_probelist"
- probelist_cautious="$cd_probelist_cautious"
- ;;
- SCSI|HCDSCSI)
- # we skip that probe if we already have one scsi hostadapter
- if [ -n "`cat /proc/scsi/scsi|fgrep scsi0`" ] ; then
- $CMD_BOOTER ok
- return 1
- fi
- probelist_full="$scsi_probelist"
- probelist_cautious="$scsi_probelist_cautious"
- ;;
- NET|HETHER)
- # we skip that probe if we have already one net device
- if [ -n "`sed -e '1,3d' /proc/net/dev`" ] ; then
- $CMD_BOOTER ok
- return 1
- fi
- probelist_full="$ether_probelist"
- probelist_cautious="$ether_probelist_cautious"
- ;;
- esac
-
- if [ $# -gt 0 -a "$1" = "cautious" ]; then
- probelist="$probelist_cautious"
- all=0
- elif [ $# -gt 0 -a "$1" = "nothing" ]; then
- probelist=""
- $CMD_BOOTER skip
- return 0
- elif [ $# -gt 0 -a "$1" = "query" ]; then
- # one day we really want to launch an interactive mode here
- # for now probe cautious in the network case, nothing in the
- # other CDROMs case and everything in the SCSI hosts case
- case $what in
- NET|HETHER)
- probelist="$probelist_cautious"
- ;;
- CD|HCDOTHER)
- probelist=""
- ;;
- SCSI|HCDSCSI)
- probelist="$probelist_full"
- ;;
- HCDATAPI)
- :
- # we will actually never get here. bad control flow :-(
- ;;
- esac
- else
- probelist="$probelist_full"
- fi
-
-
- Debug ":INFO_AUTOPROBE_RUNNING:"
-
- for driver in $probelist ; do
- modparam=
- if [ "$driver" = "ne" ]; then
- # NE2000 cards need an io parameter. 0x300 is very common.
- modparam="io=0x300"
- fi
- Debug "probing ${driver} driver:"
- Do_Load_Module $driver $modparam
- retval=$?
- if [ $retval -eq 0 ]; then
- success=1
- fi
- done
- if [ -n "$success" ]; then
- $CMD_BOOTER ok
- return 0
- else
- $CMD_BOOTER none
- return 1
- fi
- }
-
-
- Check_Source_Valid()
- {
- if [ -f $DIR_DATA/cd1 ]; then
- return 0
- else
- return 1
- fi
- }
-
-
- Check_Iso_Source_Valid()
- # jwc - check for /redmondlinux.iso in the root of a linux partition
- {
- if [ -f $DIR_ISO_FILE ]; then
- return 0
- else
- return 1
- fi
- }
- #jwc
-
-
- Failsafe_CD_Mount()
- {
- local dev="$1"
- local dir="$2"
- local short_dev
-
- # first try a normal mount
- mount -r -t iso9660 $dev $dir > /dev/null 2>&1
- Check_Source_Valid && return 0
- umount $dir > /dev/null 2>&1
-
- # nothing can be done on non-ATAPI cdrom failure
- if [ -z "`echo $dev | fgrep '/dev/hd'`" ]; then
- return 1
- fi
-
- # for ATAPI cdroms we can disble dma and try again as a fallback
- short_dev="`echo $dev | cut -c6-`"
- Debug "Disabling DMA for $short_dev and trying again ..."
- echo "using_dma:0" > /proc/ide/${short_dev}/settings
- mount -r -t iso9660 $dev $dir > /dev/null 2>&1
- Check_Source_Valid && return 0
-
- # Hmm, nothing can be done :-(
- umount $dir > /dev/null 2>&1
- return 1
- }
-
-
- Do_Mount_Source()
- {
- local devs
- local dev
- local ans
-
- Breakpoint "Do_Mount_Source"
-
- $CMD_BOOTER add_menu "BLANK2"
- $CMD_BOOTER add_menu "T2 Automatic install source detection:"
- $CMD_BOOTER list "L2 Mount"
- $CMD_BOOTER add "MCD Installation from CDROM"
- $CMD_BOOTER add "MNFS Installation over NFS"
- $CMD_BOOTER add "MDISK Installation from harddisk"
- $CMD_BOOTER end
- $CMD_BOOTER show
- $CMD_BOOTER activate L2
-
- # FIXME: for now the order of probing is fixed (CDROM, NFS, SMB, disk)
- # and we stop probing when we found the first valid source
-
- mkdir -p $DIR_SOURCE
- $CMD_BOOTER item MCD
- sysinfo --var --cdrom > /dev/null 2> /tmp/cdroms
- devs="`cut -d':' -f 2 /tmp/cdroms`"
-
- # shake the ethernet interface to wake up ;-)
- # FIXME: should we do this for all ifs? or just get rid of it?
- if [ -n "`sed -e '1,3d' /proc/net/dev`" ]; then
- ifconfig eth0 down >> $FILE_LOG_DEBUG 2>&1
- ifconfig lo down >> $FILE_LOG_DEBUG 2>&1
- ifconfig lo 127.0.0.1 netmask 255.0.0.0 broadcast 127.255.255.255 >> $FILE_LOG_DEBUG 2>&1
- route add -net 127.0.0.0 netmask 255.0.0.0 dev lo >> $FILE_LOG_DEBUG 2>&1
- ifconfig eth0 0.0.0.0 >> $FILE_LOG_DEBUG 2>&1
- ifconfig eth0 down >> $FILE_LOG_DEBUG 2>&1
- ifconfig lo down >> $FILE_LOG_DEBUG 2>&1
- fi
-
- if [ -n "$devs" ]; then
- Debug "Checking for CDROM source"
- for dev in $devs ; do
- Failsafe_CD_Mount $dev $DIR_SOURCE
- if [ $? -eq 0 ]; then
- if [ -n "`sed -e '1,3d' /proc/net/dev`" ]; then
- if [ -z "`sed -n '/^er=/p' /tmp/cmdline | fgrep cautious`" ]; then
- Debug "Checking network without mount"
- Autoget_Ether_Config nomount
- fi
- fi
- Autoget_Lizard_Config none none none none || continue
- $CMD_BOOTER ok
- $CMD_BOOTER item MNFS
- $CMD_BOOTER skip
- $CMD_BOOTER item MDISK
- $CMD_BOOTER skip
- return 0
- fi
- umount $DIR_SOURCE > /dev/null 2>&1
- done
- $CMD_BOOTER skip
- else
- $CMD_BOOTER skip
- fi
- $CMD_BOOTER item MNFS
- # FIXME: should do it over all Ethernet cards, not only eth0
- if [ -n "`sed -e '1,3d' /proc/net/dev`" ]; then
- Debug "Checking for network source"
- Autoget_Ether_Config
- if [ $? -eq 0 ]; then
- Check_Source_Valid
- if [ $? -eq 0 ]; then
- $CMD_BOOTER ok
- $CMD_BOOTER item MDISK
- $CMD_BOOTER skip
- return 0
- fi
- umount $DIR_SOURCE > /dev/null 2>&1
- umount $DIR_LIZARD > /dev/null 2>&1
- fi
- fi
- $CMD_BOOTER skip
- $CMD_BOOTER item MDISK
- # try Linux partitions first
- devs="`sysinfo --tag -C Linux --partition`"
- if [ -n "$devs" ]; then
- Debug "Checking for Linux partition source"
- Debug "... and also redmondlinux.iso source" # jwc
- for dev in $devs ; do
- mount -r -t ext2 $dev $DIR_SOURCE > /dev/null 2>&1
- Check_Source_Valid
- if [ $? -eq 0 ]; then
- Autoget_Lizard_Config none none none none || continue
- $CMD_BOOTER ok
- return 0
- fi
- umount $DIR_SOURCE > /dev/null 2>&1
- # jwc - check .iso images also
- mount -r -t ext2 $dev $DIR_SOURCE_TMP > /dev/null 2>&1
- Check_Iso_Source_Valid
- if [ $? -eq 0 ]; then
- mount -r -t iso9660 -o loop=/dev/loop0 $DIR_ISO_FILE $DIR_SOURCE > /dev/null 2>&1
- Autoget_Lizard_Config none none none none || continue
- $CMD_BOOTER ok
- return 0
- fi
- umount $DIR_SOURCE_TMP > /dev/null 2>&1
- # jwc - end check .iso images
- done
- fi
-
- # finally try DOS partitions
- devs="`sysinfo --tag -C DOS --partition`"
- if [ -n "$devs" ]; then
- Debug "Checking for DOS partition source"
- for dev in $devs ; do
- mount -r -t vfat $dev $DIR_SOURCE > /dev/null 2>&1
- Check_Source_Valid
- if [ $? -eq 0 ]; then
- Autoget_Lizard_Config none none none none || continue
- $CMD_BOOTER ok
- return 0
- fi
- umount $DIR_SOURCE > /dev/null 2>&1
- done
- fi
- $CMD_BOOTER skip
- $CMD_BOOTER complete L2
-
- return 1
- }
-
-
- Do_Extended_Autoprobe()
- {
- local module
-
- # isapnp is now under misc, but without uname -r
- if [ -r /lib/modules/misc/isapnp.o ]; then
- insmod isapnp
- fi
-
- # load more default modules now that the install source is mounted
- Load_Default_Modules isapnp fat msdos vfat umsdos scsi_mod
-
- # use hwprobe to write /etc/modules.conf
- if [ -x /sbin/hwprobe ]; then
- Breakpoint "before hwprobe"
- if [ -f /etc/hwprobe.config ]; then
- /sbin/hwprobe /etc/hwprobe.config
- else
- /sbin/hwprobe
- fi
- fi
-
- # load modules according to the generated default file
- if [ -s /etc/modules/default ]; then
- Breakpoint "before default module loading (hwprobe based)"
- for module in `cat /etc/modules/default | sed '/^#/d'` ; do
- if [ -z "`sed -n "/^$module /p" /proc/modules`" ]; then
- echo "Trying modprobe $module (forced by /etc/modules/default)" > $FILE_LOG_DEBUG 2>&1
- modprobe $module > $FILE_LOG_DEBUG 2>&1
- else
- echo "Skipping modprobe $module (forced by /etc/modules/default but already loaded)" > $FILE_LOG_DEBUG 2>&1
- fi
- done
- fi
- Load_Default_Modules sd sd_mod sr_mod sg
- if fgrep usbdevfs /proc/filesystems >/dev/null ; then
- mount -t usbdevfs none /proc/bus/usb
- echo "Trying to start USB hotplugd" > $FILE_LOG_DEBUG 2>&1
- if [ -x /usr/sbin/hotplugd ]; then
- /usr/sbin/hotplugd
- fi
- fi
-
- return 0
- }
-
-
- Prepare_lisa()
- {
- Breakpoint "Prepare_lisa"
- if [ -x /bin/lisaprep ]; then
- /bin/lisaprep || return 1
- return 0
- elif [ -x $DIR_LIVE/lisa/bin/lisaprep ]; then
- $DIR_LIVE/lisa/bin/lisaprep || return 1
- return 0
- else
- return 1
- fi
- return 0
- }
-
-
- Prepare_lizard()
- {
- Breakpoint "Prepare_lizard"
-
- # minimal network to make sure sockets work
- ifconfig lo down >> $FILE_LOG_DEBUG 2>&1
- ifconfig lo 127.0.0.1 netmask 255.0.0.0 broadcast 127.255.255.255 >> $FILE_LOG_DEBUG 2>&1
- route add -net 127.0.0.0 netmask 255.0.0.0 dev lo >> $FILE_LOG_DEBUG 2>&1
- # unpack live filesystem
- if [ -x `dirname $DIR_LIVE`/clive/uncramfs ]; then
- Breakpoint "before uncramfs"
- `dirname $DIR_LIVE`/clive/uncramfs
- fi
-
- # prepare install environment
- if [ -x $DIR_LIVE/activate ]; then
- Breakpoint "before activate"
- $DIR_LIVE/activate # || return 1
- Do_fix_ePanic lsmod
- else
- return 1
- fi
-
- if [ -z "`sed -n '/^er=/p' /tmp/cmdline | fgrep cautious`" ]; then
- # we have access to all modules through the live filesystem
- # so we can run an extended autoprobe
- Do_Extended_Autoprobe
- fi
-
- # add all needed disk devices
- Make_DISK_Devices
-
- return 0
- }
-
-
- Run_lisa_install()
- {
- local retval
- local tgtdev
-
- Breakpoint "Run_lisa_install"
- chvt 1
- # try to autodetect Monochrome terminals
- sysinfo --video | fgrep Mono > /dev/null
- if [ $? -eq 0 ]; then
- export TERM=linux-mono
- else
- export TERM=linux
- fi
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep expert`" ]; then
- set_val MODE_USER expert
- export LOGNAME="expert"
- expert_param='--expert'
- else
- set_val MODE_USER newbie
- export LOGNAME="install"
- expert_param='--newbie'
- fi
- prep_use LISA
- Debug "lisa $expert_param --first ... "
- lisa $expert_param --first
- retval=$?
- echo "Debug: lisa finished with return val $retval" > /dev/tty4
- chvt 7
- if [ $retval -eq 0 ]; then
- # now remount the target root from /root to /mnt/root
- tgtdev="`mount | fgrep ' on /root ' | cut -d' ' -f 1`"
- umount $tgtdev
- mount -t ext2 $tgtdev /mnt/root
- Retrieve_sysinfo
- $CMD_BOOTER ok
- else
- $CMD_BOOTER fail
- sleep 1
- fi
- return $retval
- }
-
-
- Run_lizard_interactive()
- {
- local retval
- local display_param=""
- local fb_param=""
- local expert_param=""
- local lizard_param=""
- local demo_param=""
- local cautious_params=""
-
- Breakpoint "Run_lizard_interactive"
-
- if [ -d /lizard/. ] ; then
- cd /lizard/
- else
- cd $DIR_LIVE_LIZARD
- fi
-
- # allow to remote-set the display
- display_param="`sed -n '/^display=/p' /tmp/cmdline | cut -d'=' -f 2-`"
- if [ -n "$display_param" ]; then
- display_param="-display $display_param"
- fi
- # if the kernel runs in frame buffer than we should use FB X in LIZARD
- fb_param="`fgrep -x 'vga=785' /tmp/cmdline`"
- if [ -n "$fb_param" ]; then
- fb_param="-server XF86_FBDev"
- fi
- # set -noskip if we run in expert mode
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep expert`" ]; then
- expert_param='-noskip'
- fi
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep cautious`" ]; then
- cautious_params='-nosound -nomouseprobe -nonetprobe'
- fi
- lizard_param="`sed -n '/lz=/p' /tmp/cmdline | cut -d'=' -f 2- | sed 's/[=,]/ /g'`"
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep demo`" ]; then
- demo_param='-demo'
- fi
- Debug "./lizard $display_param $fb_param $expert_param $cautious_params $lizard_param $demo_param ... "
- ./lizard $display_param $fb_param $expert_param $cautious_params $lizard_param $demo_param 2> /dev/tty4
- retval=$?
- echo "Debug: lizard finished with return val $retval" > /dev/tty4
-
- chvt 7
-
- # FIXME: dirty hack: we assume ok until Qt segfault bug is found
- #retval=0
-
- if [ $retval -eq 0 ]; then
- $CMD_BOOTER ok
- else
- $CMD_BOOTER fail
- sleep 1
- fi
- return $retval
- }
-
-
- Set_Val()
- {
- local f=$DIR_TARGET/etc/system.cnf
-
- set_val -f $f $1 "$2"
- }
-
-
- Get_root()
- {
- local dev
- local major
- local minor
-
- dev="`sed -n '/ \/mnt\/root /p' /proc/mounts | cut -d' ' -f 1`"
- echo "Root device is detected as $dev" > /dev/tty4
- if [ -z "$dev" ]; then
- # Hmmm, it seems lizard did not finish it's job :-(
- # give them something that doesn't hurt us and will
- # let us land safely. The kernel will remount the
- # ramdisk and call /bin/sh (as we have no /sbin/init)
- Panic "Ooops, no valid root could be found! Lizard aborted?"
- Panic "Preparing for an emergency landing ..."
- dev=/dev/ram
- fi
- major="`ls -l $dev | cut -c 35-36 | sed 's/ //g'`"
- minor="`ls -l $dev | cut -c 40-41 | sed 's/ //g'`"
-
- case $1 in
- dev)
- echo "$dev"
- return 0
- ;;
- id)
- echo "$dev"
- return 0
- ;;
- esac
- return 0
- }
-
-
- Dec2Hex()
- {
- local n1=`do_calc $1 / 16`
- local t1=`do_calc $n1 \* 16`
- local n2=`do_calc $1 - $t1`
- local i=
- local r=""
-
- if [ $n1 -eq 0 ]; then
- n1=0
- fi
-
- for i in $n1 $n2; do
- if [ $i -lt 10 ]; then
- r="${r}$i"
- else
- case "$i" in
- 10) r="${r}a" ;;
- 11) r="${r}b" ;;
- 12) r="${r}c" ;;
- 13) r="${r}d" ;;
- 14) r="${r}e" ;;
- 15) r="${r}f" ;;
- esac
- fi
- done
-
- echo "$r"
- return 0
- }
-
-
- Dev2Hex()
- {
- local root_dev=
- local driver=
- local disk=
- local base=
- local partition=
- local major=
- local minor=
- local high=
- local low=
- local bios_id=
-
- root_dev="`echo $1 | sed 's/^\/dev\///'`"
- driver="`echo $root_dev | cut -c 1-2`"
-
- while read major minor blocks name; do
- if [ "$root_dev" = "$name" ]; then
- minor="`Dec2Hex $minor`"
- major="`Dec2Hex $major`"
- echo "0x${major}${minor}"
- return 0
- fi
- done < /proc/partitions
-
- # both parts of the code below needs to be cross checked.
- if [ "$driver" = "rd" ]; then
- driver="`echo $root_dev | cut -c 1-5`"
- disk="`echo $root_dev | cut -c 7-7`"
- partition="`echo $root_dev | cut -c 9-`"
- base=8
- elif [ "$driver" = "id" ]; then
- driver="`echo $root_dev | cut -c 1-6`"
- disk="`echo $root_dev | cut -c 8-8`"
- partition="`echo $root_dev | cut -c 10-`"
- base=16
- elif [ "$driver" = "cc" ]; then
- driver="`echo $root_dev | cut -c 1-8`"
- disk="`echo $root_dev | cut -c 10-10`"
- partition="`echo $root_dev | cut -c 12-`"
- base=16
- else
- disk="`echo $root_dev | cut -c 3-3`"
- partition="`echo $root_dev | cut -c 4-`"
- base=64
- fi
-
- case $driver in
- hd)
- major=22
- if [ "$disk" = "a" -o "$disk" = "b" ]; then major=3
- elif [ "$disk" = "c" -o "$disk" = "d" ]; then major=22
- elif [ "$disk" = "e" -o "$disk" = "f" ]; then major=33
- elif [ "$disk" = "g" -o "$disk" = "h" ]; then major=34
- fi
- ;;
- ida/c0) major=72 ;;
- cciss/c0) major=104 ;;
- rd/c0) major=48 ;;
- sd)
- base=16
- major=8
- ;;
- xd) major=13 ;;
- esac
-
- high="`Dec2Hex $major`"
-
- case $disk in
- a|0) minor=0 ;;
- b|1) minor=1 ;;
- c|2)
- if [ "$driver" = "hd" ]; then
- minor=0
- else
- minor=2
- fi
- ;;
- d|3)
- if [ "$driver" = "hd" ]; then
- minor=1
- else
- minor=3
- fi
- ;;
- e|4)
- if [ "$driver" = "hd" ]; then
- minor=0
- else
- minor=4
- fi
- ;;
- f|5)
- if [ "$driver" = "hd" ]; then
- minor=1
- else
- minor=5
- fi
- ;;
- g|6)
- if [ "$driver" = "hd" ]; then
- minor=0
- else
- minor=6
- fi
- ;;
- h|7)
- if [ "$driver" = "hd" ]; then
- minor=1
- else
- minor=7
- fi
- ;;
- esac
-
- low="`do_calc $minor \* $base`"
- low="`do_calc $low \+ $partition`"
- low="`Dec2Hex $low`"
-
- echo "0x${high}${low}"
- return 0
- }
-
-
- # retrieve the real root device either from the cmdline or the mounted target
- Set_real_root_dev()
- {
- local dev
- local id
- local f=/proc/sys/kernel/real-root-dev
-
- if [ $# -eq 1 -a "$1" = "cmdline" ]; then
- dev="`sed -n '/^root=/p' /tmp/cmdline | cut -d'=' -f 2`"
- if [ -n "`echo $dev | fgrep dev`" ]; then
- id="`Dev2Hex $dev`"
- else
- id="0x$dev"
- fi
- else
- dev="`Get_root dev`"
- id="`Dev2Hex $dev`"
- fi
- echo "$id" > $f
- return 0
- }
-
-
- Fix_etc_fstab()
- {
- local f=$DIR_TARGET/etc/fstab
- local dev=
-
- # try to derive the CDROM that we installed from or the first one
- if [ -n "`fgrep '/mnt/install' /proc/mounts | fgrep 'iso9660'`" ]; then
- dev="`fgrep '/mnt/install' /proc/mounts | cut -d' ' -f 1`"
- else
- sysinfo --var --cdrom > /dev/null 2> /tmp/cdroms
- dev="`cut -d':' -f 2 /tmp/cdroms | sed '2,$d'`"
- fi
-
- # add proc entry to fstab
- mkdir -p $DIR_TARGET/proc
- if [ -z "`sed -n '/^\/proc/p' $DIR_TARGET/etc/fstab`" ]; then
- echo "/proc /proc proc defaults 0 0" >> $f
- fi
-
- # add devpts entry to fstab (if missing)
- if [ -z "`sed -n '/^devpts/p' $DIR_TARGET/etc/fstab`" ]; then
- echo "devpts /dev/pts devpts gid=5,mode=620 0 0" >> $f
- fi
-
- # add floppy entry to fstab
- mkdir -p $DIR_TARGET/mnt/floppy
- if [ -z "`sed -n '/^\/dev\/fd0/p' $DIR_TARGET/etc/fstab`" ]; then
- echo "/dev/fd0 /mnt/floppy auto defaults,user,noauto 0 0" >> $f
- fi
-
- # add cdrom entry to fstab
- mkdir -p $DIR_TARGET/mnt/cdrom
- if [ -n "$dev" ]; then
- rm -f $DIR_TARGET/dev/cdrom
- ln -s $dev $DIR_TARGET/dev/cdrom
- if [ -z "`sed -n '/\/mnt\/cdrom/p' $DIR_TARGET/etc/fstab`" ]; then
- echo "$dev /mnt/cdrom iso9660 ro,user,noauto,exec 0 0" >> $f
- fi
- fi
- return 0
- }
-
-
- Fix_keyboard()
- {
- local f=$DIR_TARGET/etc/sysconfig/keyboard
-
- # source what lizard dumped into /tmp/keyboard
- if [ -f /tmp/keyboard ]; then
- . /tmp/keyboard
- CONF_KEYBOARD_MAP="us.map"
- else
- CONF_KEYBOARD_MODEL="pc101"
- CONF_KEYBOARD_LAYOUT="us"
- CONF_KEYBOARD_MAP="us.map"
- fi
-
- # map X keyboard names to kernel keyboard names
- # FIXME: fill in missing entries (currently fallback to us.map)
- case $CONF_KEYBOARD_LAYOUT in
- us)
- # U.S. English
- CONF_KEYBOARD_MAP="us.map"
- ;;
- be)
- # Belgian
- ;;
- bg)
- # Bulgarian
- ;;
- ca)
- # Canadian
- ;;
- cs)
- # Czechoslovakian
- ;;
- de_CH)
- # Swiss German
- ;;
- dk)
- # Danish
- ;;
- es)
- # Spanish
- CONF_KEYBOARD_MAP="es.map"
- ;;
- de)
- # German
- CONF_KEYBOARD_MAP="de-latin1-nodeadkeys.map"
- ;;
- # ash is unhappy with this :-(
- # fi)
- # # Finish
- # CONF_KEYBOARD_MAP="fi-latin1.map"
- # ;;
- fr)
- # French
- CONF_KEYBOARD_MAP="fr-latin1.map"
- ;;
- sf)
- # Swiss French
- ;;
- gb)
- # United Kingdom
- CONF_KEYBOARD_MAP="uk.map"
- ;;
- hg)
- # Hungarian
- ;;
- it)
- # Italian
- CONF_KEYBOARD_MAP="it.map"
- ;;
- jp)
- # Japanese
- ;;
- no)
- # Norwegian
- ;;
- pl)
- # Polish
- ;;
- pt)
- # Portugese
- ;;
- ru)
- # Russian
- ;;
- se)
- # Swedish
- ;;
- th)
- # Thai
- ;;
- esac
-
- Set_Val CONF_KEYBOARD_MAP "$CONF_KEYBOARD_MAP"
- mkdir -p $DIR_TARGET/etc/sysconfig
- echo "KEYTABLE=$CONF_KEYBOARD_MAP" > $f
- return 0
- }
-
-
- Fix_timezone()
- {
- local f=$DIR_TARGET/etc/sysconfig/clock
-
- # source what lizard dumped into /tmp/clock
- if [ -f /tmp/clock ]; then
- . /tmp/clock
- else
- CONF_TIMEZONE="GMT"
- CONF_KERNTZ_FLAG="u"
- fi
-
- CLOCKMODE=GMT
- case $CONF_KERNTZ_FLAG in
- u)
- CLOCKMODE=GMT
- ;;
- l)
- CLOCKMODE=LOCAL
- ;;
- esac
-
- # set /etc/system.cnf
- Set_Val CONF_TIMEZONE "$CONF_TIMEZONE"
- Set_Val CONF_KERNTZ_FLAG "$CONF_KERNTZ_FLAG"
-
- # create /etc/sysconfig/clock
- mkdir -p $DIR_TARGET/etc/sysconfig
- echo "CLOCKMODE=$CLOCKMODE" > $f
-
- # create /etc/localtime
- ln -sf /usr/share/zoneinfo/${CONF_TIMEZONE} $DIR_TARGET/etc/localtime
- return 0
- }
-
-
- Fix_mouse()
- {
- local MOUSETYPE=ps2
- local PROTO=ps2
- local XEMU3=no
- local DRIVER=psaux
-
- # source what lizard dumped into /tmp/mouse
- if [ -f /tmp/mouse ]; then
- . /tmp/mouse
- else
- CONF_MOUSE1_TYPE="PS2"
- CONF_MOUSE1_X_TYPE="ps/2"
- CONF_MOUSE1_DEV="/dev/psaux"
- CONF_MOUSE1_BUTTONS="3"
- fi
-
- case $CONF_MOUSE1_X_TYPE in
- MouseManPlusPS/2|IMPS/2|ThinkingMousePS/2|GlidePointPS/2|NetMousePS/2|NetScrollPS/2|PS/2|ps/2)
- CONF_MOUSE1_TYPE="PS2"
- CONF_MOUSE1_X_TYPE="ps/2"
- CONF_MOUSE1_DEV="/dev/psaux"
- MOUSETYPE=ps2
- PROTO=ps2
- DRIVER=psaux
- ;;
- Logitech|logitech)
- CONF_MOUSE1_TYPE="Logitech"
- CONF_MOUSE1_X_TYPE="logitech"
- #CONF_MOUSE1_DEV="serial"
- MOUSETYPE=logitech
- PROTO=logi
- DRIVER=psaux
- ;;
- Microsoft|microsoft)
- CONF_MOUSE1_TYPE="Microsoft"
- CONF_MOUSE1_X_TYPE="microsoft"
- MOUSETYPE=microsoft
- PROTO=ms
- DRIVER=psaux
- ;;
- USB|usb)
- CONF_MOUSE1_TYPE="USB"
- CONF_MOUSE1_X_TYPE="PS/2"
- MOUSETYPE=usb
- PROTO=ps2
- DRIVER=usb
- ;;
- busmouse)
- MOUSETYPE=busmouse
- PROTO=bm
- DRIVER=busmouse
- ;;
- mousesystems)
- MOUSETYPE=mousesystems
- PROTO=msc
- DRIVER="$CONF_MOUSE1_DEV"
- ;;
- esac
-
- # set /etc/system.cnf
- mkdir -p $DIR_TARGET/etc
- Set_Val CONF_MOUSE1_TYPE "$CONF_MOUSE1_TYPE"
- Set_Val CONF_MOUSE1_X_TYPE "$CONF_MOUSE1_X_TYPE"
- Set_Val CONF_MOUSE1_DEV "$CONF_MOUSE1_DEV"
- Set_Val CONF_MOUSE1_BUTTONS "$CONF_MOUSE1_BUTTONS"
-
- # create /dev/mouse
- mkdir -p $DIR_TARGET/dev
- ln -sf $CONF_MOUSE1_DEV $DIR_TARGET/dev/mouse
-
- # set /etc/sysconfig/mouse
- mkdir -p $DIR_TARGET/etc/sysconfig
- touch $DIR_TARGET/etc/sysconfig/mouse
- set_val -f $DIR_TARGET/etc/sysconfig/mouse MOUSETYPE "$MOUSETYPE"
- set_val -f $DIR_TARGET/etc/sysconfig/mouse PROTO "$PROTO"
- set_val -f $DIR_TARGET/etc/sysconfig/mouse DEVICE "$CONF_MOUSE1_DEV"
- if [ "$CONF_MOUSE1_BUTTONS" = "2" ]; then
- XEMU3=yes
- fi
- set_val -f $DIR_TARGET/etc/sysconfig/mouse XEMU3 "$XEMU3"
- set_val -f $DIR_TARGET/etc/sysconfig/mouse DRIVER "$DRIVER"
- }
-
-
- Fix_Videomode()
- {
- # source what lizard dumped into /tmp/videomode
- if [ -f /tmp/videomode ]; then
- . /tmp/videomode
- else
- CONF_GRAPHIC_CARD1_VESAMODE=274
- fi
-
- # set /etc/system.cnf
- Set_Val CONF_GRAPHIC_CARD1_VESAMODE "$CONF_GRAPHIC_CARD1_VESAMODE"
-
- # dirty hack
- # FIXME for COL 2.4
- sed '/CONF_GRAPHIC_CARD1_VESAMODE/s/\"//g' $DIR_TARGET/etc/system.cnf > $DIR_TARGET/etc/system.cnf.tmp
- mv $DIR_TARGET/etc/system.cnf.tmp $DIR_TARGET/etc/system.cnf
-
- return 0
- }
-
-
- # The file $override_list contains a list of all override modules that
- # loaded successfully. They still should be present (uncompressed) in the
- # ramdisk, so we try to find them and copy them into the target system,
- # overriding any existing ones.
- #
- Fix_override_modules()
- {
- local i
- local module
- local override_module
- local override_list=/tmp/modules.override
-
- if [ -s $override_list ]; then
- for i in `cat $override_list` ; do
- for override_module in /lib/modules/*/*/${i}.o \
- /lib/modules/*/*/*/${i}.o \
- /lib/modules/*/*/*/*/${i}.o \
- /lib/modules/*/*/*/*/*/${i}.o ; do
- if [ -f $override_module ]; then
- module="`echo $override_module | cut -c10-`"
- mkdir -p $DIR_TARGET/`dirname $module`
- cp -af $override_module $DIR_TARGET/$module
- break
- fi
- done
- done
- fi
- }
-
-
- Fix_XFree86()
- {
- # source what lizard dumped into /tmp/xserver
- if [ -f /tmp/xserver ]; then
- . /tmp/xserver
- else
- CONF_X_SERVER1_TYPE="XF86_SVGA"
- CONF_X_SERVER1_RESOL=""
- CONF_X_KEYBOARD_MAP=""
- fi
-
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep vga`" ]; then
- CONF_X_SERVER1_TYPE="XF86_VGA16"
- fi
-
- # set /etc/system.cnf
- Set_Val CONF_X_SERVER1_TYPE "$CONF_X_SERVER1_TYPE"
- Set_Val CONF_X_SERVER1_RESOL "$CONF_X_SERVER1_RESOL"
- Set_Val CONF_X_KEYBOARD_MAP "$CONF_X_KEYBOARD_MAP"
-
- # create /usr/X11R6/bin/X symlink
- rm -f $DIR_TARGET/usr/X11R6/bin/X
- ln -s $CONF_X_SERVER1_TYPE $DIR_TARGET/usr/X11R6/bin/X
-
- # create generic XF86Config.vga16
- cp -p $DIR_LIVE_LIZARD/XF86Config $DIR_TARGET/etc/XF86Config.vga16
-
- return 0
- }
-
-
- Fix_group()
- {
- sed 's/^users::100:.*$/users::100:/' $DIR_TARGET/etc/group > $DIR_TARGET/etc/group.tmp
- chmod 644 $DIR_TARGET/etc/group.tmp
- mv $DIR_TARGET/etc/group.tmp $DIR_TARGET/etc/group
- }
-
-
- Fix_root_home()
- {
- local i
-
- rm -fr $DIR_TARGET/root
- cp -aR $DIR_TARGET/etc/skel $DIR_TARGET/root
- chown -R root.root $DIR_TARGET/root
- return 0
- }
-
-
- Fix_logins()
- {
- Fix_group
- Fix_root_home
- }
-
-
- Get_kernel()
- {
- local ret
- local f
- local what
- local flag
- local image
-
- case $1 in
- release|image)
- what=UTS_RELEASE
- flag=-r
- f=$DIR_TARGET/usr/src/linux/include/linux/version.h
- ;;
- version)
- what=UTS_VERSION
- flag=-v
- f=$DIR_TARGET/usr/src/linux/include/linux/compile.h
- ;;
- esac
-
- if [ -f $f ]; then
- ret="`fgrep $what $f | cut -d'"' -f 2`"
- else
- ret="`uname $flag`"
- fi
- case $1 in
- release|version)
- echo "$ret"
- return 0
- ;;
- image)
- image=/boot/vmlinuz-${ret}-modular
- if [ -f ${DIR_TARGET}${image} ]; then
- echo "$image"
- return 0
- elif [ -f ${DIR_TARGET}/boot/vmlinuz ]; then
- echo "/boot/vmlinuz"
- return 0
- elif [ -f ${DIR_TARGET}/vmlinuz ]; then
- echo "/vmlinuz"
- return 0
- fi
- ;;
- esac
- return 1
- }
-
-
- Is_SCSI_Root()
- {
- Get_root dev | fgrep "/dev/sd" > /dev/null && return 0
- return 1
- }
-
-
- Set_modules_autoload()
- {
- local uname_r="`Get_kernel release`"
- local uname_v="`Get_kernel version`"
- local confpath="/etc/modules/${uname_r}"
- local driver
- local mod_file
- local param_file
- local rootdev
-
- # modules that are loaded by other means (e.g. cardmgr)
- # should never be in those static modules load lists
- local otherload_modules_file=/tmp/modules.otherload
- # FIXME: static lists are evil
- local otherload_modules_list="3c574_cs 3c575_cb 3c589_cs aha152x_cs airo airo_cs apa1480_cb cb_enabler ds dummy_cs eepro100_cb epic_cb fdomain_cs fmvj18x_cs ftl_cs i82365 ibmtr_cs ide_cs iflash2+_mtd iflash2_mtd memory_cb memory_cs netwave_cs nmclan_cs parport_cs pcmcia_core pcnet_cs qlogic_cs ray_cs serial_cb serial_cs smc91c92_cs sram_mtd tcic tulip_cb wavelan_cs wvlan_cs xirc2ps_cs"
- touch $otherload_modules_file
- for i in $otherload_modules_list ; do
- echo "$i" >> $otherload_modules_file
- done
-
- # modules loaded by LISA were stored in this file
- local lisa_modules_file=/tmp/modules.initrd
- touch $lisa_modules_file
-
- # modules already handled will be stored in this file
- local handled_modules_file=$DIR_TARGET/tmp/modules.handled
- mkdir -p $DIR_TARGET/tmp
- chmod 1777 $DIR_TARGET/tmp
- rm -f $handled_modules_file
- touch $handled_modules_file
- local never_modules="sunrpc lockd fat msdos umsdos vfat parport soundcore soundlow 8390 scsi_mod sd_mod sd sr_mod st sg nfs isofs lp slhc slip ppp ipx"
- for driver in $never_modules; do
- echo $driver >> $handled_modules_file
- done
- # modules needed for the rootfs will be stored in this file
- # FIXME12uname: because of the rebuild uname -v causes problems
- local rootfs_modules_file="$DIR_TARGET$confpath/${uname_v}.rootfs"
- mkdir -p $DIR_TARGET$confpath
- rm -f "$rootfs_modules_file"
- touch "$rootfs_modules_file"
-
- # modules not needed for the rootfs will be stored in this file
- # FIXME12uname: because of the rebuild uname -v causes problems
- local non_rootfs_modules_file="$DIR_TARGET$confpath/${uname_v}.default"
- mkdir -p $DIR_TARGET/etc/modules/options
- mkdir -p $DIR_TARGET$confpath
- rm -f "$non_rootfs_modules_file"
- touch "$non_rootfs_modules_file"
-
- # The list of modules to be autoloaded consists of 3 parts:
- # 1. modules loaded by LISA (during autoprobing and on user's request)
- local lisa_modules="`cat $lisa_modules_file`"
- # 2. modules that are loaded now (to catch manually loaded modules)
- local loaded_modules="`cat /proc/modules | cut -d' ' -f 1`"
- # 3. modules that we want always to be loaded
- #local default_modules="sunrpc lockd fat msdos umsdos vfat parport parport_pc parport_probe soundcore soundlow 8390 scsi_mod sd_mod sd sr_mod st sg nfs isofs lp slhc slip ppp ipx"
- # only
- local default_modules="parport_pc parport_probe"
-
- # The modules may be autoloaded in 2 steps:
- # 1. modules required to load the root filesystem
- # (this is only necessary if rootfs on a SCSI device)
- local need_initrd=
- # 2. other modules
-
- # check if rootfs on non IDE controller
- rootdev="`sed -n '/ \/mnt\/root /p' /proc/mounts | cut -d' ' -f 1`"
- echo $rootdev | fgrep /dev/hd >/dev/null || need_initrd=true
-
- # store modules and their params in the appropriate autoload files
- for driver in $lisa_modules $loaded_modules $default_modules ; do
- if [ -n "`fgrep -x $driver "$otherload_modules_file"`" ]; then
- continue
- fi
- if [ -n "`fgrep -x $driver "$handled_modules_file"`" ]; then
- continue
- fi
- echo "$driver" >> "$handled_modules_file"
- mod_file="$non_rootfs_modules_file"
- param_file="$DIR_TARGET/etc/modules/options/$driver"
- if [ -n "$need_initrd" ]; then
- # FIXME: dumb check for scsi (should be done by sysinfo)
- if [ -f /lib/modules/${uname_r}/kernel/drivers/scsi/$driver.o ]; then
- mod_file="$rootfs_modules_file"
- fi
- # FIXME: quick hack for public beta: aic7xxx has moved
- if [ -f /lib/modules/${uname_r}/kernel/drivers/scsi/aic7xxx/$driver.o ]; then
- mod_file="$rootfs_modules_file"
- fi
- if [ -f /lib/modules/${uname_r}/kernel/drivers/block/$driver.o ]; then
- mod_file="$rootfs_modules_file"
- fi
- fi
- echo "$driver" >> "$mod_file"
- if [ -s /etc/modules/options/$driver ]; then
- cp -a /etc/modules/options/$driver $param_file
- fi
- done
- [ -f "$rootfs_modules_file" ] && {
- mv "$rootfs_modules_file" "$rootfs_modules_file".tmp
- # 'scsi_mod' is the first thing to load in initrd...
- $need_initrd && echo "scsi_mod" > "$rootfs_modules_file"
- # then what's been found...
- cat "$rootfs_modules_file".tmp >> "$rootfs_modules_file"
- rm -f "$rootfs_modules_file".tmp
- # 'sd_mod' is the last(!) thing to be loaded in initrd...
- $need_initrd && echo "sd_mod" >> "$rootfs_modules_file"
- $need_initrd && echo "sd" >> "$rootfs_modules_file"
- }
-
- cp -a "$rootfs_modules_file" /etc/modules/rootfs
- cp -a "$rootfs_modules_file" $DIR_TARGET$confpath/rootfs
- cp -a "$non_rootfs_modules_file" $DIR_TARGET$confpath/default
- }
-
-
- Set_modules()
- {
- # fix modules:
- # - create /etc/modules/`uname -r`/"`uname -v`.default"
- Set_modules_autoload
- return 0
- }
-
-
- Prepare_Initrd()
- {
- # FIXME12uname: because of the rebuild uname -v causes problems
- local uname_r="`Get_kernel release`"
- local uname_v="`Get_kernel version`"
- local mod_file="/etc/modules/${uname_r}/${uname_v}.rootfs"
- local driver
- local moddir
- local module
- local ans
-
- # create minimal directories
- mkdir -p bin dev etc/rc.d etc/modules/${uname_r} \
- etc/modules/options lib/modules/${uname_r} sbin
-
- # create minimal devices
- mknod -m 644 dev/tty0 c 4 0
- mknod -m 644 dev/tty1 c 4 1
- ln -s tty0 dev/console
-
- # copy minimal libraries
- cp -a /lib/libc* lib
- cp -a /lib/ld.so* lib
- cp -a /etc/ld.so.conf etc
-
- # copy minimal binaries
- cp -a /bin/sh bin
- cp -a /sbin/insmod sbin
- cp -a /bin/uname bin
- cp -a /bin/cat bin
-
- for moddir in kernel/drivers/block \
- kernel/drivers/cdrom \
- kernel/drivers/net/tulip \
- kernel/drivers/ide \
- kernel/drivers/parport \
- kernel/drivers/pnp \
- kernel/drivers/sound \
- kernel/drivers/scsi \
- kernel/drivers/usb \
- kernel/net/sunrpc \
- kernel/fs \
- pcmcia ; do
- mkdir -p ./lib/modules/${uname_r}/$moddir
- done
-
- # copy rootfs module list and corresponding modules and params files
- if [ -f "$DIR_TARGET/$mod_file" ]; then
- cp -a "$DIR_TARGET/$mod_file" ./"$mod_file"
- cp -a "$DIR_TARGET/$mod_file" ./etc/modules/${uname_r}/rootfs
- cp -a "$DIR_TARGET/$mod_file" $DIR_TARGET/etc/modules/rootfs
- # copy necessary modules
- for driver in `cat "$DIR_TARGET/$mod_file"` ; do
- for moddir in kernel/drivers/block \
- kernel/drivers/cdrom \
- kernel/drivers/net \
- kernel/drivers/ide \
- kernel/drivers/parport \
- kernel/drivers/pnp \
- kernel/drivers/sound \
- kernel/drivers/scsi \
- kernel/drivers/usb \
- kernel/net/sunrpc \
- kernel/fs \
- pcmcia ; do
- module=/lib/modules/${uname_r}/$moddir/${driver}.o
- # we use the modules from the target system
- if [ -f $DIR_TARGET/$module ]; then
- mkdir -p ./lib/modules/${uname_r}/$moddir
- cp -a $DIR_TARGET/$module ./$module
- fi
- done
- if [ -s /etc/modules/options/$driver ]; then
- cp -a /etc/modules/options/$driver etc/modules/options
- fi
- done
- fi
-
- # copy module autoload routine
- cp -a /etc/rc.d/rc.rootfs etc/rc.d
-
- # this is used to trigger a initrd umount and freeramdisk in rc.boot
- touch free_initrd
-
- # create a very simple linuxrc
- echo '#!/bin/sh' > linuxrc
- echo "/bin/sh /etc/rc.d/rc.rootfs" >> linuxrc
- echo "exit 0" >> linuxrc
- chmod 755 linuxrc
- }
-
-
- Create_Initrd()
- {
- local f=$DIR_TARGET/tmp/loopfile
- local size=2880
- local mnt=$DIR_TARGET/mnt/tmp
- local img=$DIR_TARGET/boot/initrd.gz
- local dev=""
-
- mkdir -p $mnt
- Load_Default_Modules loop
- if insmod loop; then
- dev=/dev/loop0
- dd if=/dev/zero of=$f bs=1k count=$size 2> /dev/null
- [ -b $dev ] || mknod -m 666 $dev b 7 0
- losetup $dev $f
- else
- # fall back to more expensive ram-disk...
- dev=/dev/ram2
- [ -b $dev ] || mknod -m 666 $dev b 1 2
- fi
- mke2fs $dev $size 2> /dev/null
- mount -t ext2 $dev $mnt > /dev/null 2>&1
- ( cd $mnt ; Prepare_Initrd )
- umount $dev
- dd if=$dev bs=1k count=$size 2> /dev/null | gzip -9 > $img
-
- if [ $dev = /dev/loop0 ]; then
- losetup -d $dev
- rmmod loop
- rm -f $f
- else
- freeramdisk $dev
- fi
- }
-
-
- Is_DAC960_Root()
- {
- Get_root dev | fgrep "/dev/rd/" > /dev/null && return 0
- Get_root dev | fgrep "/dev/ida/" > /dev/null && return 0
- Get_root dev | fgrep "/dev/cciss/" > /dev/null && return 0
- return 1
- }
-
-
- Set_initrd()
- {
- local need_initrd=
-
- Is_SCSI_Root && need_initrd=true
- Is_DAC960_Root && need_initrd=true
- if [ -n "$need_initrd" ]; then
- # we need a initrd
- Create_Initrd
- else
- # we don't need a initrd
- rm -fr $DIR_TARGET/initrd/*
- fi
- return 0
- }
-
-
- Is_SPARC()
- {
-
- if [ "`uname -m`" = "sparc" -o "`uname -m`" = "sparc64" ]; then
- return 0
- else
- return 1
- fi
- }
-
-
- Set_lilo()
- {
- local f=$DIR_TARGET/etc/lilo.conf
- local dev="`Get_root dev`"
- local image="`Get_kernel image`"
- local append="append = \"quiet\""
- local initrd=
- local lilo_cmd=lilo
-
- if [ -f $FILE_LIZARD_RULES ]; then
- # simulate what newer lizards normally do
- mkdir -p $DIR_TARGET/etc
- if [ -n "`get_val CONF_INSTALL_LILO`" ]; then
- dev="`get_val CONF_INSTALL_LILO`"
- fi
- cat << EOF > $f
- #
- # /etc/lilo.conf - generated by Lizard
- #
-
- # target
-
- boot = $dev
- install = /boot/boot.b
-
- # options
-
- prompt
- delay = 50
- timeout = 50
- message = /boot/message
-
- default = linux
-
- EOF
- fi
- if [ -f $f ]; then
- # lizard >= 990720 creates an /etc/lilo.conf template
- # linux-kernel-binary postin script finishes the work
- # so nothing to do directly from /linuxrc any more
- return 0
- fi
- Set_initrd
- if [ -f $DIR_TARGET/boot/initrd.gz ]; then
- append="append = \"quiet\""
- initrd="initrd = /boot/initrd.gz"
- fi
- # old lizard, so we have to do everything
- mkdir -p $DIR_TARGET/boot
- if [ ! -f $DIR_TARGET/boot/message ]; then
- cp -a /boot/message $DIR_TARGET/boot/message
- fi
- mkdir -p $DIR_TARGET/etc
- cat << EOF > $f
- #
- # general section
- #
- EOF
- if Is_SPARC ; then
- cat << EOF >> $f
- partition = 1
- EOF
- else
- cat << EOF >> $f
- boot = $dev
- install = /boot/boot.b
- EOF
- fi
- cat << EOF >> $f
- message = /boot/message
- prompt
-
- # wait 5 seconds (50 10ths) for user to select the entry to load
- timeout = 50
-
- #
- # default entry
- #
-
- EOF
- cat << EOF >> $f
- image = $image
- label = linux
- root = $dev
- vga = 274
- read-only
- $append
- $initrd
-
- #
- # additional entries
- #
-
- EOF
- chmod 600 $f
- if Is_SPARC; then
- mv $f $DIR_TARGET/etc/silo.conf
- lilo_cmd=silo
- fi
- ( cd $DIR_TARGET; chroot $DIR_TARGET sbin/$lilo_cmd && echo "LILO ok" ) > $DIR_TARGET/tmp/lilo.error 2>&1
- return 0
- }
-
-
- Check_LILO()
- {
- rm -f /tmp/mbr
- if [ $# -gt 0 ]; then
- dd if=$1 bs=1 skip=2 count=4 of=/tmp/mbr 2> /dev/null
- else
- dd if=/dev/hda bs=1 skip=2 count=4 of=/tmp/mbr 2> /dev/null
- if [ ! -s /tmp/mbr ]; then
- dd if=/dev/sda bs=1 skip=2 count=4 of=/tmp/mbr 2> /dev/null
- fi
- fi
-
- if [ ! -s /tmp/mbr ]; then
- rm -f /tmp/mbr
- return 1
- else
- fgrep LILO /tmp/mbr > /dev/null
- if [ $? -eq 0 ]; then
- ANSWER="LILO"
- else
- ANSWER="unknown"
- fi
- fi
- rm -f /tmp/mbr
- return 0
- }
-
-
- Do_Analyse_Boot_Setup()
- {
- local mbr=
- local dummy=
- local bios_boot=
- local active_partitions=
- local os2_bootmgr=
- local lilo_in_mbr=
-
- # check if there is a LILO in the MBR
- mbr="`sysinfo --tag -C MBR --disk`"
- Check_LILO $mbr
- if [ $? -eq 0 -a "$ANSWER" = "LILO" ]; then
- lilo_in_mbr=true
- else
- lilo_in_mbr=false
- fi
- echo
-
- # first look for active partitions
- active_partitions="`sysinfo --tag -C active --partition`"
- if [ -z "$active_partitions" ]; then
- echo "No active partitions found!"
- else
- sysinfo --label -C active --partition
- fi
-
- if [ -n "$lilo_in_mbr" ]; then
- #echo "===> The BIOS will boot from the master boot record $mbr."
- return 0
- fi
- # the BIOS will boot from the first active partition
- bios_boot="`sysinfo --tag -C active --partition | sed -n '1p'`"
- if [ -z "$bios_boot" ]; then
- #echo "===> it seems you have no valid boot setup!"
- #echo "===> you have 2 choices to fix that:"
- #echo "A.) install a boot loader/manager in the master boot record"
- #echo " of your first hard disk."
- #echo "B.) install a boot loader/manager in a primary partition on"
- #echo " the first hard disk and activate this partition."
- #echo
- return 1
- fi
- #echo "===> The BIOS will boot the first active partition $bios_boot."
- Check_LILO $bios_boot
- if [ $? -eq 0 -a "$ANSWER" = "LILO" ]; then
- echo "===> $bios_boot seems to contain a LILO boot manager."
- else
- # check for DOSC
- if [ "$bios_boot" = "`sysinfo --tag -C DOSC --partition`" ]; then
- echo "===> $bios_boot seems to contain a DOS boot loader."
- # check for OS/2 Bootmanager
- elif [ "$bios_boot" = "`sysinfo --tag -C Bootmanager --partition | fgrep -x $bios_boot`" ]; then
- echo "===> $bios_boot seems to contain a OS/2 boot manager."
- # check for BSD Bootmanager
- elif [ "$bios_boot" = "`sysinfo --tag -C BSD --partition | fgrep -x $bios_boot`" ]; then
- echo "===> $bios_boot seems to contain a BSD boot manager."
- # check for Solaris Bootmanager
- elif [ "$bios_boot" = "`sysinfo --tag -C Solaris --partition | fgrep -x $bios_boot`" ]; then
- echo "===> $bios_boot seems to contain a Solaris boot manager."
- else
- echo "===> $bios_boot seems to contain no (or an unknown) boot manager."
- fi
- fi
- return 0
- }
-
-
- Do_Activate_Partition()
- {
- local dummy=
- local hd_dev=
- local hd_part=
-
- hd_dev=`echo "$1" | cut -d'/' -f1-3`
- if [ "$hd_dev" = "/dev/rd" ]; then
- hd_dev=`echo "$1" | cut -c 1-12`
- hd_part=`echo "$1" | cut -c 14-`
- elif [ "$hd_dev" = "/dev/ida" ]; then
- hd_dev=`echo "$1" | cut -c 1-13`
- hd_part=`echo "$1" | cut -c 15-`
- elif [ "$hd_dev" = "/dev/cciss" ]; then
- hd_dev=`echo "$1" | cut -c 1-15`
- hd_part=`echo "$1" | cut -c 17-`
- else
- hd_part=`echo "$1" | cut -c 9-`
- fi
- dummy="$hd_dev $hd_part"
- activate $dummy 2> $FILE_TMP_ERR
- if [ $? -eq 0 ]; then
- Debug ":INFO_ACTIVATE_SUCCESS:"
- else
- Debug "$1: :ERR_ACTIVATE_PROBLEMS:"
- touch $FILE_TMP_ERR
- return 1
- fi
- return 0
- }
-
-
- Get_MBR_dev()
- {
- sysinfo --tag -C MBR --disk
- }
-
-
- Replace_MBR()
- {
- local src=/boot/bsd.mbr
- local tgt=$1
- local tmpf=/tmp/mbr.new
-
- if [ ! -f $src ]; then
- Debug "could not find $src to replace $tgt"
- return 1
- fi
-
- # make a working copy of our original
- cp $src $tmpf || { Debug "cp MBR->/tmp -- no space ?"; return 1; }
-
- # merge the partition table in case there is one
- dd if=$tgt of=$tmpf bs=1 count=64 skip=446 seek=446 2> /dev/null
-
- # and write it back onto the disk
- dd if=$tmpf of=$tgt count=1 2> /dev/null && {
- Debug "sucessfully replaced $tgt with $src"
- rm -f $tmpf
- return 0
- }
-
- rm -f $tmpf
- Debug "problems replacing $tgt"
- return 1
- }
-
-
- Do_Fix_MBR()
- {
- local mbr_dev=
- local cbcode=/tmp/cmbr
-
- mbr_dev="`Get_MBR_dev`"
- if [ -z "$mbr_dev" ]; then
- Debug "Get_MBR_dev returned nothing"
- return 1
- fi
-
- # Measure the entropy of the boot code: meaningful code compresses
- # by far worse than identical byte patterns. -- td 1999-04-01
-
- dd if=$mbr_dev bs=446 count=1 2>/dev/null | gzip -9nf | \
- dd bs=70 skip=1 > $cbcode 2>/dev/null # chop off first ~70 bytes
-
- if [ -s $cbcode ]; then
- # This means there's sufficient entropy in the boot code.
- # For now be happy with that
- # (simplified approach -- see TODO below)
- rm -f $cbcode
- return 0
- fi
- rm -f $cbcode
- Debug "Compressed MBR code appears too small to work ==> replacing MBR"
- Replace_MBR $mbr_dev || return 1
- return 0
-
- # outline of complete algorithm
- # first of all examine MBR
- # if [ MBR code appears 2 B empty ]; then
- # override it with our MBR (head 446, <orig parttab>, tail 2)
- # return 0 (0 means fixed)
- # else
- # if [ ! MBR is a LILO ]; then
- # better leave it untouched
- # return 2 (2 means maybe)
- # TODO: "
- # else
- # if [ ! LILO is valid (how to test that ???)]; then
- # replace with our MBR (head 446, tail 2)
- # return 0 (0 means fixed)
- # else
- # fi
- # fi
- # "
- # fi
- }
-
-
- Set_MBR()
- {
- Do_Fix_MBR || return 1
- return 0
- #Do_Analyse_Boot_Setup
- #Do_Activate_Partition
- }
-
-
- Fix_lisa()
- {
- set_val -f $DIR_TARGET/etc/system.cnf DIR_TARGET "/"
- set_val -f $DIR_TARGET/etc/system.cnf MODE_QUERY "prompt"
- return 0
- }
-
-
- Fix_network()
- {
- # source what lizard dumped into /tmp/network
- if [ -f /tmp/network ]; then
- . /tmp/network
- else
- CONF_eth0_STAT=""
- CONF_eth0_IP="192.168.1.2"
- CONF_eth0_MASK="255.255.255.0"
- CONF_eth0_DYNAMIC=""
- CONF_ROUTER1_IP="192.168.1.1"
- CONF_FQ_HOSTNAME="noname.nodomain.nowhere"
- CONF_DNS_SERVER1_IP=""
- CONF_DNS_SERVER2_IP=""
- CONF_DNS_SERVER3_IP=""
- CONF_NIS_DOMAIN=""
- CONF_NIS_SERVER1_IP=""
- CONF_NIS_SERVER2_IP=""
- CONF_NIS_SERVER3_IP=""
- fi
-
- # append ".nodomain.nowhere" to FQHN if it was actually a shortname
- if [ -z "`echo $CONF_FQ_HOSTNAME | fgrep '.'`" ]; then
- CONF_FQ_HOSTNAME="${CONF_FQ_HOSTNAME}.nodomain.nowhere"
- fi
-
- # generate other config info
- CONF_NODENAME="`echo $CONF_FQ_HOSTNAME | cut -d'.' -f 1`"
- CONF_eth0_NAME="$CONF_FQ_HOSTNAME"
- #CONF_eth0_MASK="`do_netcalc -m $CONF_eth0_IP`"
- CONF_eth0_NET="`do_netcalc -n $CONF_eth0_IP $CONF_eth0_MASK`"
- CONF_eth0_BCAST="`do_netcalc -b $CONF_eth0_IP $CONF_eth0_MASK`"
- LINE_DYNAMIC1="DYNAMIC=$CONF_eth0_DYNAMIC"
- CONF_DNS_DOMAIN="`echo $CONF_FQ_HOSTNAME | cut -d'.' -f 2-`"
- LINE_DOMAIN="domain $CONF_DNS_DOMAIN"
- CONF_DNS_SEARCH="`echo $CONF_FQ_HOSTNAME | cut -d'.' -f 2-`"
- LINE_SEARCH="search $CONF_DNS_SEARCH"
- LINE_DNS_SERVER1=""
- LINE_DNS_SERVER2=""
- LINE_DNS_SERVER3=""
- if [ -n "$CONF_DNS_SERVER1_IP" -a "$CONF_DNS_SERVER1_IP" != "0.0.0.0" ]; then
- LINE_DNS_SERVER1="nameserver $CONF_DNS_SERVER1_IP"
- fi
- if [ -n "$CONF_DNS_SERVER2_IP" -a "$CONF_DNS_SERVER2_IP" != "0.0.0.0" ]; then
- LINE_DNS_SERVER2="nameserver $CONF_DNS_SERVER2_IP"
- fi
- if [ -n "$CONF_DNS_SERVER3_IP" -a "$CONF_DNS_SERVER3_IP" != "0.0.0.0" ]; then
- LINE_DNS_SERVER3="nameserver $CONF_DNS_SERVER3_IP"
- fi
- NETWORKING="yes"
- LINE_NETWORKING="NETWORKING=yes"
- if [ -n "`sed -e '1,3d' /proc/net/dev`" -a -n "$CONF_eth0_IP" -a "$CONF_eth0_IP" != "0.0.0.0" -a "$CONF_eth0_STAT" = "up" ]; then
- CONF_eth0_DEV="eth0"
- LINE_LOCALHOST="127.0.0.1 localhost"
- LINE_ETH0="$CONF_eth0_IP $CONF_FQ_HOSTNAME $CONF_NODENAME"
- LINE_ETH1=""
- if [ -z "$CONF_ROUTER1_IP" -o "$CONF_ROUTER1_IP" = "0.0.0.0" ]; then
- LINE_GATEWAY1="GATEWAY=none"
- else
- LINE_GATEWAY1="GATEWAY=$CONF_ROUTER1_IP"
- fi
- LINE_ONBOOT1="ONBOOT=yes"
- else
- CONF_eth0_DEV=""
- LINE_LOCALHOST="127.0.0.1 $CONF_FQ_HOSTNAME $CONF_NODENAME localhost"
- LINE_ETH0=""
- LINE_ETH1=""
- LINE_GATEWAY1="GATEWAY=none"
- LINE_ONBOOT1="ONBOOT=no"
- fi
- LINE_GATEWAY2="GATEWAY=none"
- LINE_ONBOOT2="ONBOOT=no"
- LINE_DYNAMIC2="DYNAMIC="
-
- LINE_NIS_DOMAIN=""
- LINE_NIS_SERVER1=""
- LINE_NIS_SERVER2=""
- LINE_NIS_SERVER3=""
-
- if [ -n "$CONF_NIS_DOMAIN" ]; then
- LINE_NIS_DOMAIN="domain $CONF_NIS_DOMAIN"
- # do not set domainname as it makes glibc-2.2 unhappy on boot
- # domainname $CONF_NIS_DOMAIN
- fi
- if [ -n "$CONF_NIS_SERVER1_IP" ]; then
- LINE_NIS_SERVER1="$LINE_NIS_DOMAIN server $CONF_NIS_SERVER1_IP"
- else
- LINE_NIS_SERVER2="$LINE_NIS_DOMAIN broadcast"
- fi
- if [ -n "$CONF_NIS_SERVER2_IP" ]; then
- LINE_NIS_SERVER2="ypserver $CONF_NIS_SERVER2_IP"
- fi
- if [ -n "$CONF_NIS_SERVER3_IP" ]; then
- LINE_NIS_SERVER3="ypserver $CONF_NIS_SERVER3_IP"
- fi
-
- # set /etc/system.cnf
- mkdir -p $DIR_TARGET/etc
- Set_Val CONF_FQ_HOSTNAME "$CONF_FQ_HOSTNAME"
- Set_Val CONF_NODENAME "$CONF_NODENAME"
- Set_Val CONF_eth0_STAT "$CONF_eth0_STAT"
- Set_Val CONF_eth0_DEV "$CONF_eth0_DEV"
- Set_Val CONF_eth0_NAME "$CONF_eth0_NAME"
- Set_Val CONF_eth0_IP "$CONF_eth0_IP"
- Set_Val CONF_eth0_MASK "$CONF_eth0_MASK"
- Set_Val CONF_eth0_NET "$CONF_eth0_NET"
- Set_Val CONF_eth0_BCAST "$CONF_eth0_BCAST"
- Set_Val CONF_eth0_DYNAMIC "$CONF_eth0_DYNAMIC"
- Set_Val CONF_eth1_STAT "$CONF_eth1_STAT"
- Set_Val CONF_eth1_DEV "$CONF_eth1_DEV"
- Set_Val CONF_eth1_NAME "$CONF_eth1_NAME"
- Set_Val CONF_eth1_IP "$CONF_eth1_IP"
- Set_Val CONF_eth1_MASK "$CONF_eth1_MASK"
- Set_Val CONF_eth1_NET "$CONF_eth1_NET"
- Set_Val CONF_eth1_BCAST "$CONF_eth1_BCAST"
- Set_Val CONF_eth1_DYNAMIC "$CONF_eth1_DYNAMIC"
- Set_Val CONF_ROUTER1_IP "$CONF_ROUTER1_IP"
- Set_Val CONF_DNS_DOMAIN "$CONF_DNS_DOMAIN"
- Set_Val CONF_DNS_SEARCH "$CONF_DNS_SEARCH"
- Set_Val CONF_DNS_SERVER1_IP "$CONF_DNS_SERVER1_IP"
- Set_Val CONF_DNS_SERVER2_IP "$CONF_DNS_SERVER2_IP"
- Set_Val CONF_DNS_SERVER3_IP "$CONF_DNS_SERVER3_IP"
- Set_Val CONF_NIS_DOMAIN "$CONF_NIS_DOMAIN"
- Set_Val CONF_NIS_SERVER1_IP "$CONF_NIS_SERVER1_IP"
- Set_Val CONF_NIS_SERVER2_IP "$CONF_NIS_SERVER2_IP"
- Set_Val CONF_NIS_SERVER3_IP "$CONF_NIS_SERVER3_IP"
-
- # create /etc/HOSTNAME
- cat << EOF > $DIR_TARGET/etc/HOSTNAME
- $CONF_FQ_HOSTNAME
- EOF
- chmod 644 $DIR_TARGET/etc/HOSTNAME
-
- # create /etc/hosts
- cat << EOF > $DIR_TARGET/etc/hosts
- # /etc/hosts - hostname_to_address mappings for the resolver library
- #
- # The format is:
- #
- # ipaddr fully_qualified_hostname list_of_nicknames
- #
- # We strongly recommend to use a fully qualified hostname for your machine
- # if it is connected to any type of network. You can add short nicknames as
- # you like, but the official canonical name is the name that follows the
- # IP address and should always be a fully qualified hostname.
- #
- # If you don't have any network interfaces, you should put your hostname
- # in the line of your loopback device, which has the address 127.0.0.1.
- #
- # LISA or COAS will automatically put the hostname in the right line for you.
- #
- #
- # !!! Automatically generated by lizard. Do not edit !!!
- #
- # The loopback device. It should always be available.
- #
- $LINE_LOCALHOST
- #
- # Your first IP interface (if you are connected to any kind of network)
- #
- $LINE_ETH0
-
- #
- # Your second IP interface (normally for routers only)
- #
- $LINE_ETH1
-
- #
- # If you have a nameserver we recommend to use it instead of putting many
- # hosts in this file. If you don't have a nameserver though, you can add
- # hostnames and their IP addresses below this line.
- #
- #===========================================================================
- EOF
- chmod 644 $DIR_TARGET/etc/hosts
-
- # create /etc/sysconfig/network
- mkdir -p $DIR_TARGET/etc/sysconfig
- cat << EOF > $DIR_TARGET/etc/sysconfig/network
- $LINE_NETWORKING
- HOSTNAME=$CONF_FQ_HOSTNAME
- IF_LIST='lo eth tr sl ppp'
- EOF
- chmod 644 $DIR_TARGET/etc/sysconfig/network
-
- # create /etc/sysconfig/network-scripts/ifcfg-lo
- mkdir -p $DIR_TARGET/etc/sysconfig/network-scripts
- # FIXME: check whether anything is necessary
-
- # create /etc/sysconfig/network-scripts/ifcfg-eth0
- mkdir -p $DIR_TARGET/etc/sysconfig/network-scripts
- cat << EOF > $DIR_TARGET/etc/sysconfig/network-scripts/ifcfg-eth0
- #!/bin/sh
- #>>>Device type: ethernet
- #>>>Variable declarations:
- DEVICE=$CONF_eth0_DEV
- IPADDR=$CONF_eth0_IP
- NETMASK=$CONF_eth0_MASK
- NETWORK=$CONF_eth0_NET
- BROADCAST=$CONF_eth0_BCAST
- $LINE_GATEWAY1
- $LINE_ONBOOT1
- $LINE_DYNAMIC1
- #>>>End variable declarations
- EOF
- chmod 755 $DIR_TARGET/etc/sysconfig/network-scripts/ifcfg-eth0
-
- # create /etc/resolv.conf
- cat << EOF > $DIR_TARGET/etc/resolv.conf
- # /etc/resolv.conf - DNS setup file
- #
- # possible entries are:
- #
- # domain <domain> Local domain name. If not present, the
- # gethostbyname syscall is used to
- # determine the local domain name.
- #
- # search <list_of_domains> Search list for hostname lookup.
- # The search list is normally determined
- # from the local domain name but it
- # can be set to a list of domains.
- #
- # nameserver <ip_addr> Define which server to contact
- # for DNS lookups. If there are
- # multiple nameserver lines (Max=3),
- # they are queried in the listed order.
- #
- # !!! Automatically generated by lizard. Do not edit !!!
- #
- $LINE_DOMAIN
- $LINE_SEARCH
- $LINE_DNS_SERVER1
- $LINE_DNS_SERVER2
- $LINE_DNS_SERVER3
- EOF
- chmod 644 $DIR_TARGET/etc/resolv.conf
-
- # create /etc/nis.conf
- cat << EOF > $DIR_TARGET/etc/nis.conf
- # /etc/nis.conf - NIS setup file
- #
- # possible entries are:
- #
- # domain <domain> broadcast This is the default NIS domain;
- # Broadcasts are used to find an
- # eligible server (insecure).
- # alternatively
- #
- # domain <domain> server <ip> Additionally specify which host
- # to contact for NIS service.
- #
- # ypserver <ip> Fall-Back servers for NIS can
- # be added this way for the case
- # that the primary server is down.
- #
- # !!! Automatically generated by lizard. Edit at your own risk !!!
- #
- $LINE_NIS_SERVER1
- $LINE_NIS_SERVER2
- $LINE_NIS_SERVER3
- EOF
- chmod 644 $DIR_TARGET/etc/nis.conf
-
- # prepare passwd and group for NIS
- sed '/^\+/d' $DIR_TARGET/etc/passwd > $DIR_TARGET/etc/passwd.tmp
- sed '/^\+/d' $DIR_TARGET/etc/group > $DIR_TARGET/etc/group.tmp
- if [ -n "$CONF_NIS_DOMAIN" ]; then
- # add NIS lines to passwd and group if NIS domain set
- echo "+::::::" >> $DIR_TARGET/etc/passwd.tmp
- echo "+:::" >> $DIR_TARGET/etc/group.tmp
- fi
- chmod 644 $DIR_TARGET/etc/passwd.tmp
- chmod 644 $DIR_TARGET/etc/group.tmp
- mv $DIR_TARGET/etc/passwd.tmp $DIR_TARGET/etc/passwd
- mv $DIR_TARGET/etc/group.tmp $DIR_TARGET/etc/group
-
- # force nis-client to be started if NIS domain is set
- if [ -n "$CONF_NIS_DOMAIN" ]; then
- if [ -f $DIR_TARGET/etc/sysconfig/daemons/nis-client ]; then
- set_val -f $DIR_TARGET/etc/sysconfig/daemons/nis-client ONBOOT yes
- fi
- fi
-
- return 0
- }
-
-
- Prepare_save_initrd()
- {
- # trigger a copy of the initrd we used for install under /var/tmp/initrd
- touch /save_initrd
- }
-
-
- Prepare_free_initrd()
- {
- # trigger a initrd umount and freeramdisk in rc.boot
- touch /free_initrd
- }
-
-
- Fix_language()
- {
- # source what lizard dumped into /tmp/language
- if [ -f /tmp/language ]; then
- . /tmp/language
- else
- CONF_LANGUAGE="english"
- CONF_PRINTER1_PAPER="letter"
- fi
- case $CONF_LANGUAGE in
- english|us)
- CONF_LST_LANG="us"
- CONF_PRINTER1_PAPER="letter"
- ;;
- german|de)
- CONF_LST_LANG="de"
- CONF_PRINTER1_PAPER="a4"
- ;;
- french|fr)
- CONF_LST_LANG="fr"
- CONF_PRINTER1_PAPER="a4"
- ;;
- italian|it)
- CONF_LST_LANG="it"
- CONF_PRINTER1_PAPER="a4"
- ;;
- esac
-
- # set /etc/system.cnf
- Set_Val CONF_LST_LANG "$CONF_LST_LANG"
- Set_Val CONF_PRINTER1_PAPER "$CONF_PRINTER1_PAPER"
- }
-
-
- Fix_PCMCIA()
- {
- local pcic=""
-
- if [ -s /tmp/pcmcia.chip ]; then
- pcic="`cat /tmp/pcmcia.chip`"
- set_val -f $DIR_TARGET/etc/sysconfig/pcmcia PCMCIA yes
- set_val -f $DIR_TARGET/etc/sysconfig/pcmcia PCIC $pcic
- fi
- }
-
-
- Fix_Compaq_Devices_Copy()
- {
- if [ -d /dev/ida -a ! -d $DIR_TARGET/dev/ida ]; then
- cp -aR /dev/ida $DIR_TARGET/dev/ida
- fi
- if [ -d /dev/cciss -a ! -d $DIR_TARGET/dev/cciss ]; then
- cp -aR /dev/cciss $DIR_TARGET/dev/cciss
- fi
- }
-
- Fix_Disk_Devices_Copy()
- {
- # copies already used ones, but we have 'ash', which lacks good globbing
- cp -aR /dev/hd* /dev/sd* $DIR_TARGET/dev/
- }
-
- Fix_modules()
- {
- local uname_r="`Get_kernel release`"
- local uname_v="`Get_kernel version`"
-
-
- if [ -f /etc/modules.conf ]; then
- cp -a /etc/modules.conf $DIR_TARGET/etc/modules.conf
- fi
- if [ -f /etc/modules/rootfs ]; then
- cp -a /etc/modules/rootfs $DIR_TARGET/etc/modules/rootfs
- fi
- if [ -f /etc/modules/default ]; then
- cp -a /etc/modules/default $DIR_TARGET/etc/modules/default
- fi
- # remove all old scheme modules load files
- rm -fr $DIR_TARGET/etc/modules/${uname_r}
- }
-
-
- Fix_grub_postin()
- {
- mount -t proc /proc $DIR_TARGET/proc
- ( cd $DIR_TARGET; chroot $DIR_TARGET var/adm/LST/PostIn/*grub* && echo "grub postin ok" ) > $DIR_TARGET/tmp/grub.postin.log 2>&1
- umount $DIR_TARGET/proc
- return 0
- }
-
-
- Fix_lizard_log_copy()
- {
- if [ -f /tmp/lizard.log ]; then
- cp -a /tmp/lizard.log $DIR_TARGET/tmp/lizard.log
- fi
- if [ -f /var/log/update ]; then
- cp -a /var/log/update $DIR_TARGET/var/log/update
- fi
- }
-
-
- Fix_linux_kernel_binary_postin()
- {
- local f=$DIR_TARGET/etc/lilo.conf
- local initrd=
- local recall_lilo=false
-
- # The linux-kernel-binary postin expands the template and
- # creates dynamically an initrd if needed
- mount -t proc /proc $DIR_TARGET/proc
- ( cd $DIR_TARGET; chroot $DIR_TARGET var/adm/LST/PostIn/*linux-kernel-binary* && echo "linux-kernel-binary postin ok" ) > $DIR_TARGET/tmp/linux-kernel-binary.postin.log 2>&1
- umount $DIR_TARGET/proc
-
- # If root is on /dev/rd, /dev/ida, or /dev/cciss we have to add an
- # initrd line
- Is_DAC960_Root
- if [ $? -eq 0 ]; then
- echo "found root on DAC960, cpqarray, or cciss. Need to inject initrd line." >> $DIR_TARGET/tmp/lilo.fix.log
- initrd="/boot/initrd-`uname -r`.gz"
- if [ ! -f "${DIR_TARGET}${initrd}" ]; then
- echo "No initrd found. No way to fix it." >> $DIR_TARGET/tmp/lilo.fix.log
- elif [ -z "`sed -n '/[ ]*initrd[ ]*=/p' $f`"; then
- echo "initrd found. Injecting initrd line." >> $DIR_TARGET/tmp/lilo.fix.log
- recall_lilo=true
- # cut everything up to the linux entry
- sed -n '1,/label[ ]*=[ ]*linux/p' $f > ${f}.tmp
- cat << EOF >> ${f}.tmp
- initrd = $initrd
- EOF
- sed -n '/label[ ]*=[ ]*linux/,$p' $f | sed '/label[ ]*=[ ]*linux/d' >> ${f}.tmp
- mv ${f}.tmp $f
- chmod 600 $f
- fi
- fi
-
- # If the root partition resides on a SCSI or RAID disk we enable linear
- Is_SCSI_Root || Is_DAC960_Root
- if [ $? -eq 0 ]; then
- echo "injecting linear option" >> $DIR_TARGET/tmp/lilo.fix.log
- recall_lilo=true
- # cut everything up to the install entry
- sed -n '1,/^install[ ]*=/p' $f > ${f}.tmp
- cat << EOF >> ${f}.tmp
- linear
- EOF
- sed -n '/^install[ ]*=/,$p' $f | sed '/^install[ ]*=/d' >> ${f}.tmp
- mv ${f}.tmp $f
- chmod 600 $f
- fi
-
- if [ "$recall_lilo" = "true" ]; then
- echo "recall_lilo=true. Recalling lilo." >> $DIR_TARGET/tmp/lilo.fix.log
- mount -t proc /proc $DIR_TARGET/proc
- ( cd $DIR_TARGET; chroot $DIR_TARGET sbin/lilo ) > $DIR_TARGET/tmp/lilo.again.log 2>&1
- umount $DIR_TARGET/proc
- else
- echo "recall_lilo=false. Do nothing." >> $DIR_TARGET/tmp/lilo.again.log
- fi
- return 0
- }
-
-
- Do_fix_ePanic()
- {
- local what=$1
-
- if [ "$what" = "XFree_usr_adm" ]; then
- mkdir -p $DIR_TARGET/usr/adm
- elif [ "$what" = "ide-cd" ]; then
- insmod /lib/modules/`uname -r`/kernel/drivers/cdrom/cdrom.o
- insmod /lib/modules/`uname -r`/kernel/drivers/ide/ide-cd.o
- elif [ "$what" = "no-ide-cd" ]; then
- rmmod ide-cd
- elif [ "$what" = "bootpc" ]; then
- if [ -f /floppy/bootpc.out.fake ]; then
- cp -a /floppy/bootpc.out.fake /tmp/bootpc.out
- return 0
- elif [ -f /etc/bootpc.out.fake ]; then
- cp -a /etc/bootpc.out.fake /tmp/bootpc.out
- return 0
- else
- return 1
- fi
- elif [ "$what" = "af_packet" ]; then
- insmod /lib/modules/`uname -r`/kernel/drivers/misc/af_packet.o
- elif [ "$what" = "lsmod" ]; then
- rm -f /sbin/lsmod
- ln -s insmod /sbin/lsmod
- fi
- }
-
-
- Fix_grub_menu_lst()
- {
- local f=$DIR_TARGET/boot/grub/menu.lst
-
- # ServerWorks PCI host bridges currently need noapic to work
- if [ -n "`fgrep 'Host bridge:' /proc/pci | fgrep ServerWorks`" ]; then
- sed 's/ quiet/ noapic quiet/' $f > ${f}.tmp
- chmod 644 ${f}.tmp
- mv ${f}.tmp $f
- fi
-
- # RAID devices root string is currently broken
- cp -a $DIR_LIVE_LIZARD/share/apps/lizard/fixes/fixroot.pl $DIR_TARGET/tmp/fixroot.pl
-
- mount -t proc /proc $DIR_TARGET/proc
- ( cd $DIR_TARGET; chroot $DIR_TARGET usr/bin/perl /tmp/fixroot.pl && echo "grub fix ok" ) > $DIR_TARGET/tmp/grub.fix.log 2>&1
- umount $DIR_TARGET/proc
- return 0
- }
-
-
- Do_fix()
- {
- local fixlist
- local fix
- local default_fixlist='1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19'
- local default_nextgen_fixlist='13 19' # nearly empty
-
- # we now support a parameter fix=NUM(,NUM(,NUM(...)))
- # that allows us to dynamically turn on/off fixes
- fixlist="`sed -n '/^fix=/p' /tmp/cmdline | cut -d'=' -f 2 | sed 's/,/ /g'`"
- if [ -z "$fixlist" ]; then
- fixlist="$default_fixlist"
- # Only allow the short fixlist if we are neither in LUI
- # nor in LISA (text based) install mode
- if [ -z "`sed -n '/^lizard=/s/^lizard=//p' /tmp/cmdline`" -a -z "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then
- if [ -d $DIR_LIVE_LIZARD/share/apps/lizard/fixes ]; then
- Debug "using new fix list"
- fixlist="$default_nextgen_fixlist"
- fi
- fi
- fi
-
- for fix in $fixlist ; do
- case $fix in
- 1)
- Debug "Running fix 1: Fix_etc_fstab"
- Fix_etc_fstab
- ;;
- 2)
- Debug "Running fix 2: Fix_timezone"
- Fix_timezone
- ;;
- 3)
- Debug "Running fix 3: Fix_mouse"
- Fix_mouse
- ;;
- 4)
- Debug "Running fix 4: Fix_XFree86"
- Fix_XFree86
- ;;
- 5)
- Debug "Running fix 5: Fix_network"
- Fix_network
- ;;
- 6)
- Debug "Running fix 6: Fix_logins"
- Fix_logins
- ;;
- 7)
- Debug "Running fix 7: Fix_lisa"
- Fix_lisa
- ;;
- 8)
- Debug "Running fix 8: Fix_keyboard"
- Fix_keyboard
- ;;
- 9)
- Debug "Running fix 9: Fix_language"
- Fix_language
- ;;
- 10)
- Debug "Running fix 10: Fix_PCMCIA"
- Fix_PCMCIA
- ;;
- 11)
- Debug "Running fix 11: Fix_Compaq_Devices_Copy"
- Fix_Compaq_Devices_Copy
- ;;
- 12)
- Debug "Running fix 12: Fix_Disk_Devices_Copy"
- Fix_Disk_Devices_Copy
- ;;
- 13)
- Debug "Running fix 13: Fix_modules"
- Fix_modules
- ;;
- 14)
- Debug "Running fix 14: Fix_Videomode"
- Fix_Videomode
- ;;
- 15)
- Debug "Running fix 15: Fix_override_modules"
- Fix_override_modules
- ;;
- 16)
- Debug "Running fix 16: Fix_linux_kernel_binary_postin"
- Fix_linux_kernel_binary_postin
- ;;
- 17)
- Debug "Running fix 17: Fix_grub_postin"
- Fix_grub_postin
- ;;
- 18)
- Debug "Running fix 18: Fix_lizard_log_copy"
- Fix_lizard_log_copy
- ;;
- 19)
- Debug "Running fix 19: Fix_grub_menu_lst"
- Fix_grub_menu_lst
- ;;
- esac
- # Breakpoint "After fix $fix"
- done
- }
-
-
- Copy_hwinfo()
- {
- if [ -x /bin/hwinfo ]; then
- cp -a /bin/hwinfo $DIR_TARGET/bin/hwinfo
- fi
- }
-
-
- Copy_mklizard()
- {
- if [ -x /bin/mklizard ]; then
- cp -a /bin/mklizard $DIR_TARGET/bin/mklizard
- fi
- }
-
-
- Copy_vesafb()
- {
- local trigger=/tmp/vesafb-640x480x4
-
- [ -x $trigger ] && cp -a $trigger $DIR_TARGET/var/run
- }
-
-
- Run_OpenLinux_Finish()
- {
- if [ -x $DIR_TARGET/usr/libexec/OpenLinux/finish.sh ]; then
- Debug "Running Run_OpenLinux_Finish"
- mount -t proc /proc $DIR_TARGET/proc
- ( cd $DIR_TARGET; chroot $DIR_TARGET usr/libexec/OpenLinux/finish.sh ) > $DIR_TARGET/tmp/OpenLinux.finish.log 2>&1
- umount $DIR_TARGET/proc
- fi
- }
-
-
- Run_finish()
- {
- Breakpoint "Run_finish"
- echo "Debug: Running Run_finish ..." > /dev/tty4
- Set_real_root_dev
- Set_modules
- Set_lilo
- Set_MBR
- Copy_hwinfo
- Copy_mklizard
- Copy_vesafb
- Do_fix
- Do_fix_ePanic XFree_usr_adm
- Run_OpenLinux_Finish
- echo "Debug: Run_finish reached end. ok." > /dev/tty4
- return 0
- }
-
- Get_Floppy_Version()
- {
- local floppy_num
-
- if [ -f /IDENTIFY ]; then
- floppy_num="`cut -d'#' -f 2 /IDENTIFY | cut -d' ' -f 1`"
- if [ -n "$floppy_num" ]; then
- echo "$floppy_num"
- return 0
- fi
- fi
- Debug "Ooops. Can not determine floppy version."
- return 1
- }
-
- Simple_Module_Manager()
- {
- local probe_mode=
- local insmod_param=
- local floppy_num="`Get_Floppy_Version`"
- local floppy_info
-
- if [ -n "$floppy_num" ]; then
- floppy_info=" [build ${floppy_num}]"
- fi
-
- $CMD_BOOTER add_menu "T1 Initial hardware detection${floppy_info}:"
- $CMD_BOOTER list "L1 Hardware"
- $CMD_BOOTER add "HDEVPCI Probing for PCI devices"
- $CMD_BOOTER add "HPCMCIA Probing for PCMCIA cards"
- $CMD_BOOTER add "HCDSCSI Probing for SCSI hosts"
- $CMD_BOOTER add "HCDATAPI Probing for ATAPI CDROMs"
- $CMD_BOOTER add "HCDOTHER Probing for other CDROMs"
- $CMD_BOOTER add "HETHER Probing for Ethernet cards"
- $CMD_BOOTER end
- $CMD_BOOTER show
- $CMD_BOOTER activate L1
-
- Do_Autoprobe HDEVPCI
- $CMD_BOOTER item HPCMCIA
- if [ -z "`sed -n '/^er=/p' /tmp/cmdline | fgrep nopcmcia`" ]; then
- InitPCMCIA || $CMD_BOOTER none
- else
- $CMD_BOOTER skip
- fi
- RemovePCMCIA
-
- Breakpoint "before autoprobe"
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep cautious`" ]; then
- probe_mode=cautious
- fi
-
- # do the insmod= parameter parsing
- insmod_param="`sed -n '/^insmod=/p' /tmp/cmdline | cut -d'=' -f 2- | sed 's/%/ /g'`"
- if [ -n "$insmod_param" ]; then
- if [ "$insmod_param" = "manually" ]; then
- Breakpoint --force "insert your modules manually using insmod"
- probe_mode=nothing
- elif [ "$insmod_param" = "query" ]; then
- Breakpoint --force "now we would start the module manager"
- probe_mode=query
- else
- # after the default modules were loaded, we allow one
- # particular module to be loaded with parameters
- # specified in the form install insmod=module%param%...
- # so e.g. install insmod=ne%io=0x340%irq=4
- Do_Load_Module $insmod_param
- fi
- fi
- #Do_Autoprobe all $probe_mode
- #Do_Autoprobe HDEVPCI $probe_mode
- Do_Autoprobe HCDSCSI $probe_mode
- Do_Autoprobe HCDATAPI $probe_mode
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep noothercd`" ]; then
- $CMD_BOOTER item HCDOTHER
- $CMD_BOOTER skip
- else
- Do_Autoprobe HCDOTHER $probe_mode
- fi
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep noether`" ]; then
- $CMD_BOOTER item HETHER
- $CMD_BOOTER skip
- else
- Do_Autoprobe HETHER $probe_mode
- fi
- Breakpoint "after autoprobe"
- $CMD_BOOTER complete L1
- }
-
-
- Mount_Modules_Floppy()
- {
- local floppy_type=scsi
- local need_floppy=no
-
- # in a small initrd some modules are missing, so ask for modules floppy
- if [ ! -f /lib/modules/`uname -r`/kernel/drivers/scsi/t128.o.gz ]; then
- need_floppy=yes
- fi
-
- # ask for PCMCIA floppy if supported chip but no PCMCIA modules found
- if [ -x /sbin/probe -a -n "`/sbin/probe | fgrep -v 'not found' | fgrep 'found'`" ]; then
- floppy_type=pcmcia
- if [ ! -f /lib/modules/`uname -r`/pcmcia/pcmcia_core.o.gz ]; then
- need_floppy=yes
- fi
- fi
-
- # if we explicitly say no modules floppy than overrule anything else
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep nofloppy`" ]; then
- need_floppy=no
- fi
-
- # if we explicitly request a scsi floppy then ...
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep scsi`" ]; then
- need_floppy=yes
- fi
-
- # do we need a floppy now?
- if [ "$need_floppy" = "no" ]; then
- return 0
- fi
-
- $CMD_BOOTER list "L0 Modules"
- $CMD_BOOTER add "MODULES Insert $floppy_type floppy"
- $CMD_BOOTER end
- $CMD_BOOTER show
- $CMD_BOOTER activate L0
- $CMD_BOOTER item MODULES
- while [ 1 ]; do
- sleep 10
- mount -r -t ext2 /dev/fd0H1440 /floppy > $FILE_LOG_DEBUG 2>&1
- if [ $? -eq 0 ]; then
- if [ -d /floppy/lib/modules ]; then
- $CMD_BOOTER ok
- break
- else
- umount /floppy > $FILE_LOG_DEBUG 2>&1
- fi
- fi
- if [ -z "`sed -n '/^er=/p' /tmp/cmdline | fgrep scsi`" ]; then
- $CMD_BOOTER skip
- break
- fi
- $CMD_BOOTER fail
- # jwc - sleep 5
- $CMD_BOOTER item MODULES
- done
- $CMD_BOOTER add_menu "BLANK1"
- }
-
-
- Write_hwinfo()
- {
- if [ "$FORCE_HWINFO" != "true" ]; then
- return 0
- fi
- umount /floppy > $FILE_LOG_DEBUG 2>&1
- if [ -x /bin/hwinfo ]; then
- echo "c" > /dev/tty1
- chvt 1
- echo "Running hwinfo..."
- /bin/hwinfo || return 1
- fi
- return 0
- }
-
-
- HasPCMCIA()
- {
- $CMD_BOOTER wait
- Debug "searching for PCMCIA controllers with probe:"
- /sbin/probe >/tmp/pcmcia 2>&1
- if [ $? -eq 0 ]; then
- Debug "PCMCIA chip found!"
- return 0
- else
- Debug "No supported PCMCIA chip found! Skipping PCMCIA!"
- $CMD_BOOTER none
- return 1
- fi
- }
-
-
- UnpackPCMCIA()
- {
- local i
- Breakpoint "Before UnpackPCMCIA"
- mkdir -p /lib/modules/`uname -r`/pcmcia
-
- # if we unpack PCMCIA we are tight on space, so gzip some modules
- mkdir -p /tmp/stage/fs
- mv /lib/modules/`uname -r`/kernel/fs/*/*.o /tmp/stage/fs
- gzip -9 /tmp/stage/fs/*.o
- mkdir -p /tmp/stage/scsi
- mv /lib/modules/`uname -r`/kernel/drivers/scsi/*.o /tmp/stage/scsi
- gzip -9 /tmp/stage/scsi/*.o
-
- # if we run from the modules floppy then copy pcmcia stuff
- if [ -f /floppy/sbin/cardmgr.gz ]; then
- cp -a /floppy/sbin/cardmgr.gz /sbin
- cp -aR /floppy/etc/pcmcia /etc
- for i in /floppy/lib/modules/`uname -r`/pcmcia/*.gz ; do
- if [ -f $i ]; then
- cp -a $i /lib/modules/`uname -r`/pcmcia
- fi
- done
- fi
- gunzip /lib/modules/`uname -r`/pcmcia/*.gz
- gunzip /sbin/cardmgr.gz
- gunzip /etc/pcmcia/*.gz
- Breakpoint "After UnpackPCMCIA"
- return 0
- }
-
-
- RemovePCMCIA()
- {
-
- local a
- Breakpoint "Before RemovePCMCIA"
-
- rm -f /sbin/probe
- rm -f /sbin/cardmgr
- rm -f /sbin/cardmgr.gz
- rm -fr /lib/modules/`uname -r`/pcmcia
- rm -fr /etc/pcmcia
- # restore the compressed modules in case of big initrd
- if [ -d /tmp/stage ]; then
- gunzip /tmp/stage/fs/*.gz
- for a in /tmp/stage/fs/*.o; do
- mv $a /lib/modules/`uname -r`/kernel/fs/`basename $a .o`
- done
- gunzip /tmp/stage/scsi/*.gz
- mv /tmp/stage/scsi/*.o /lib/modules/`uname -r`/kernel/drivers/scsi
- rm -fr /tmp/stage
- fi
- Breakpoint "After RemovePCMCIA"
- }
-
-
- InitPCMCIA()
- {
- local pcic=
- local chip=
- local modpath=
- local retval=1
-
- modpath=/lib/modules/`uname -r`/pcmcia
-
- HasPCMCIA || return 1
-
- # jwc - if we get here, we have pcmcia slots. unpackpcmcia, below, may
- # fail if the user hasn't inserted the pcmcia floppy, in which case we
- # won't know which type of chip we have. assume i82365, as this is a
- # safe default.
- echo i82365 > /tmp/pcmcia.chip
- # jwc
-
- UnpackPCMCIA || return 1
-
- # /bin/sh /etc/rc.d/rc.pcmcia
- # this will be replaced by rc.pcmcia
- while [ 1 ]; do
- Load_Default_Modules pcmcia_core || break
- # the chip should be derived automatically from the probe command
- # see /tmp/pcmcia
- for chip in i82365 tcic ; do
- Load_Default_Modules $chip
- if [ $? -eq 0 ]; then
- pcic=$chip
- Load_Default_Modules ds
- break
- fi
- done
- if [ -z "$pcic" ]; then break ; fi
- if [ ! -s /sbin/cardmgr ]; then break ; fi
- /sbin/cardmgr || break
- echo "$pcic" > /tmp/pcmcia.chip
- pcic="ok"
- break
- done
- if [ "$pcic" != "ok" ]; then
- if [ -z "$pcic" ]; then
- Debug "No supported PCMCIA chip found! Skipping PCMCIA!"
- $CMD_BOOTER none
- fi
- if [ -s /var/run/cardmgr.pid ]; then
- kill `cat /var/run/cardmgr.pid`
- sleep 1
- fi
- /sbin/rmmod ds >/dev/null 2>&1
- /sbin/rmmod tcic >/dev/null 2>&1
- /sbin/rmmod i82365 >/dev/null 2>&1
- /sbin/rmmod pcmcia_core >/dev/null 2>&1
- else
- Debug "$chip PCMCIA chip detected!"
- Debug "Ask to insert PCMCIA cards"
- Debug ":DO_INSERT_PCMCIA_CARDS:"
- # jwc - sleep 5
- $CMD_BOOTER ok
- retval=0
- fi
- return $retval
- }
-
-
- Make_DISK_Devices()
- {
-
- # Parse /proc/partitions for disks in the system and
- # create extra device nodes for them. Requires working makedev.
-
- (read skip ; read skip ; while read major minor size device ; do
- makedev $device
- done ) < /proc/partitions
- }
-
- Load_Override_Modules()
- {
- local i
-
- for i in /floppy/lib/modules/override/*/* ; do
- if [ -f $i ]; then
- Load_Default_Modules `basename $(echo $i | sed s'/\.o.*//')`
- fi
- done
- }
-
-
- Show_Easteregg()
- {
- $CMD_BOOTER add_menu "T5 Product completeness checker:"
- $CMD_BOOTER list "L5 Product"
- $CMD_BOOTER add "EART Final artwork and branding available"
- $CMD_BOOTER add "ELEGAL Final Readmes and Licence available"
- $CMD_BOOTER add "EPM Final 3rd party contracts signed"
- $CMD_BOOTER add "EMKTG Marketing rollout plan in place"
- $CMD_BOOTER add "ESALES Pricing and sales quota in place"
- $CMD_BOOTER add "EPROGS Announced programs in place"
- $CMD_BOOTER end
- $CMD_BOOTER show
- $CMD_BOOTER activate L5
- $CMD_BOOTER item EART
- sleep 5
- $CMD_BOOTER fail
- $CMD_BOOTER item ELEGAL
- sleep 3
- $CMD_BOOTER none
- $CMD_BOOTER item EPM
- sleep 3
- $CMD_BOOTER skip
- $CMD_BOOTER item EMKTG
- sleep 3
- $CMD_BOOTER none
- $CMD_BOOTER item ESALES
- sleep 3
- $CMD_BOOTER skip
- $CMD_BOOTER item EPROGS
- sleep 3
- $CMD_BOOTER skip
- $CMD_BOOTER add_menu "BLANKEGG"
- }
-
-
- Probe_Hardware()
- {
- Breakpoint "Probe_Hardware"
- Mount_Modules_Floppy
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep eggs`" ]; then
- Show_Easteregg
- fi
- # load override modules
- Load_Override_Modules
- Load_Default_Modules $LIST_MODULES_DEF
- # jwc - Do_fix_ePanic ide-cd
- Simple_Module_Manager
- Load_Default_Modules sd_mod sd sr_mod sg # st
- # FIXME: currently we always return 0
- return 0
- }
-
-
- # very simple printf replacement, pads string arg2 to size specified in arg1
- Pad_String()
- {
- local strmax="$1"
- local string="$2"
- local strlen
- local strpad
- local newstring=""
-
- strlen="`echo "$2" | get_info -c`"
- strlen="`do_calc $strlen - 1`"
- strpad="`do_calc $strmax - $strlen`"
- while [ $strpad -gt 0 ]; do
- newstring=" ${newstring}"
- strpad="`do_calc $strpad - 1`"
- done
- newstring="${newstring}${string}"
- echo "$newstring"
- }
-
-
- # For performance reasons call sfdisk once only and cache the output
- Create_sfdisk_Cache()
- {
- sfdisk -s 2>/dev/null > $FILE_SFDISK_CACHE
- touch $FILE_SFDISK_CACHE
- }
-
-
- # Get available disk devices
- Get_Disk_Devices()
- {
- cat $FILE_SFDISK_CACHE | sed -n '/^\/dev\//p' | cut -d':' -f 1 | sed 's/[ ]*//g'
- }
-
-
- # Get the kernel's view of the geometry of a disk
- Get_Disk_Geometry()
- {
- local disk="$1"
-
- sfdisk -g $disk 2>/dev/null | cut -d':' -f 2 | sed '{
- s/cylinders,//
- s/heads,//
- s/sectors\/track//
- }'
- }
-
-
- # Get cylinder size in sectors
- Get_Cylinder_Size()
- {
- local disk="$1"
- local tmpfile=/tmp/disksize.tmp
- local cylinders
- local heads
- local sectors
- local cylinder_size
-
- Get_Disk_Geometry $disk > $tmpfile
- read cylinders heads sectors < $tmpfile
- rm -f $tmpfile
-
- cylinder_size="`do_calc $heads \* $sectors`"
- echo "$cylinder_size"
- }
-
-
- # Get the size of the specified disk
- Get_Disk_Size()
- {
- local disk="$1"
- local tmpfile=/tmp/disksize.tmp
- local cylinders
- local heads
- local sectors
- local disk_sectors
-
- Get_Disk_Geometry $disk > $tmpfile
- read cylinders heads sectors < $tmpfile
- rm -f $tmpfile
-
- disk_sectors="`do_calc $heads \* $sectors`"
- disk_sectors="`do_calc $disk_sectors \* $cylinders`"
- disk_sectors="`do_calc $disk_sectors - 1`"
- echo "$disk_sectors"
- }
-
-
- # Read list of requested mountpoints from table
- Get_Mountpoints()
- {
- local table="$1"
-
- cat $table | sed '/^#/d' | cut -d':' -f 1
- }
-
-
- # Get the next mountpoint (or first mountpoint if no mountpoint specified)
- Next_Mountpoint()
- {
- local mountpoints="$1"
- local mountpoint
- local i
- local found="false"
-
- if [ $# -gt 1 ]; then
- mountpoint="$2"
- else
- mountpoint=""
- fi
- for i in $mountpoints ; do
- if [ -z "$mountpoint" ]; then
- echo "$i"
- break
- fi
- if [ "$found" = "true" ]; then
- echo "$i"
- break
- fi
- if [ "$i" = "$mountpoint" ]; then
- found="true"
- fi
- done
- }
-
- # round number of sectors up or down to the next cylinder boundary
- Round_Cyl()
- {
- local disk="$1"
- local direction="$2"
- local size_sectors="$3"
- local rounded_sectors
- local cylinder_size
- local cylinders
-
- cylinder_size="`Get_Cylinder_Size $disk`"
- cylinders="`do_calc $size_sectors / $cylinder_size`"
- rounded_sectors="`do_calc $cylinders \* $cylinder_size`"
- if [ "$direction" = "up" -a $rounded_sectors -lt $size_sectors ]; then
- rounded_sectors="`do_calc $rounded_sectors + $cylinder_size`"
- fi
- echo "$rounded_sectors"
- }
-
- # write one sfdisk line in dump format for the specified mountpoint
- Write_sfdisk_Entry()
- {
- local mountpoint
- local table
- local disk
- local part_num
- local start
- local outfile
- local partition
- local raw_end=
- local end=
- local size_mb
- local size_sectors
- local remain_sectors
- local part_id
- local boot_flag
- local info
- local disk_prefix
- local part_prefix
- local disk_sectors
- local next_start
- local next_sectors
-
- table="$1"
- mountpoint="$2"
- disk="$3"
- part_num="$4"
- start="$5"
- outfile="$6"
- shift 6
-
- disk_sectors="`Get_Disk_Size $disk`"
- remain_sectors="`do_calc $disk_sectors - $start`"
- remain_sectors="`do_calc $remain_sectors + 1`"
- info="`sed -n "\,^${mountpoint}:,p" $table`"
- size_mb="`echo $info | cut -d':' -f 2`"
- part_id="`echo $info | cut -d':' -f 3`"
- boot_flag="`echo $info | cut -d':' -f 4`"
- if [ -z "$size_mb" ]; then
- # as disk_sectors was calculated as a multiple of cylinders
- # we end for sure on a cylinder boundary
- size_sectors="`do_calc $disk_sectors - $start`"
- size_sectors="`do_calc $size_sectors + 1`"
- if [ $part_num -ge 4 -a $size_sectors -lt $remain_sectors ]; then
- size_sectors="`do_calc $size_sectors - 63`"
- fi
- else
- size_sectors="`do_calc $size_mb \* 2048`"
- raw_end="`do_calc $start + $size_sectors`"
- # reserve extra space for extended/logical partition chaining
- if [ $part_num -ge 4 -a $size_sectors -lt $remain_sectors ]; then
- raw_end="`do_calc $raw_end + 63`"
- fi
- # now make sure we end up on the next cylinder boundary
- raw_end="`Round_Cyl $disk up $raw_end`"
- size_sectors="`do_calc $raw_end - $start`"
- if [ $part_num -ge 4 -a $size_sectors -lt $remain_sectors ]; then
- size_sectors="`do_calc $size_sectors - 63`"
- fi
- fi
- end="`do_calc $start + $size_sectors`"
- end="`do_calc $end - 1`"
- if [ $part_num -ge 4 -a $size_sectors -lt $remain_sectors ]; then
- end="`do_calc $end + 63`"
- fi
-
- # does the requested partition fit on this disk?
- if [ $end -gt $disk_sectors ]; then
- return 1
- fi
-
- disk_prefix="`echo $disk | cut -c 6-7`"
- case $disk_prefix in
- hd|sd|xd)
- part_prefix=""
- ;;
- *)
- part_prefix="p"
- ;;
- esac
-
- partition="${disk}${part_prefix}${part_num}"
- if [ $part_num -eq 4 ]; then
- # create an extended partition
- remain_sectors="`do_calc $disk_sectors - $start`"
- remain_sectors="`do_calc $remain_sectors + 1`"
- echo "$partition : start=`Pad_String 9 $start`, size=`Pad_String 8 $remain_sectors`, Id= 5" >> $outfile
- echo >> $outfile
- start="`do_calc $start + 63`"
- fi
- if [ $part_num -ge 4 ]; then
- part_num="`do_calc $part_num + 1`"
- partition="${disk}${part_prefix}${part_num}"
- fi
- echo "$mountpoint:$partition" >> $FILE_FSINFO_MAP
- echo -n "$partition : start=`Pad_String 9 $start`, size=`Pad_String 8 $size_sectors`, Id=`Pad_String 2 $part_id`" >> $outfile
- if [ "$boot_flag" = "1" ]; then
- echo ", bootable" >> $outfile
- else
- echo >> $outfile
- fi
- if [ $part_num -ge 5 ]; then
- next_start="`do_calc $start + $size_sectors`"
- next_sectors="`do_calc $remain_sectors - $size_sectors`"
- next_sectors="`do_calc $next_sectors - 63`"
- if [ $size_sectors -lt $remain_sectors ]; then
- echo " - : start=`Pad_String 9 $next_start`, size=`Pad_String 8 $next_sectors`, Id= 5" >> $outfile
- else
- next_start="`do_calc $start - 63`"
- echo " - : start=`Pad_String 9 $next_start`, size=`Pad_String 8 0`, Id= 0" >> $outfile
- fi
- next_start="`do_calc $start - 63`"
- echo " - : start=`Pad_String 9 $next_start`, size=`Pad_String 8 0`, Id= 0" >> $outfile
- echo " - : start=`Pad_String 9 $next_start`, size=`Pad_String 8 0`, Id= 0" >> $outfile
- echo >> $outfile
- fi
- if [ $part_num -ge 5 -a $size_sectors -lt $remain_sectors ]; then
- echo "`do_calc $end + 64`"
- else
- echo "`do_calc $end + 1`"
- fi
- return 0
- }
-
-
- # Read a partitioning config file and create sfdisk dump output to stdout
- Create_sfdisk_Dump()
- {
- local disk_devices
- local mountpoints
- local mountpoint=""
- local disk
- local size
- local start=63
- local table="$1"
- local outfile="$2"
- local disk_full="false"
-
- if [ $# -ne 2 ]; then
- Panic "Usage: Create_sfdisk_Dump partitioning_config_file sfdisk_write_config_file"
- fi
- if [ ! -f "$table" ]; then
- Panic "$table: partitioning_config_file not found"
- fi
-
- rm -f $outfile
- Create_sfdisk_Cache
-
- disk_devices="`Get_Disk_Devices`"
- mountpoints="`Get_Mountpoints $table`"
- mountpoint="`Next_Mountpoint "$mountpoints"`"
-
- # We fill up disks sequentially as found by 'sfdisk'
- for disk in $disk_devices ; do
- # reset variables and print header for every new disk started
- part_num=1
- disk_full="false"
- echo "# partition table of $disk" >> $outfile
- echo "unit: sectors" >> $outfile
- echo >> $outfile
- while [ 1 ]; do
- start="`Write_sfdisk_Entry $table $mountpoint $disk $part_num $start $outfile`"
- if [ $? -ne 0 ]; then
- disk_full="true"
- start="63"
- echo >> $outfile
- break
- fi
- disk_full="false"
- mountpoint="`Next_Mountpoint "$mountpoints" $mountpoint`"
- if [ -z "$mountpoint" ]; then
- break
- fi
- part_num="`do_calc $part_num + 1`"
- done
- if [ "$disk_full" = "true" ]; then
- continue
- fi
- if [ -z "$mountpoint" ]; then
- break
- fi
- done
- if [ "$disk_full" = "true" ]; then
- Panic "You don't have enough diskspace for all the partitions"
- fi
- rm -f $FILE_SFDISK_CACHE
- return 0
- }
-
-
- Get_Dev_Of_FSINFO_MAP()
- {
- sed -n "\,^$1:,p" $FILE_FSINFO_MAP | cut -d':' -f 2
- }
-
-
- Prepare_Remaining_Partitions()
- {
- local mountpoints
- local mountpoint
- local device
- local info
- local fstype
- local format_flag
- local use_flag
- local mount_options
- local dump_flag
- local fsck_flag
- local format_cmd
- local format_opts
-
- mountpoints="`Get_Mountpoints $FILE_FSINFO_MAP`"
-
- # loop through all mountpoints
- for mountpoint in $mountpoints ; do
- # The '/' and 'swap' partitions were handled before already
- if [ "$mountpoint" = '/' -o "$mountpoint" = 'swap' ]; then
- continue
- fi
- device="`Get_Dev_Of_FSINFO_MAP $mountpoint`"
- info="`sed -n "\,^${mountpoint}:,p" $FILE_LIZARD_FSINFO`"
- fstype="`echo $info | cut -d':' -f 5`"
- if [ -z "$fstype" ]; then
- fstype="ext2"
- fi
- format_flag="`echo $info | cut -d':' -f 6`"
- use_flag="`echo $info | cut -d':' -f 7`"
- mount_options="`echo $info | cut -d':' -f 8`"
- dump_flag="`echo $info | cut -d':' -f 9`"
- fsck_flag="`echo $info | cut -d':' -f 10`"
- if [ "$format_flag" = '1' ]; then
- Debug "Creating and mounting root filesystem ($myroot)"
- format_opts=""
- case $fstype in
- ext2|ext3|reiserfs)
- if [ "$fstype" = "reiserfs" ]; then
- format_cmd="mkreiserfs"
- elif [ "$fstype" = "ext2" ]; then
- format_cmd="mke2fs"
- else
- format_cmd="mke2fs"
- format_opts="-j"
- fi
- Debug "Formating $device as $fstype with $format_cmd"
- $format_cmd $format_opts $device > /dev/tty4 2>&1 || Panic "$format_cmd $device failed"
- ;;
- *)
- Panic "Formating of type $fstype not supported"
- ;;
- esac
- fi
- if [ "$use_flag" = '1' ]; then
- Debug "Mounting $device of type $fstype to /mnt/root${mountpoint}"
- mkdir -p /mnt/root${mountpoint} > /dev/tty4 2>&1 || Panic "mkdir -p /mnt/root${mountpoint} failed"
- mount -t $fstype $device /mnt/root${mountpoint} > /dev/tty4 2>&1 || Panic "mount -t $fstype $device /mnt/root${mountpoint} failed"
- if [ -z "$mount_options" ]; then
- mount_options="defaults"
- fi
- else
- if [ -z "$mount_options" ]; then
- mount_options="defaults,noauto"
- fi
- fi
- if [ -z "$dump_flag" ]; then
- dump_flag="0"
- fi
- if [ -z "$fsck_flag" ]; then
- fsck_flag="0"
- fi
- # Write fstab entry
- mkdir -p /mnt/root/etc
- cat << EOF >> /mnt/root/etc/fstab
- $device $mountpoint $fstype $mount_options $dump_flag $fsck_flag
- EOF
- done
- }
-
-
- Run_lizard_pre_script()
- {
- local myroot
- local myswap
- local sfdisk_feed_file=/tmp/sfdisk.dump.feed
- local disks
- local disk
-
- # As the very first step run the start.sh script.
- # Put all your pre fixes and adjustments here.
- # For some ideas look at the examples in our template.
- Breakpoint "Run_lizard_pre_script"
- if [ -n "$FILE_LIZARD_START" ]; then
- if [ -f $FILE_LIZARD_START ]; then
- Debug "Running $FILE_LIZARD_START ..."
- #echo "c" > /dev/tty4
- echo "Running $FILE_LIZARD_START ..." > /dev/tty4
- chvt 4
- sh $FILE_LIZARD_START
- chvt 7
- fi
- fi
-
- if [ -z "$FILE_LIZARD_FSINFO" ]; then
- chvt 4
- # echo "Skipping fsinfo file handling (backward compatibility mode)" > /dev/tty4
- myroot="`get_val -f $FILE_LIZARD_PROFILE CONF_INSTALL_ROOT`"
- myswap="`get_val -f $FILE_LIZARD_PROFILE CONF_INSTALL_SWAP`"
- else
- if [ -f $FILE_LIZARD_FSINFO ]; then
- echo "Generating dump table for sfdisk from fsinfo file..." > /dev/tty4
- Create_sfdisk_Dump $FILE_LIZARD_FSINFO $sfdisk_feed_file
- cat $sfdisk_feed_file > /dev/tty4
- # split the file in one file per disk
- echo "# END" >> $sfdisk_feed_file
- disks="`sed -n '/^# partition table of/s/^# partition table of //p' $sfdisk_feed_file`"
- for disk in $disks ; do
- echo "Partitioning disk $disk ..."
- sed -n "\;^# partition table of $disk;,/^#/p" /tmp/sfdisk.dump.feed | sed '$,$d' > ${sfdisk_feed_file}.tmp
- cat ${sfdisk_feed_file}.tmp
- sfdisk -x $disk < ${sfdisk_feed_file}.tmp || Panic "Partitioning of disk $disk by using sfdisk failed"
- Replace_MBR $disk || Panic "Replacing of MBR of disk $disk failed"
- done
- myroot="`Get_Dev_Of_FSINFO_MAP '/'`"
- myswap="`Get_Dev_Of_FSINFO_MAP 'swap'`"
- else
- Debug "$FILE_LIZARD_FSINFO: file not found"
- retval=1
- fi
- fi
-
- if [ -n "$myswap" ]; then
- Debug "Creating and using swap space ($myswap)"
- mkswap $myswap > /dev/tty4 2>&1 || return 1
- swapon $myswap > /dev/tty4 2>&1 || return 1
- else
- Debug "Warning: no swap partition specified"
- fi
-
- if [ -n "$myroot" ]; then
- Debug "Creating and mounting root filesystem ($myroot)"
- mke2fs -j $myroot > /dev/tty4 2>&1 || return 1
- mount -t ext3 $myroot /mnt/root > /dev/tty4 2>&1 || return 1
- else
- Debug "Abort: no root partition specified"
- return 1
- fi
-
- mkdir -p /mnt/root/etc
- cat << EOF > /mnt/root/etc/fstab
- $myroot / ext3 defaults 1 1
- EOF
- if [ -n "$myswap" ]; then
- cat << EOF >> /mnt/root/etc/fstab
- $myswap swap swap defaults 0 0
- EOF
- fi
- chmod 644 /mnt/root/etc/fstab
- Prepare_Remaining_Partitions
- }
-
-
- # Copy_Val SOURCE_VARIABLE [SOURCE_FILE TARGET_VARIABLE] TARGET_FILE [DEFAULTVALUE]
- Copy_Val()
- {
- local srcvar
- # local srcfile="/etc/system.cnf"
- local srcfile="/mnt/root/etc/system.cnf"
- local tgtvar
- local tgtfile
- local defval=""
- local val=""
-
- var="$1"
- shift 1
- tgtvar="$var"
- if [ $# -gt 2 ]; then
- srcfile="$1"
- tgtvar="$2"
- shift 2
- fi
- tgtfile="$1"
- shift 1
- if [ $# -gt 0 ]; then
- defval="$1"
- shift 1
- fi
-
- if [ -f $srcfile ]; then
- val="`get_val -f $srcfile $var`"
- if [ -z "$val" ]; then
- val="$defval"
- fi
- else
- val="$defval"
- fi
- touch $tgtfile
- set_val -f $tgtfile $tgtvar "$val"
- }
-
- Retrieve_sysinfo()
- {
- local bpf=/tmp/bootpc.out
-
- # Fix_etc_fstab
- # parse provided /etc/fstab
- # create mountpoints
- # mount filesystems
-
- # Fix_timezone
- Copy_Val CONF_TIMEZONE /tmp/clock "GMT"
- Copy_Val CONF_KERNTZ_FLAG /tmp/clock "u"
-
- # Fix_mouse
- Copy_Val CONF_MOUSE1_DEV /tmp/mouse "/dev/psaux"
- Copy_Val CONF_MOUSE1_BUTTONS /tmp/mouse "3"
- Copy_Val CONF_MOUSE1_X_TYPE /tmp/mouse "ps/2"
-
- # Fix_XFree86
- Copy_Val CONF_X_SERVER1_TYPE /tmp/xserver "XFree86"
- #Copy_Val CONF_X_SERVER1_RESOL /tmp/xserver ""
- #Copy_Val CONF_X_KEYBOARD_MAP /tmp/xserver ""
-
- # Fix_network
- Copy_Val CONF_eth0_STAT /tmp/network ""
- Copy_Val CONF_eth0_IP /tmp/network "192.168.1.2"
- Copy_Val CONF_eth0_MASK /tmp/network "255.255.255.0"
- Copy_Val CONF_eth0_DYNAMIC /tmp/network ""
- Copy_Val CONF_ROUTER1_IP /tmp/network "192.168.1.1"
- Copy_Val CONF_FQ_HOSTNAME /tmp/network "noname.nodomain.none"
- Copy_Val CONF_DNS_SERVER1_IP /tmp/network ""
- Copy_Val CONF_DNS_SERVER2_IP /tmp/network ""
- Copy_Val CONF_DNS_SERVER3_IP /tmp/network ""
- Copy_Val CONF_NIS_DOMAIN /tmp/network ""
- Copy_Val CONF_NIS_SERVER1_IP /tmp/network ""
- Copy_Val CONF_NIS_SERVER2_IP /tmp/network ""
- Copy_Val CONF_NIS_SERVER3_IP /tmp/network ""
-
- # overwrite the network info if we have DHCP info
- if [ -s $bpf ]; then
- Copy_Val HOSTNAME $bpf CONF_FQ_HOSTNAME /tmp/network
- Copy_Val IPADDR $bpf CONF_eth0_IP /tmp/network
- Copy_Val NETMASK $bpf CONF_eth0_MASK /tmp/network
- Copy_Val GATEWAYS $bpf CONF_ROUTER1_IP /tmp/network
- Copy_Val DNSSRVS $bpf CONF_DNS_SERVER1_IP /tmp/network
- fi
-
- # Fix_logins
- # nothing to do
- # copy passwd and group
-
- # Fix_lisa
- # nothing to do
- # set DIR_TARGET to /
-
- # Fix_language
- # FIXME: has to be converted from CONF_LANGUAGE to CONF_LST_LANG
- Copy_Val CONF_LST_LANG /etc/system.cnf CONF_LANGUAGE /tmp/language "english"
-
-
- }
-
-
- Run_lizard_unattended()
- {
- local retval
-
- Breakpoint "Run_lizard_unattended"
- Debug "Running Run_lizard_unattended"
- chvt 4
- if [ -f $FILE_LIZARD_PKGS ]; then
- echo "Running $DIR_LIVE_LIZARD/share/apps/lizard/extrabin/instpkg.sh $FILE_LIZARD_PKGS..." > /dev/tty4
- $DIR_LIVE_LIZARD/share/apps/lizard/extrabin/instpkg.sh $FILE_LIZARD_PKGS > /dev/tty4
- else
- Debug "$FILE_LIZARD_PKGS: file not found"
- retval=1
- fi
- retval=$?
- chvt 7
- if [ $retval -eq 0 ]; then
- $CMD_BOOTER ok
- else
- $CMD_BOOTER fail
- sleep 1
- fi
- if [ -f $FILE_LIZARD_XCONFIG ]; then
- Debug "Copying XF86Config"
- mkdir -p $DIR_TARGET/etc/X11
- # cp -a $FILE_LIZARD_XCONFIG $DIR_TARGET/etc/XF86Config
- cp -a $FILE_LIZARD_XCONFIG $DIR_TARGET/etc/X11/XF86Config-4
- fi
- # cp -a $FILE_LIZARD_PROFILE /etc/system.cnf
- cp -a $FILE_LIZARD_PROFILE $DIR_TARGET/etc/system.cnf
- Debug "Retrieving system configuration"
- Breakpoint "After file copy"
- Retrieve_sysinfo
- return $retval
- }
-
-
- Run_lizard_post_script()
- {
- local eth0_ip="`get_val CONF_eth0_IP`"
- local eth0_net="`get_val CONF_eth0_NET`"
- local file_passwd=etc/passwd
- local file_shadow=etc/shadow
- local rootpw_passwd=""
- local rootpw_shadow=""
-
- chvt 4
- Debug "Running Run_lizard_post_script ..."
- Breakpoint "Before Run_lizard_post_script - what is /etc/passwd?"
- echo "Running Run_lizard_post_script ..." > /dev/tty4
-
- # get root password from an old passwd file (if available)
- file_passwd="`Lizard_File_Glob $file_passwd $eth0_ip $eth0_net`"
- if [ -n "$file_passwd" ]; then
- rootpw_passwd="`sed -n '/^root:/p' $file_passwd | cut -d':' -f 2`"
- fi
-
- # get root password from an old shadow file (if available)
- file_shadow="`Lizard_File_Glob $file_shadow $eth0_ip $eth0_net`"
- if [ -n "$file_shadow" ]; then
- rootpw_shadow="`sed -n '/^root:/p' $file_shadow | cut -d':' -f 2`"
- fi
-
-
- if [ -z "$rootpw_passwd" ]; then
- rootpw_passwd="x"
- fi
- if [ -z "$rootpw_shadow" ]; then
- rootpw_shadow="x"
- fi
-
- # if we have an old shadow password but no shadow in the target system
- # then we better take the old shadow password and put it in /etc/passwd
- if [ ! -f $DIR_TARGET/etc/shadow -a -n "$rootpw_shadow" ]; then
- rootpw_passwd="$rootpw_shadow"
- fi
-
- # Make sure we have a root password set in /etc/passwd
- if [ -z "`sed -n '/^root:/p' $DIR_TARGET/etc/passwd | cut -d':' -f 2`" ]; then
- echo "root:$rootpw_passwd:0:0:root:/root:/bin/bash" > $DIR_TARGET/etc/passwd.tmp
- sed "/^root:/d" $DIR_TARGET/etc/passwd >> $DIR_TARGET/etc/passwd.tmp
- chmod 644 $DIR_TARGET/etc/passwd.tmp
- mv $DIR_TARGET/etc/passwd.tmp $DIR_TARGET/etc/passwd
- fi
-
- # Make sure we have a root password set in /etc/shadow
- if [ -f $DIR_TARGET/etc/shadow ]; then
- echo "root:$rootpw_shadow:10547:0::7:7::" > $DIR_TARGET/etc/shadow.tmp
- sed '/^root:/d' $DIR_TARGET/etc/shadow >> $DIR_TARGET/etc/shadow.tmp
- chmod 400 $DIR_TARGET/etc/shadow.tmp
- mv $DIR_TARGET/etc/shadow.tmp $DIR_TARGET/etc/shadow
- fi
-
- # As the last step run the finish.sh script.
- # Put all your post fixes and adjustments here.
- Breakpoint "Run_lizard_post_script"
- if [ -n "$FILE_LIZARD_FINISH" ]; then
- if [ -f $FILE_LIZARD_FINISH ]; then
- Debug "Running $FILE_LIZARD_FINISH ..."
- echo "Running $FILE_LIZARD_FINISH ..." > /dev/tty4
- chvt 4
- sh $FILE_LIZARD_FINISH
- chvt 7
- fi
- fi
- }
-
-
- Do_Demo_Fake()
- {
- local dangerous_bins="/bin/instpkg.sh /bin/instpkg /sbin/lilo /sbin/mkfs.ext2 /sbin/mkswap /sbin/swapon /sbin/sfdisk"
-
- if [ "$1" = "enable" ]; then
- for i in $dangerous_bins ; do
- if [ -f $i ]; then
- mv $i $i.real
- fi
- if [ -f $DIR_LIVE_LIZARD/share/apps/lizard/extrabin/fake-`basename $i` ]; then
- ln -s $DIR_LIVE_LIZARD/share/apps/lizard/extrabin/fake-`basename $i` $i
- else
- # this one is only for fake-sfdisk and only
- # temporary until it's integrated into lizard
- ln -s fake-`basename $i` $i
- # well it's also for instpkgs.sh
- fi
- done
- elif [ "$1" = "disable" ]; then
- for i in $dangerous_bins ; do
- if [ -f $i.real ]; then
- rm -f $i
- mv $i.real $i
- fi
- done
- fi
- }
-
-
- Mini_lizard()
- {
- Do_Mount_Source || return 1
- $CMD_BOOTER complete L2
- Debug ":FOUND_VALID_SOURCE:"
- $CMD_BOOTER add_menu "BLANK3"
- $CMD_BOOTER add_menu "T3 Lycoris Install Wizard:"
- if [ -f $FILE_LIZARD_RULES ]; then
- $CMD_BOOTER add 'LIZARD Starting LUI - Lizard Unattended Install'
- else
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then
- $CMD_BOOTER add 'LIZARD Starting LISA - text based install'
- else
- $CMD_BOOTER add 'LIZARD Starting LIZARD'
- fi
- fi
- $CMD_BOOTER item LIZARD
- $CMD_BOOTER list "L3 Lizard"
- $CMD_BOOTER end
- $CMD_BOOTER show
- $CMD_BOOTER activate L3
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then
- Prepare_lisa || return 1
- else
- Prepare_lizard || return 1
- fi
- # Write hwinfo (if requested) after install source was mounted
- Write_hwinfo
- chvt 7
- if [ -f $FILE_LIZARD_RULES ]; then
- Run_lizard_pre_script || return 1
- fi
- if [ -f $FILE_LIZARD_RULES ]; then
- Run_lizard_unattended || return 1
- else
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep demo`" ]; then
- Do_Demo_Fake enable
- fi
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep text`" ]; then
- Run_lisa_install || return 1
- else
- Run_lizard_interactive || return 1
- fi
- # link all programs back to the dangerous ones
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep demo`" ]; then
- Do_Demo_Fake disable
- fi
- fi
- $CMD_BOOTER list "L4 Finish"
- $CMD_BOOTER add "FINISH Preparing to boot into new system"
- $CMD_BOOTER end
- $CMD_BOOTER show
- $CMD_BOOTER activate L4
- $CMD_BOOTER item FINISH
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep demo`" ]; then
- Set_real_root_dev || return 1
- else
- Run_finish || return 1
- fi
- $CMD_BOOTER ok
- if [ -f $FILE_LIZARD_RULES ]; then
- Run_lizard_post_script || return 1
- fi
- Unmount_install_partitions
- return 0
- }
-
-
- Check_vesafb()
- {
- cat /proc/kmsg > /tmp/kmsg &
- sleep 3; kill $! > /dev/null 2>&1
- if [ -z "`sed -n '/vesafb: mode is 640x480x4/p' /tmp/kmsg`" ]; then
- Debug "apparently not in vesafb-mode 640x480x4..."
- return 1
- fi
- touch /tmp/vesafb-640x480x4
- return 0
- }
-
-
- Main()
- {
- local retval
-
- Debug "Running new /linuxrc ..."
-
- Mini_init boot
- Check_vesafb || CMD_BOOTER=booter.text
- if [ -n "`sed -n '/^er=/p' /tmp/cmdline | fgrep eggs`" ]; then
- if [ -f /boot/stage3-egg.pcx ]; then
- mv /boot/stage3-egg.pcx /boot/stage3.pcx
- fi
- else
- rm -f /boot/stage3-egg.pcx
- fi
- $CMD_BOOTER -server
- # syslinux puts the kernel name in BOOT_IMAGE - overwrite with label
- if [ -n "`sed -n '/^BOOT_IMAGE=boot/p' /tmp/cmdline`" ]; then
- BOOT_IMAGE=boot
- fi
- if [ "$BOOT_IMAGE" = "boot" ]; then
- Probe_Hardware
- Set_real_root_dev cmdline
- else
- # goto multi user mode
- Mini_init multi
- Probe_Hardware
- # probe hardware, mount CDROM, call lizard, finish install
- Mini_lizard
- retval=$?
- if [ $retval -ne 0 ]; then
- $CMD_BOOTER fail
- Install_aborted
- fi
- # goto single user mode
- Mini_init single
- fi
- Kill_Proc_By_Name XF86_VGA16 lwm
- Kill_Proc_By_Name booter hotplugd
-
- # fix for broken docview
- Kill_Proc_By_Name docview
-
- # remove ide-cd module, so we can switch to ide-scsi mode later
- Do_fix_ePanic no-ide-cd
-
- echo "c" > /dev/tty1
- chvt 1
- echo "c" > /dev/tty7
- Mini_init shutdown
- Breakpoint "before quitting initrd"
- }
-
-
- Main
- if [ "$FORCE_REBOOT" = "true" ]; then
- /sbin/reboot
- else
- exit 0
- fi
-
-