Subversion Repositories livecd

Rev

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

Rev 1 Rev 36
Line 11... Line 11...
11
 
11
 
12
 
12
 
13
echolog "mounting /proc and /sys filesystems"
13
echolog "mounting /proc and /sys filesystems"
14
mount -t proc proc /proc
14
mount -t proc proc /proc
15
mount -t sysfs sysfs /sys
15
mount -t sysfs sysfs /sys
-
 
16
ln -sf /proc/mounts /etc/mtab # this allows us to use umount -a
16
 
17
 
17
# setup DEBUGCMD variable. If debug boot option is present, call debug()
18
# setup DEBUGCMD variable. If debug boot option is present, call debug()
18
# function several times during script's execution
19
# function several times during script's execution
19
if [ "`cmdline_parameter debug`" ]; then DEBUGCMD="debug"; else DEBUGCMD=""; fi
20
if [ "`cmdline_parameter debug`" ]; then DEBUGCMD="debug"; else DEBUGCMD=""; fi
20
 
21
 
21
$DEBUGCMD
22
$DEBUGCMD
22
 
23
 
-
 
24
# amount of RAM to store changes
-
 
25
RAMSIZE="`cmdline_value ramsize`"
-
 
26
if [ "$RAMSIZE" = "" ]; then RAMSIZE="70%"; fi
-
 
27
 
23
# I have to set these variables very carefully
28
# I have to set these variables very carefully
24
UNION=/union
29
UNION=/union
25
MEMORY=/memory
30
MEMORY=/memory
26
#MOUNTDIR=mnt
31
#MOUNTDIR=mnt
27
MOUNTDIR=livecd
32
MOUNTDIR=livecd
Line 37... Line 42...
37
modprobe_essential_modules
42
modprobe_essential_modules
38
setup_dma
43
setup_dma
39
 
44
 
40
$DEBUGCMD
45
$DEBUGCMD
41
 
46
 
42
# load network modules, if NFSROOT is set
47
# if NFSROOT is set:
43
echolog "check for nfsroot"
48
echolog "check for nfsroot"
44
if [ "$NFSROOT" != "" ]; then
49
if [ "$NFSROOT" != "" ]; then
-
 
50
 
-
 
51
   # load network modules, if NFSROOT is set
45
   echolog "nfsroot: $NFSROOT"
52
   echolog "nfsroot: $NFSROOT"
46
   # mii maybe need by NIC
-
 
47
   echolog "load module mii"
-
 
48
   modprobe_module mii
53
   load_network_modules
49
 
-
 
50
   # detecting network card
-
 
51
   PCITABLE=/bin/pcitable
-
 
52
   NICS=`lspci -n | awk '/Class 0200/ {print $4}' | tr ':' ' ' \
-
 
53
   | while read x y ; do grep "0x$x.*0x$y" $PCITABLE \
-
 
54
   | awk '$3 !~ /"unknown"/ {print $3}' | tr -d '"' ; done`
-
 
55
   echolog "Found network card(s): $NICS"
-
 
56
 
-
 
57
   if [ -n "$NICS" ]; then
-
 
58
       echo $NICS | while read nic ; do
-
 
59
	   echo "Loading module $nic"
-
 
60
	   modprobe_module $nic
-
 
61
       done
-
 
62
   else
-
 
63
       echo "ERROR: No network card detected!"
-
 
64
       echo "Type in your network card driver (e.g. tg3, e1000). "
-
 
65
       echo "Or ask your system administrator for help."
-
 
66
       echo -n "Network card driver: "
-
 
67
       read nic
-
 
68
       echo "Loading module $nic"
-
 
69
       modprobe_module $nic
-
 
70
   fi
-
 
71
fi
-
 
72
 
54
 
73
$DEBUGCMD
55
   $DEBUGCMD
74
 
56
 
75
# get DHCP lease
57
   # get DHCP lease
76
if [ "$NFSROOT" != "" ]; then
-
 
77
    # create /dev/urandom (needed by udhcpc)
-
 
78
    mknod /dev/urandom c 1 9
-
 
79
    echolog "Try to get DHCP lease on eth0"
58
   echolog "get DHCP lease"
80
    udhcpc --now --quit --interface=eth0 --script=/bin/udhcpc.script
-
 
81
    if [ $? -ne 0 ]; then
59
   get_dhcp_lease
82
	echo "ERROR: couldn't get DHCP lease, trying again"
-
 
83
	udhcpc --now --quit --interface=eth0 --script=/bin/udhcpc.script
-
 
84
	if [ $? -ne 0 ]; then
-
 
85
	    echo "ERROR: couldn't get DHCP lease, trying eth1"
-
 
86
	    udhcpc --now --quit --interface=eth1 --script=/bin/udhcpc.script
-
 
87
	    if [ $? -ne 0 ]; then
-
 
88
		echo "ERROR: couldn't get DHCP lease, trying again eth1"
-
 
89
		udhcpc --now --quit --interface=eth1 --script=/bin/udhcpc.script
-
 
90
		if [ $? -ne 0 ]; then
-
 
91
		    echo "ERROR: can't get DHCP lease on eth0 and eth1"
-
 
92
		fi
-
 
93
	    fi
-
 
94
	fi
-
 
95
    fi
-
 
96
fi
-
 
97
 
60
   
98
$DEBUGCMD
61
   $DEBUGCMD
99
 
62
 
100
# we need nfs modules loaded, if NFSROOT is set
63
    # we need nfs modules loaded, if NFSROOT is set
101
if [ "$NFSROOT" != "" ]; then
-
 
102
    modprobe_nfs_modules
64
    modprobe_nfs_modules
-
 
65
 
103
fi
66
fi
104
 
67
 
105
$DEBUGCMD
68
$DEBUGCMD
106
 
69
 
107
# $UNION will be used as a root directory, livecd modules will be added soon.
70
# $UNION will be used as a root directory, livecd modules will be added soon.
Line 115... Line 78...
115
   mount_device $CHANGESDEV $MEMORY
78
   mount_device $CHANGESDEV $MEMORY
116
else false; fi
79
else false; fi
117
 
80
 
118
# mount tmpfs only in the case when changes= boot parameter was empty
81
# mount tmpfs only in the case when changes= boot parameter was empty
119
# or we were not able to mount the storage device
82
# or we were not able to mount the storage device
120
if [ $? -ne 0 ]; then mount -t tmpfs -o "size=80%" tmpfs $MEMORY; fi
83
if [ $? -ne 0 ]; then mount -t tmpfs -o "size=$RAMSIZE" tmpfs $MEMORY; fi
121
 
84
 
122
mkdir -p $CHANGES
85
mkdir -p $CHANGES
123
mkdir -p $COPY2RAM
86
mkdir -p $COPY2RAM
124
mkdir -p $IMAGES
87
mkdir -p $IMAGES
125
mount -t unionfs -o dirs=$CHANGES=rw unionfs $UNION
88
mount -t unionfs -o dirs=$CHANGES=rw unionfs $UNION
Line 174... Line 137...
174
# More likely these directories aren't there.
137
# More likely these directories aren't there.
175
# Even if they are, this won't hurt.
138
# Even if they are, this won't hurt.
176
mkdir -p $UNION/proc
139
mkdir -p $UNION/proc
177
mkdir -p $UNION/sys
140
mkdir -p $UNION/sys
178
mkdir -p $UNION/tmp
141
mkdir -p $UNION/tmp
-
 
142
chmod 1777 $UNION/tmp
179
mkdir -p $UNION/dev
143
mkdir -p $UNION/dev
-
 
144
mkdir -p $UNION/initrd
180
 
145
 
181
$DEBUGCMD
146
$DEBUGCMD
182
 
147
 
183
# Union contains all the files and directories unioned from all modules.
148
# Union contains all the files and directories unioned from all modules.
184
# Change root directory to it, and move initrd's root to /livecd/live/initramdisk
149
# Change root directory to it, and move initrd's root to /livecd/live/initramdisk
Line 201... Line 166...
201
cat $UNION/bin/true >/dev/null
166
cat $UNION/bin/true >/dev/null
202
 
167
 
203
$DEBUGCMD
168
$DEBUGCMD
204
 
169
 
205
pivot_root . $INITRAMDISK
170
pivot_root . $INITRAMDISK
206
exec $CHROOT . sbin/init <dev/console >dev/console 2>&1; fi
171
exec $CHROOT . sbin/init <dev/console >dev/console 2>&1
207
 
172
 
208
header "ERROR!"
173
header "ERROR!"
209
echolog "You are not supposed to be here, something went wrong!"
174
echolog "You are not supposed to be here, something went wrong!"
210
echolog "Even Ctrl+Alt+Del won't help you in kernel panic."
175
echolog "Even Ctrl+Alt+Del won't help you in kernel panic."
211
 
176