Subversion Repositories livecd

Rev

Rev 85 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 85 Rev 100
Line 14... Line 14...
14
# - add ide-cd, sr_mod, cdrom (for SL5 cdrom support)
14
# - add ide-cd, sr_mod, cdrom (for SL5 cdrom support)
15
# - add aufs (unionfs replacement)
15
# - add aufs (unionfs replacement)
16
# - to allow LiveCD mounted over NFS (for diskless client)
16
# - to allow LiveCD mounted over NFS (for diskless client)
17
# - add functions get_dhcp_lease() and load_network_modules()
17
# - add functions get_dhcp_lease() and load_network_modules()
18
# - add ata_piix to modprobe_usb_sata_modules
18
# - add ata_piix to modprobe_usb_sata_modules
-
 
19
# - works with unionfs 2.x
-
 
20
# - better detection of network card in case of diskless client
19
#
21
#
20
 
22
 
21
# ===========================================================
23
# ===========================================================
22
# user interface functions
24
# user interface functions
23
# ===========================================================
25
# ===========================================================
Line 120... Line 122...
120
     MODULE=${MODULE%%:};   # remove : at the end, a bug 
122
     MODULE=${MODULE%%:};   # remove : at the end, a bug 
121
     TMPMOD="/tmp/`basename $MODULE .gz`";
123
     TMPMOD="/tmp/`basename $MODULE .gz`";
122
     # if the module is not loaded already
124
     # if the module is not loaded already
123
     if [ "`cat $LSMOD 2>/dev/null | egrep \"^$TMPMOD\\\$\"`" = "" ]; then
125
     if [ "`cat $LSMOD 2>/dev/null | egrep \"^$TMPMOD\\\$\"`" = "" ]; then
124
        gunzip -c $MODULE 2>/dev/null >$TMPMOD
126
        gunzip -c $MODULE 2>/dev/null >$TMPMOD
125
        if [ "$?" -ne 0 ]; then cp $MODULE $TMPMOD; fi # can't gunzip? copy
127
        if [ $? -ne 0 ]; then cp $MODULE $TMPMOD; fi # can't gunzip? copy
126
        insmod $TMPMOD $2; err=$?
128
        insmod $TMPMOD $2; err=$?
127
        ### insmod $TMPMOD $2 >/dev/null 2>/dev/null; err=$?
129
        ### insmod $TMPMOD $2 >/dev/null 2>/dev/null; err=$?
128
        if [ "$err" -eq 0 ]; then echo $TMPMOD >>$LSMOD; fi # module log
130
        if [ "$err" -eq 0 ]; then echo $TMPMOD >>$LSMOD; fi # module log
129
        rm $TMPMOD
131
        rm $TMPMOD
130
     fi
132
     fi
Line 187... Line 189...
187
# $1 = union absolute path (starting with /)
189
# $1 = union absolute path (starting with /)
188
# $2 = path to data directory
190
# $2 = path to data directory
189
#
191
#
190
union_insert_dir()
192
union_insert_dir()
191
{
193
{
-
 
194
   which unionctl >/dev/null 2>&1
-
 
195
   if [ $? -eq 0 ]; then
-
 
196
       # unionfs 1.x or aufs
192
   unionctl "$1" --add --after 0 --mode ro "$2"
197
       unionctl "$1" --add --after 0 --mode ro "$2"
-
 
198
   else
-
 
199
       # unionfs 2.x
-
 
200
       mount -t unionfs -o remount,add=:${2}=ro none "$1"
-
 
201
   fi
193
}
202
}
194
 
203
 
195
# List all modules in all directories (base, modules, optional)
204
# List all modules in all directories (base, modules, optional)
196
# and filter out unneeded optional modules (not specified by load= kernel parameter)
205
# and filter out unneeded optional modules (not specified by load= kernel parameter)
197
# $1 = root directory of mounted DATAdir
206
# $1 = root directory of mounted DATAdir
Line 244... Line 253...
244
# $2 = target directory in RAM
253
# $2 = target directory in RAM
245
#
254
#
246
copy_to_ram()
255
copy_to_ram()
247
{
256
{
248
   cp -R $1/* $2
257
   cp -R $1/* $2
249
   if [ "$?" -ne 0 ]; then fatal "can't copy to RAM, not enough memory?"; fi
258
   if [ $? -ne 0 ]; then fatal "can't copy to RAM, not enough memory?"; fi
250
}
259
}
251
 
260
 
252
# Copy content of "rootcopy" directory on the CD to $2 (union, usually)
261
# Copy content of "rootcopy" directory on the CD to $2 (union, usually)
253
# $1 = source
262
# $1 = source
254
# $2 = destination
263
# $2 = destination
Line 448... Line 457...
448
# ===========================================================
457
# ===========================================================
449
 
458
 
450
# load network modules, if NFSROOT is set
459
# load network modules, if NFSROOT is set
451
# Urs Beyerle, PSI
460
# Urs Beyerle, PSI
452
#
461
#
-
 
462
 
453
load_network_modules()
463
load_network_modules()
454
{
464
{
455
    # mii maybe need by NIC
465
    # mii maybe need by NIC
456
    echolog "load module mii"
466
    echolog "load module mii"
457
    modprobe_module mii
467
    modprobe_module mii
458
 
468
 
-
 
469
    FOUND_NIC=""
-
 
470
 
-
 
471
    # 1. load network driver defined by kernel parameter nic
-
 
472
    NIC="`cmdline_value nic`"
-
 
473
    if [ -n "$NIC" ]; then
-
 
474
	echolog "load module $NIC"
-
 
475
	modprobe_module nic
-
 
476
    fi
-
 
477
 
459
    # detecting network card
478
    # 2. detecting network card from pcitable list
460
    PCITABLE=/bin/pcitable
479
    PCITABLE=/bin/pcitable
461
    NICS=`lspci -n | awk '/Class 0200/ {print $4}' | tr ':' ' ' \
480
    NICS=`lspci -n | awk '/Class 0200/ {print $4}' | tr ':' ' ' \
462
	| while read x y ; do grep "0x$x.*0x$y" $PCITABLE \
481
	| while read x y ; do grep "0x$x.*0x$y" $PCITABLE \
463
	| awk '$3 !~ /"unknown"/ {print $3}' | tr -d '"' ; done`
482
	| awk '$3 !~ /"unknown"/ {print $3}' | tr -d '"' ; done`
464
    echolog "Found network card(s): $NICS"
-
 
465
    
483
    
466
    if [ -n "$NICS" ]; then
484
    if [ -n "$NICS" ]; then
467
	echo $NICS | while read nic ; do
485
	echolog "found network card(s): $NICS"
-
 
486
	for nic in $NICS; do
468
	    echo "Loading module $nic"
487
	    echolog "load module $nic"
469
	    modprobe_module $nic
488
	    modprobe_module $nic
-
 
489
	    FOUND_NIC="yes"
470
	done
490
	done
-
 
491
    fi
-
 
492
 
-
 
493
    # 3. probe for more network card drivers, if no ethX devices found
-
 
494
    for iface in eth0 eth1 eth2 eth3; do
-
 
495
	ifconfig $iface > /dev/null 2>&1
-
 
496
	if [ $? -eq 0 ]; then  FOUND_NIC="yes"; break; fi
471
    else
497
    done
-
 
498
    if [ -z $FOUND_NIC ]; then
-
 
499
	KERNEL="`uname -r`"
-
 
500
	NETDRIVERS="`cat /lib/modules/$KERNEL/netdrivers`"
-
 
501
	for driver in $NETDRIVERS; do
-
 
502
	    modprobe_module $driver
-
 
503
	    ifconfig $iface > /dev/null 2>&1
-
 
504
	    if [ $? -eq 0 ]; then 
-
 
505
		echolog "load $driver"
-
 
506
		FOUND_NIC="yes"
-
 
507
		break
-
 
508
	    fi
-
 
509
	    rmmod $driver
-
 
510
	done
-
 
511
    fi
-
 
512
		
-
 
513
    # 4. ask the user for a network driver
-
 
514
    if [ -z $FOUND_NIC ]; then
472
	echo "ERROR: No network card detected!"
515
	echo "ERROR: No network card detected!"
473
	echo "Type in your network card driver (e.g. tg3, e1000). "
516
	echo "Type in your network card driver (e.g. tg3, e1000). "
474
	echo "Or ask your system administrator for help."
517
	echo "Or ask your system administrator for help."
475
	echo -n "Network card driver: "
518
	echo -n "Network card driver: "
476
	read nic
519
	read nic
477
	echo "Loading module $nic"
520
	echo "Load module $nic"
478
	modprobe_module $nic
521
	modprobe_module $nic
479
    fi
522
    fi
480
}
523
}
481
 
524
 
482
# get DHCP lease
525
# get DHCP lease