Subversion Repositories livecd

Rev

Rev 185 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 185 Rev 205
1
#!/bin/ash
1
#!/bin/ash
2
#
2
#
3
# Functions library :: for Linux Live scripts 5.x.y
3
# Functions library :: for Linux Live scripts 5.x.y
4
# Author: Tomas M. <http://www.linux-live.org>
4
# Author: Tomas M. <http://www.linux-live.org>
5
#
5
#
6
# modified by Urs Beyerle
6
# modified by Urs Beyerle
7
# - to allow LiveCD mounted over nfs
7
# - to allow LiveCD mounted over nfs
8
# - add scsi_mod, sd_mod for usb-storage module
8
# - add scsi_mod, sd_mod for usb-storage module
9
# - only with boot option "automount", all devices in fstab are rw automounted
9
# - only with boot option "automount", all devices in fstab are rw automounted
10
# - remove detect of CD and Floppy (done by fstab-sync)
10
# - remove detect of CD and Floppy (done by fstab-sync)
11
# - add sr_mod (USB CDROM support)
11
# - add sr_mod (USB CDROM support)
12
# - add SATA to modprobe_usb_modules -> modprobe_usb_sata_modules
12
# - add SATA to modprobe_usb_modules -> modprobe_usb_sata_modules
13
# - add fscache (for SL5) 
13
# - add fscache (for SL5) 
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
19
# - works with unionfs 2.x
20
# - better detection of network card in case of diskless client
20
# - better detection of network card in case of diskless client
21
# - add sg, sata_nv module
21
# - add sg, sata_nv module
22
# - to allow LiveCD mounted over CIFS (for diskless client)
22
# - to allow LiveCD mounted over CIFS (for diskless client)
23
# - add function find_changes
23
# - add function find_changes
-
 
24
# - add sata_svw
24
#
25
#
25
 
26
 
26
# ===========================================================
27
# ===========================================================
27
# user interface functions
28
# user interface functions
28
# ===========================================================
29
# ===========================================================
29
 
30
 
30
# echolog
31
# echolog
31
# $1 = text to show and to write to /var/log/messages
32
# $1 = text to show and to write to /var/log/messages
32
#
33
#
33
echolog()
34
echolog()
34
{
35
{
35
   echo "LIVECD:" "$@" >>/var/log/livedbg
36
   echo "LIVECD:" "$@" >>/var/log/livedbg
36
   echo "$@"
37
   echo "$@"
37
}
38
}
38
 
39
 
39
# debug
40
# debug
40
# commands executed when debug boot parameter is present
41
# commands executed when debug boot parameter is present
41
#
42
#
42
debug()
43
debug()
43
{
44
{
44
   echo
45
   echo
45
   echo "====="
46
   echo "====="
46
   echo ": Debugging started. Here is the root shell for you."
47
   echo ": Debugging started. Here is the root shell for you."
47
   echo ": Type your desired command or hit Ctrl+D to continue booting."
48
   echo ": Type your desired command or hit Ctrl+D to continue booting."
48
   echo
49
   echo
49
   ash
50
   ash
50
}
51
}
51
 
52
 
52
# header
53
# header
53
# $1 = text to show
54
# $1 = text to show
54
#
55
#
55
header()
56
header()
56
{
57
{
57
   echolog "$1"
58
   echolog "$1"
58
}
59
}
59
 
60
 
60
fatal()
61
fatal()
61
{
62
{
62
   header "Fatal error occured - $1"
63
   header "Fatal error occured - $1"
63
   echolog "Something went wrong and we can't continue booting :("
64
   echolog "Something went wrong and we can't continue booting :("
64
   echolog "You may explore the system by using simple commands like ls, lsmod, mount, etc."
65
   echolog "You may explore the system by using simple commands like ls, lsmod, mount, etc."
65
   echolog "You may also try to hit Ctrl+D. Booting will continue. Use at your own risk."
66
   echolog "You may also try to hit Ctrl+D. Booting will continue. Use at your own risk."
66
   echolog "To be safe, hit Ctrl+Alt+Delete to reboot."
67
   echolog "To be safe, hit Ctrl+Alt+Delete to reboot."
67
   echolog
68
   echolog
68
   ash
69
   ash
69
}
70
}
70
 
71
 
71
# ===========================================================
72
# ===========================================================
72
# text processing functions
73
# text processing functions
73
# ===========================================================
74
# ===========================================================
74
 
75
 
75
# egrep_o is a replacement for "egrep -o". It prints only the last
76
# egrep_o is a replacement for "egrep -o". It prints only the last
76
# matching text
77
# matching text
77
# $1 = regular expression
78
# $1 = regular expression
78
#
79
#
79
egrep_o()
80
egrep_o()
80
{
81
{
81
   cat | egrep "$1" | sed -r "s/.*($1).*/\\1/"
82
   cat | egrep "$1" | sed -r "s/.*($1).*/\\1/"
82
}
83
}
83
 
84
 
84
# look into cmdline and echo $1 back if $1 is set
85
# look into cmdline and echo $1 back if $1 is set
85
# $1 = value name, case sensitive, for example livecd_subdir
86
# $1 = value name, case sensitive, for example livecd_subdir
86
# $2 = file to use instead /proc/cmdline, optional
87
# $2 = file to use instead /proc/cmdline, optional
87
#
88
#
88
cmdline_parameter()
89
cmdline_parameter()
89
{
90
{
90
   CMDLINE=/proc/cmdline
91
   CMDLINE=/proc/cmdline
91
   if [ "$2" != "" ]; then CMDLINE="$2"; fi
92
   if [ "$2" != "" ]; then CMDLINE="$2"; fi
92
   cat "$CMDLINE" | egrep_o "(^|[[:space:]]+)$1(\$|=|[[:space:]]+)" | egrep_o "$1"
93
   cat "$CMDLINE" | egrep_o "(^|[[:space:]]+)$1(\$|=|[[:space:]]+)" | egrep_o "$1"
93
}
94
}
94
 
95
 
95
# look into cmdline and echo value of $1 option
96
# look into cmdline and echo value of $1 option
96
# $1 = value name, case sensitive, for example livecd_subdir
97
# $1 = value name, case sensitive, for example livecd_subdir
97
# $2 = file to use instead /proc/cmdline, optional
98
# $2 = file to use instead /proc/cmdline, optional
98
#
99
#
99
cmdline_value()
100
cmdline_value()
100
{
101
{
101
   CMDLINE=/proc/cmdline
102
   CMDLINE=/proc/cmdline
102
   if [ "$2" != "" ]; then CMDLINE="$2"; fi
103
   if [ "$2" != "" ]; then CMDLINE="$2"; fi
103
   cat "$CMDLINE" | egrep_o "(^|[[:space:]]+)$1=([^[:space:]]+)" | egrep_o "=.*" | cut -b 2- | tail -n 1
104
   cat "$CMDLINE" | egrep_o "(^|[[:space:]]+)$1=([^[:space:]]+)" | egrep_o "=.*" | cut -b 2- | tail -n 1
104
}
105
}
105
 
106
 
106
# ===========================================================
107
# ===========================================================
107
# system functions
108
# system functions
108
# ===========================================================
109
# ===========================================================
109
 
110
 
110
# modprobe module $1, including all dependencies, suppress all messages
111
# modprobe module $1, including all dependencies, suppress all messages
111
# (own function because modprobe in busybox doesn't work with gzipped modules)
112
# (own function because modprobe in busybox doesn't work with gzipped modules)
112
# $1 = module name, eg. ehci-hcd
113
# $1 = module name, eg. ehci-hcd
113
# $2 = optional argument
114
# $2 = optional argument
114
#
115
#
115
modprobe_module()
116
modprobe_module()
116
{
117
{
117
  if [ "$1" = "" ]; then return 1; fi
118
  if [ "$1" = "" ]; then return 1; fi
118
  PRINTK=`cat /proc/sys/kernel/printk`
119
  PRINTK=`cat /proc/sys/kernel/printk`
119
  echo "0" >/proc/sys/kernel/printk
120
  echo "0" >/proc/sys/kernel/printk
120
 
121
 
121
  KERNEL="`uname -r`"; LSMOD=/tmp/lsmod
122
  KERNEL="`uname -r`"; LSMOD=/tmp/lsmod
122
  MODULEDEPS="`cat /lib/modules/$KERNEL/modules.dep | egrep \"$1\\.ko(\\.gz)?:\"`"
123
  MODULEDEPS="`cat /lib/modules/$KERNEL/modules.dep | egrep \"$1\\.ko(\\.gz)?:\"`"
123
 
124
 
124
  for MODULE in `echo $MODULEDEPS | cut -d ":" -f 2-` `echo $MODULEDEPS | cut -d ":" -f 1`; do
125
  for MODULE in `echo $MODULEDEPS | cut -d ":" -f 2-` `echo $MODULEDEPS | cut -d ":" -f 1`; do
125
     MODULE=${MODULE%%:};   # remove : at the end, a bug 
126
     MODULE=${MODULE%%:};   # remove : at the end, a bug 
126
     TMPMOD="/tmp/`basename $MODULE .gz`";
127
     TMPMOD="/tmp/`basename $MODULE .gz`";
127
     # if the module is not loaded already
128
     # if the module is not loaded already
128
     if [ "`cat $LSMOD 2>/dev/null | egrep \"^$TMPMOD\\\$\"`" = "" ]; then
129
     if [ "`cat $LSMOD 2>/dev/null | egrep \"^$TMPMOD\\\$\"`" = "" ]; then
129
        gunzip -c $MODULE 2>/dev/null >$TMPMOD
130
        gunzip -c $MODULE 2>/dev/null >$TMPMOD
130
        if [ $? -ne 0 ]; then cp $MODULE $TMPMOD; fi # can't gunzip? copy
131
        if [ $? -ne 0 ]; then cp $MODULE $TMPMOD; fi # can't gunzip? copy
131
        insmod $TMPMOD $2; err=$?
132
        insmod $TMPMOD $2; err=$?
132
        ### insmod $TMPMOD $2 >/dev/null 2>/dev/null; err=$?
133
        ### insmod $TMPMOD $2 >/dev/null 2>/dev/null; err=$?
133
        if [ "$err" -eq 0 ]; then echo $TMPMOD >>$LSMOD; fi # module log
134
        if [ "$err" -eq 0 ]; then echo $TMPMOD >>$LSMOD; fi # module log
134
        rm $TMPMOD
135
        rm $TMPMOD
135
     fi
136
     fi
136
  done
137
  done
137
 
138
 
138
  echo "$PRINTK" >/proc/sys/kernel/printk
139
  echo "$PRINTK" >/proc/sys/kernel/printk
139
  if [ "$err" -ne 0 ]; then echolog "error inserting module $1 ($err)"; fi
140
  if [ "$err" -ne 0 ]; then echolog "error inserting module $1 ($err)"; fi
140
  return $err
141
  return $err
141
}
142
}
142
 
143
 
143
# Mount device $1 to $2
144
# Mount device $1 to $2
144
# $1 = /dev device to mount, eg. /dev/hda1
145
# $1 = /dev device to mount, eg. /dev/hda1
145
# $2 = mountpoint, eg. /mnt/hda1
146
# $2 = mountpoint, eg. /mnt/hda1
146
# $3 = mount options, for example "loop", "ro", or "remount,rw"
147
# $3 = mount options, for example "loop", "ro", or "remount,rw"
147
#
148
#
148
mount_device()
149
mount_device()
149
{
150
{
150
  mkdir -p $2
151
  mkdir -p $2
151
  if [ "$3" != "" ]; then OPTIONS="-o $3"; else OPTIONS=""; fi
152
  if [ "$3" != "" ]; then OPTIONS="-o $3"; else OPTIONS=""; fi
152
 
153
 
153
  PRINTK=`cat /proc/sys/kernel/printk`
154
  PRINTK=`cat /proc/sys/kernel/printk`
154
  echo "0" >/proc/sys/kernel/printk
155
  echo "0" >/proc/sys/kernel/printk
155
 
156
 
156
  mount -t auto $1 $2 $OPTIONS >/dev/null 2>/dev/null
157
  mount -t auto $1 $2 $OPTIONS >/dev/null 2>/dev/null
157
  err=$?
158
  err=$?
158
 
159
 
159
  if [ "$err" -ne 0 ]; then rmdir $2 2>/dev/null; fi
160
  if [ "$err" -ne 0 ]; then rmdir $2 2>/dev/null; fi
160
  echo "$PRINTK" >/proc/sys/kernel/printk
161
  echo "$PRINTK" >/proc/sys/kernel/printk
161
  return $err
162
  return $err
162
}
163
}
163
 
164
 
164
# ===========================================================
165
# ===========================================================
165
# live module functions
166
# live module functions
166
# ===========================================================
167
# ===========================================================
167
 
168
 
168
# Create module
169
# Create module
169
# call mksquashfs with apropriate arguments
170
# call mksquashfs with apropriate arguments
170
# $1 = directory which will be compressed to squashfs module
171
# $1 = directory which will be compressed to squashfs module
171
# $2 = output .mo file
172
# $2 = output .mo file
172
# $3 = optional -keep-as-directory argument
173
# $3 = optional -keep-as-directory argument
173
#
174
#
174
create_module()
175
create_module()
175
{
176
{
176
   mksquashfs $1 $2 $3 >/dev/null
177
   mksquashfs $1 $2 $3 >/dev/null
177
   if [ $? -ne 0 ]; then return 1; fi
178
   if [ $? -ne 0 ]; then return 1; fi
178
   chmod oga-x $2 # remove execute attrib
179
   chmod oga-x $2 # remove execute attrib
179
}
180
}
180
 
181
 
181
# Mount .mo module to destination directory
182
# Mount .mo module to destination directory
182
# $1 = path to .mo livecd compressed module
183
# $1 = path to .mo livecd compressed module
183
# $2 = destination folder
184
# $2 = destination folder
184
#
185
#
185
mount_module()
186
mount_module()
186
{
187
{
187
   mount -t squashfs -o loop,ro $1 $2
188
   mount -t squashfs -o loop,ro $1 $2
188
}
189
}
189
 
190
 
190
# Insert a directory tree $2 to an union specified by $1
191
# Insert a directory tree $2 to an union specified by $1
191
# Top-level read-write branch is specified by it's index 0
192
# Top-level read-write branch is specified by it's index 0
192
# $1 = union absolute path (starting with /)
193
# $1 = union absolute path (starting with /)
193
# $2 = path to data directory
194
# $2 = path to data directory
194
#
195
#
195
union_insert_dir()
196
union_insert_dir()
196
{
197
{
197
   which unionctl >/dev/null 2>&1
198
   which unionctl >/dev/null 2>&1
198
   if [ $? -eq 0 ]; then
199
   if [ $? -eq 0 ]; then
199
       # unionfs 1.x or aufs
200
       # unionfs 1.x or aufs
200
       unionctl "$1" --add --after 0 --mode ro "$2"
201
       unionctl "$1" --add --after 0 --mode ro "$2"
201
   else
202
   else
202
       # unionfs 2.x
203
       # unionfs 2.x
203
       mount -t unionfs -o remount,add=:${2}=ro none "$1"
204
       mount -t unionfs -o remount,add=:${2}=ro none "$1"
204
   fi
205
   fi
205
}
206
}
206
 
207
 
207
# List all modules in all directories (base, modules, optional)
208
# List all modules in all directories (base, modules, optional)
208
# and filter out unneeded optional modules (not specified by load= kernel parameter)
209
# and filter out unneeded optional modules (not specified by load= kernel parameter)
209
# $1 = root directory of mounted DATAdir
210
# $1 = root directory of mounted DATAdir
210
#
211
#
211
list_modules()
212
list_modules()
212
{
213
{
213
   LOAD="`cmdline_value load`"
214
   LOAD="`cmdline_value load`"
214
   ls -A1d $1/*.mo $1/*/*.mo 2>/dev/null | while read LINE; do
215
   ls -A1d $1/*.mo $1/*/*.mo 2>/dev/null | while read LINE; do
215
      MODNAME="`basename $LINE .mo`"
216
      MODNAME="`basename $LINE .mo`"
216
      if [ "$LOAD" != "*" -a "`echo $LINE | grep optional`" != "" -a "`echo $LOAD | egrep \"(^|,)$MODNAME(\\\$|,)\"`" = "" ]; then continue
217
      if [ "$LOAD" != "*" -a "`echo $LINE | grep optional`" != "" -a "`echo $LOAD | egrep \"(^|,)$MODNAME(\\\$|,)\"`" = "" ]; then continue
217
        else echo $LINE; fi
218
        else echo $LINE; fi
218
   done
219
   done
219
}
220
}
220
 
221
 
221
# Insert one single .mo module to the union
222
# Insert one single .mo module to the union
222
# $1 = union absolute path (starting with /)
223
# $1 = union absolute path (starting with /)
223
# $2 = module.mo full path
224
# $2 = module.mo full path
224
# $3 = destination folder, where images will be mounted to
225
# $3 = destination folder, where images will be mounted to
225
#
226
#
226
union_insert_module()
227
union_insert_module()
227
{
228
{
228
   TARGET="$3/`basename $2`"
229
   TARGET="$3/`basename $2`"
229
   while [ -e $TARGET ]; do TARGET=$TARGET.X; done
230
   while [ -e $TARGET ]; do TARGET=$TARGET.X; done
230
   mkdir -p $TARGET
231
   mkdir -p $TARGET
231
   mount_module $2 $TARGET
232
   mount_module $2 $TARGET
232
   if [ $? -ne 0 ]; then echo "can't read module data"; return 1; fi
233
   if [ $? -ne 0 ]; then echo "can't read module data"; return 1; fi
233
   union_insert_dir $1 $TARGET; 
234
   union_insert_dir $1 $TARGET; 
234
}
235
}
235
 
236
 
236
# Insert all .mo modules, in $2 directory and subdirectories, to the union
237
# Insert all .mo modules, in $2 directory and subdirectories, to the union
237
# $1 = union absolute path (starting with /)
238
# $1 = union absolute path (starting with /)
238
# $2 = LiveCD data dir (with directories /base, /modules, etc.)
239
# $2 = LiveCD data dir (with directories /base, /modules, etc.)
239
# $3 = destination folder, where images will be mounted to
240
# $3 = destination folder, where images will be mounted to
240
#
241
#
241
union_insert_modules()
242
union_insert_modules()
242
{
243
{
243
   PRINTK=`cat /proc/sys/kernel/printk`
244
   PRINTK=`cat /proc/sys/kernel/printk`
244
   echo "0" >/proc/sys/kernel/printk
245
   echo "0" >/proc/sys/kernel/printk
245
 
246
 
246
   list_modules $2 | while read MODULE; do
247
   list_modules $2 | while read MODULE; do
247
      echo " -> `basename $MODULE`"
248
      echo " -> `basename $MODULE`"
248
      union_insert_module $1 $MODULE $3
249
      union_insert_module $1 $MODULE $3
249
   done
250
   done
250
 
251
 
251
   echo "$PRINTK" >/proc/sys/kernel/printk
252
   echo "$PRINTK" >/proc/sys/kernel/printk
252
}
253
}
253
 
254
 
254
# Copy modules to RAM directory
255
# Copy modules to RAM directory
255
# $1 = data directory
256
# $1 = data directory
256
# $2 = target directory in RAM
257
# $2 = target directory in RAM
257
#
258
#
258
copy_to_ram()
259
copy_to_ram()
259
{
260
{
260
   cp -R $1/* $2
261
   cp -R $1/* $2
261
   if [ $? -ne 0 ]; then fatal "can't copy to RAM, not enough memory?"; fi
262
   if [ $? -ne 0 ]; then fatal "can't copy to RAM, not enough memory?"; fi
262
}
263
}
263
 
264
 
264
# Copy content of "rootcopy" directory on the CD to $2 (union, usually)
265
# Copy content of "rootcopy" directory on the CD to $2 (union, usually)
265
# $1 = source
266
# $1 = source
266
# $2 = destination
267
# $2 = destination
267
#
268
#
268
copy_rootchanges()
269
copy_rootchanges()
269
{
270
{
270
   cp -a $1/rootcopy/* $2 2>/dev/null # could be empty
271
   cp -a $1/rootcopy/* $2 2>/dev/null # could be empty
271
}
272
}
272
 
273
 
273
# ===========================================================
274
# ===========================================================
274
# discovery functions
275
# discovery functions
275
# ===========================================================
276
# ===========================================================
276
 
277
 
277
# List all CD-ROMs
278
# List all CD-ROMs
278
# by using /proc entries
279
# by using /proc entries
279
#
280
#
280
list_cdrom_devices()
281
list_cdrom_devices()
281
{
282
{
282
   if [ "`cmdline_parameter nocd`" != "" ]; then return 1; fi
283
   if [ "`cmdline_parameter nocd`" != "" ]; then return 1; fi
283
   for CDDEVICE in `cat /proc/sys/dev/cdrom/info | head -n 3 | tail -n 1 | cut -d ":" -f 2`; do
284
   for CDDEVICE in `cat /proc/sys/dev/cdrom/info | head -n 3 | tail -n 1 | cut -d ":" -f 2`; do
284
      echo "/dev/$CDDEVICE"
285
      echo "/dev/$CDDEVICE"
285
   done
286
   done
286
}
287
}
287
 
288
 
288
# List all partition devices
289
# List all partition devices
289
# take list of all partitions and output unique disks.
290
# take list of all partitions and output unique disks.
290
# Return empty result when nohd parameter was given.
291
# Return empty result when nohd parameter was given.
291
#
292
#
292
list_partition_devices()
293
list_partition_devices()
293
{
294
{
294
   if [ "`cmdline_parameter nohd`" != "" ]; then return 1; fi
295
   if [ "`cmdline_parameter nohd`" != "" ]; then return 1; fi
295
   cat /proc/partitions | grep -v loop | sed -r "s/^[0-9[:space:]]+/\/dev\//" | grep /dev/
296
   cat /proc/partitions | grep -v loop | sed -r "s/^[0-9[:space:]]+/\/dev\//" | grep /dev/
296
}
297
}
297
 
298
 
298
# List all disk devices
299
# List all disk devices
299
#
300
#
300
list_disk_devices()
301
list_disk_devices()
301
{
302
{
302
   list_partition_devices | egrep -v "[0-9]"
303
   list_partition_devices | egrep -v "[0-9]"
303
}
304
}
304
 
305
 
305
# List all block devices
306
# List all block devices
306
#
307
#
307
list_block_devices()
308
list_block_devices()
308
{
309
{
309
   list_cdrom_devices
310
   list_cdrom_devices
310
   list_partition_devices
311
   list_partition_devices
311
}
312
}
312
 
313
 
313
# Try to mount all disks, partitions and cdroms and Find where the LiveCD is.
314
# Try to mount all disks, partitions and cdroms and Find where the LiveCD is.
314
# If LiveCD found in the device, echo dirname of it's directory,
315
# If LiveCD found in the device, echo dirname of it's directory,
315
# and leave the device mounted. Mounting is not ro, but without any argument.
316
# and leave the device mounted. Mounting is not ro, but without any argument.
316
# $1 = directory where devices will be mounted
317
# $1 = directory where devices will be mounted
317
# added: mount $NFSROOT to /$1/nfs if NFSROOT is set. and search there for LiveCD
318
# added: mount $NFSROOT to /$1/nfs if NFSROOT is set. and search there for LiveCD
318
#
319
#
319
find_live_data_dir()
320
find_live_data_dir()
320
{
321
{
321
   if [ "$NFSROOT" != "" ]; then 
322
   if [ "$NFSROOT" != "" ]; then 
322
      DIR="/$1/nfs"
323
      DIR="/$1/nfs"
323
      mkdir -p $DIR
324
      mkdir -p $DIR
324
      # try to mount nfs dir
325
      # try to mount nfs dir
325
      mount -t nfs $NFSROOT $DIR -o $NFSOPTS 
326
      mount -t nfs $NFSROOT $DIR -o $NFSOPTS 
326
   fi
327
   fi
327
 
328
 
328
   if [ "$CIFSROOT" != "" ]; then
329
   if [ "$CIFSROOT" != "" ]; then
329
      DIR="/$1/cifs"
330
      DIR="/$1/cifs"
330
      mkdir -p $DIR
331
      mkdir -p $DIR
331
      # try to mount cifs dir
332
      # try to mount cifs dir
332
      mount -t cifs $CIFSROOT $DIR -o ro,$CIFSOPTS
333
      mount -t cifs $CIFSROOT $DIR -o ro,$CIFSOPTS
333
   fi
334
   fi
334
 
335
 
335
   if [ "$DIR" = "" ]; then
336
   if [ "$DIR" = "" ]; then
336
       list_block_devices | while read DEVICE; do
337
       list_block_devices | while read DEVICE; do
337
	   DIR="/$1/`basename $DEVICE`"
338
	   DIR="/$1/`basename $DEVICE`"
338
	   mount_device $DEVICE $DIR
339
	   mount_device $DEVICE $DIR
339
	   if [ $? -ne 0 ]; then continue; fi
340
	   if [ $? -ne 0 ]; then continue; fi
340
	   # FOUND=`find $DIR -name livecd.sgn -type f | head -n 1`
341
	   # FOUND=`find $DIR -name livecd.sgn -type f | head -n 1`
341
	   FOUND=`ls -A1d $DIR/livecd.sgn $DIR/*/livecd.sgn 2>/dev/null | head -n 1`
342
	   FOUND=`ls -A1d $DIR/livecd.sgn $DIR/*/livecd.sgn 2>/dev/null | head -n 1`
342
	   if [ "$FOUND" = "" ]; then umount $DIR 2>/dev/null; rmdir $DIR 2>/dev/null
343
	   if [ "$FOUND" = "" ]; then umount $DIR 2>/dev/null; rmdir $DIR 2>/dev/null
343
	   else dirname "$FOUND"; return 1; fi
344
	   else dirname "$FOUND"; return 1; fi
344
       done
345
       done
345
   else
346
   else
346
       # FOUND=`find $DIR -name livecd.sgn -type f | head -n 1`
347
       # FOUND=`find $DIR -name livecd.sgn -type f | head -n 1`
347
       FOUND=`ls -A1d $DIR/livecd.sgn $DIR/*/livecd.sgn 2>/dev/null | head -n 1`
348
       FOUND=`ls -A1d $DIR/livecd.sgn $DIR/*/livecd.sgn 2>/dev/null | head -n 1`
348
       if [ "$FOUND" != "" ]; then 
349
       if [ "$FOUND" != "" ]; then 
349
	   dirname "$FOUND"
350
	   dirname "$FOUND"
350
       fi
351
       fi
351
   fi
352
   fi
352
}
353
}
353
 
354
 
354
# ===========================================================
355
# ===========================================================
355
# hardware preparation functions
356
# hardware preparation functions
356
# ===========================================================
357
# ===========================================================
357
 
358
 
358
# Create block devices to /dev described by /sys entries
359
# Create block devices to /dev described by /sys entries
359
#
360
#
360
create_block_devices()
361
create_block_devices()
361
{
362
{
362
   echolog "creating /dev entries for block devices"
363
   echolog "creating /dev entries for block devices"
363
   ls -A1d /sys/block/*/dev /sys/block/*/*/dev 2>/dev/null | grep -v loop | while read BLOCK; do
364
   ls -A1d /sys/block/*/dev /sys/block/*/*/dev 2>/dev/null | grep -v loop | while read BLOCK; do
364
      DEVICE="/dev/`basename \`dirname $BLOCK\``"
365
      DEVICE="/dev/`basename \`dirname $BLOCK\``"
365
      if [ ! -b $DEVICE ]; then
366
      if [ ! -b $DEVICE ]; then
366
         MINORMAJOR="`head -n 1 $BLOCK | tr ':' ' '`"
367
         MINORMAJOR="`head -n 1 $BLOCK | tr ':' ' '`"
367
         mknod $DEVICE b $MINORMAJOR
368
         mknod $DEVICE b $MINORMAJOR
368
      fi
369
      fi
369
   done
370
   done
370
}
371
}
371
 
372
 
372
# modprobe kernel modules needed for the LiveCD
373
# modprobe kernel modules needed for the LiveCD
373
#
374
#
374
modprobe_essential_modules()
375
modprobe_essential_modules()
375
{
376
{
376
   echolog "starting loop device support"
377
   echolog "starting loop device support"
377
   modprobe_module loop max_loop=32
378
   modprobe_module loop max_loop=32
378
   echolog "starting cdrom support"
379
   echolog "starting cdrom support"
379
   modprobe_module ide_cd
380
   modprobe_module ide_cd
380
   modprobe_module ide-cd
381
   modprobe_module ide-cd
381
   modprobe_module sr_mod
382
   modprobe_module sr_mod
382
   modprobe_module cdrom
383
   modprobe_module cdrom
383
   echolog "starting cdrom filesystem support"
384
   echolog "starting cdrom filesystem support"
384
   modprobe_module isofs
385
   modprobe_module isofs
385
   echolog "starting squashfs support"
386
   echolog "starting squashfs support"
386
   modprobe_module squashfs
387
   modprobe_module squashfs
387
   echolog "starting unionfs/aufs support"
388
   echolog "starting unionfs/aufs support"
388
   modprobe_module unionfs
389
   modprobe_module unionfs
389
   modprobe_module aufs
390
   modprobe_module aufs
390
   echolog "starting vfat support"
391
   echolog "starting vfat support"
391
   # modprobe_module nls_cp437
392
   # modprobe_module nls_cp437
392
   # modprobe_module nls_iso8859-1
393
   # modprobe_module nls_iso8859-1
393
   # modprobe_module nls_iso8859-2
394
   # modprobe_module nls_iso8859-2
394
   modprobe_module vfat
395
   modprobe_module vfat
395
   echolog "starting ntfs support"
396
   echolog "starting ntfs support"
396
   modprobe_module ntfs
397
   modprobe_module ntfs
397
   modprobe_module nls_utf8
398
   modprobe_module nls_utf8
398
   create_block_devices
399
   create_block_devices
399
}
400
}
400
 
401
 
401
 
402
 
402
# modprobe kernel modules needed for USB masstorage devices
403
# modprobe kernel modules needed for USB masstorage devices
403
#
404
#
404
modprobe_usb_sata_modules()
405
modprobe_usb_sata_modules()
405
{
406
{
406
   echolog "starting USB and SATA support"
407
   echolog "starting USB and SATA support"
407
   modprobe_module ehci-hcd
408
   modprobe_module ehci-hcd
408
   modprobe_module ohci-hcd
409
   modprobe_module ohci-hcd
409
   modprobe_module uhci-hcd
410
   modprobe_module uhci-hcd
410
   modprobe_module scsi_mod
411
   modprobe_module scsi_mod
411
 
412
 
412
   modprobe_module libata
413
   modprobe_module libata
413
   modprobe_module ata_piix
414
   modprobe_module ata_piix
414
   modprobe_module ahci
415
   modprobe_module ahci
415
   modprobe_module sata_nv
416
   modprobe_module sata_nv
-
 
417
   modprobe_module sata_svw
416
   modprobe_module sg
418
   modprobe_module sg
417
 
419
 
418
   modprobe_module sd_mod
420
   modprobe_module sd_mod
419
   modprobe_module sr_mod
421
   modprobe_module sr_mod
420
   modprobe_module usb-storage
422
   modprobe_module usb-storage
421
   echolog "waiting for USB devices, max 8 seconds"
423
   echolog "waiting for USB devices, max 8 seconds"
422
   sleep 8
424
   sleep 8
423
   create_block_devices
425
   create_block_devices
424
}
426
}
425
 
427
 
426
# modprobe nfs kernel modules
428
# modprobe nfs kernel modules
427
#
429
#
428
modprobe_nfs_modules()
430
modprobe_nfs_modules()
429
{
431
{
430
   echolog "starting nfs support"
432
   echolog "starting nfs support"
431
   modprobe_module lockd
433
   modprobe_module lockd
432
   modprobe_module fscache
434
   modprobe_module fscache
433
   modprobe_module nfs_acl
435
   modprobe_module nfs_acl
434
   modprobe_module nfs
436
   modprobe_module nfs
435
}
437
}
436
 
438
 
437
# modprobe cifs kernel module
439
# modprobe cifs kernel module
438
#
440
#
439
modprobe_cifs_modules()
441
modprobe_cifs_modules()
440
{
442
{
441
  echolog "starting cifs support"
443
  echolog "starting cifs support"
442
  modprobe_module cifs
444
  modprobe_module cifs
443
}
445
}
444
 
446
 
445
# enable/disable CD autoejecting when unmounted
447
# enable/disable CD autoejecting when unmounted
446
# $1 = 1|0 ... enable|disable
448
# $1 = 1|0 ... enable|disable
447
#
449
#
448
cd_autoeject()
450
cd_autoeject()
449
{
451
{
450
   echo $1 >/proc/sys/dev/cdrom/autoeject
452
   echo $1 >/proc/sys/dev/cdrom/autoeject
451
}
453
}
452
 
454
 
453
# Disable DMA if nodma boot parameter is present
455
# Disable DMA if nodma boot parameter is present
454
#
456
#
455
setup_dma()
457
setup_dma()
456
{
458
{
457
   if [ ! "`cmdline_parameter nodma`" = "" ]; then
459
   if [ ! "`cmdline_parameter nodma`" = "" ]; then
458
      for DEVICE in `list_cdrom_devices` `list_disk_devices`; do
460
      for DEVICE in `list_cdrom_devices` `list_disk_devices`; do
459
         echolog "setting DMA support off for $DEVICE"
461
         echolog "setting DMA support off for $DEVICE"
460
         hdparm -d 0 $DEVICE
462
         hdparm -d 0 $DEVICE
461
      done
463
      done
462
   fi
464
   fi
463
}
465
}
464
 
466
 
465
# create correct fstab file in $1/etc/fstab and create apropriate
467
# create correct fstab file in $1/etc/fstab and create apropriate
466
# mount directories in $1
468
# mount directories in $1
467
# $1 = root directory (union)
469
# $1 = root directory (union)
468
#
470
#
469
activate_fstab()
471
activate_fstab()
470
{
472
{
471
   mkdir -p $1/etc
473
   mkdir -p $1/etc
472
   FSTAB="$1/etc/fstab"
474
   FSTAB="$1/etc/fstab"
473
   echo "tmpfs            /                tmpfs       defaults         0   0" >$FSTAB
475
   echo "tmpfs            /                tmpfs       defaults         0   0" >$FSTAB
474
   echo "devpts           /dev/pts         devpts      gid=5,mode=620   0   0" >>$FSTAB
476
   echo "devpts           /dev/pts         devpts      gid=5,mode=620   0   0" >>$FSTAB
475
   echo "proc             /proc            proc        defaults         0   0" >>$FSTAB
477
   echo "proc             /proc            proc        defaults         0   0" >>$FSTAB
476
 
478
 
477
   # all the rest will be done by runlast or by fstab-sync
479
   # all the rest will be done by runlast or by fstab-sync
478
   # search for SWAP done later in /etc/rc.sysinit
480
   # search for SWAP done later in /etc/rc.sysinit
479
}
481
}
480
 
482
 
481
 
483
 
482
# find partition and/or folder that stores the changes
484
# find partition and/or folder that stores the changes
483
# return false, if changes not set or changes folder/partition not found
485
# return false, if changes not set or changes folder/partition not found
484
# Urs Beyerle
486
# Urs Beyerle
485
#
487
#
486
find_changes()
488
find_changes()
487
{
489
{
488
    echolog "looking for changes in $CHANGESVAL"
490
    echolog "looking for changes in $CHANGESVAL"
489
 
491
 
490
    CHANGESDEV="`echo "$CHANGESVAL" | egrep -o "^/dev/[^/]+"`"
492
    CHANGESDEV="`echo "$CHANGESVAL" | egrep -o "^/dev/[^/]+"`"
491
    CHANGESFOLDER="`echo "$CHANGESVAL" | sed -r 's:^/dev/[^/]+(.*):\1:'`"
493
    CHANGESFOLDER="`echo "$CHANGESVAL" | sed -r 's:^/dev/[^/]+(.*):\1:'`"
492
    # (re-)define CHANGES if CHANGESFOLDER is set
494
    # (re-)define CHANGES if CHANGESFOLDER is set
493
    if [ "$CHANGESFOLDER" != "" ]; then CHANGES=$MEMORY/$CHANGESFOLDER; fi
495
    if [ "$CHANGESFOLDER" != "" ]; then CHANGES=$MEMORY/$CHANGESFOLDER; fi
494
 
496
 
495
    # we may need usb and sata support
497
    # we may need usb and sata support
496
    modprobe_usb_sata_modules
498
    modprobe_usb_sata_modules
497
 
499
 
498
    # device defined?
500
    # device defined?
499
    if [ "$CHANGESDEV" != "" ]; then
501
    if [ "$CHANGESDEV" != "" ]; then
500
	mount_device $CHANGESDEV $MEMORY
502
	mount_device $CHANGESDEV $MEMORY
501
	if [ $? -eq 0 ]; then 
503
	if [ $? -eq 0 ]; then 
502
	    echolog "mounted $CHANGESDEV to $MEMORY"
504
	    echolog "mounted $CHANGESDEV to $MEMORY"
503
	else
505
	else
504
	    echolog "WARNING: device $CHANGESDEV could not be mounted! Continue booting in 10 sec. ..."
506
	    echolog "WARNING: device $CHANGESDEV could not be mounted! Continue booting in 10 sec. ..."
505
	    CHANGESVAL=""
507
	    CHANGESVAL=""
506
	    sleep 10
508
	    sleep 10
507
	fi
509
	fi
508
	return
510
	return
509
    fi
511
    fi
510
    
512
    
511
    # if no device is specified, search all devices for folder CHANGESFOLDER
513
    # if no device is specified, search all devices for folder CHANGESFOLDER
512
    list_block_devices | while read DEVICE; do
514
    list_block_devices | while read DEVICE; do
513
	mount_device $DEVICE $MEMORY
515
	mount_device $DEVICE $MEMORY
514
	if [ $? -ne 0 ]; then continue; fi
516
	if [ $? -ne 0 ]; then continue; fi
515
	FOUND_FOLDER=`ls -1d $MEMORY/$CHANGESFOLDER 2>/dev/null`
517
	FOUND_FOLDER=`ls -1d $MEMORY/$CHANGESFOLDER 2>/dev/null`
516
	if [ "$FOUND_FOLDER" = "" ]; then 
518
	if [ "$FOUND_FOLDER" = "" ]; then 
517
	    umount $MEMORY 2>/dev/null
519
	    umount $MEMORY 2>/dev/null
518
	else
520
	else
519
	    echolog "found folder $CHANGESFOLDER on $DEVICE"
521
	    echolog "found folder $CHANGESFOLDER on $DEVICE"
520
	    break
522
	    break
521
	fi
523
	fi
522
    done
524
    done
523
 
525
 
524
    FOUND_FOLDER=`ls -1d $MEMORY/$CHANGESFOLDER 2>/dev/null`
526
    FOUND_FOLDER=`ls -1d $MEMORY/$CHANGESFOLDER 2>/dev/null`
525
 
527
 
526
    if [ "$FOUND_FOLDER" = "" ]; then 
528
    if [ "$FOUND_FOLDER" = "" ]; then 
527
	echolog "WARNING: changes=$CHANGESVAL not found! Continue booting in 10 sec. ..."
529
	echolog "WARNING: changes=$CHANGESVAL not found! Continue booting in 10 sec. ..."
528
	CHANGESVAL=""
530
	CHANGESVAL=""
529
	sleep 10
531
	sleep 10
530
    fi
532
    fi
531
 
533
 
532
}
534
}
533
 
535
 
534
 
536
 
535
# ===========================================================
537
# ===========================================================
536
# functions used for LiveCD on NFS 
538
# functions used for LiveCD on NFS 
537
# ===========================================================
539
# ===========================================================
538
 
540
 
539
# load network modules, if NFSROOT is set
541
# load network modules, if NFSROOT is set
540
# Urs Beyerle
542
# Urs Beyerle
541
#
543
#
542
 
544
 
543
# network devices found ?
545
# network devices found ?
544
#
546
#
545
found_nic()
547
found_nic()
546
{
548
{
547
    found="1"
549
    found="1"
548
    for iface in eth0 eth1 eth2 eth3 eth4 eth5; do
550
    for iface in eth0 eth1 eth2 eth3 eth4 eth5; do
549
	# nic already found ?
551
	# nic already found ?
550
	echo $FOUND_IFACE | grep -q $iface 
552
	echo $FOUND_IFACE | grep -q $iface 
551
	if [ $? -ne 0 ]; then
553
	if [ $? -ne 0 ]; then
552
	    ifconfig $iface > /dev/null 2>&1
554
	    ifconfig $iface > /dev/null 2>&1
553
	    if [ $? -eq 0 ]; then 
555
	    if [ $? -eq 0 ]; then 
554
		FOUND_IFACE="$FOUND_IFACE $iface"
556
		FOUND_IFACE="$FOUND_IFACE $iface"
555
		found="0"
557
		found="0"
556
	    fi
558
	    fi
557
	fi
559
	fi
558
    done
560
    done
559
    return $found
561
    return $found
560
}
562
}
561
 
563
 
562
# 1. load network driver defined by kernel parameter nic
564
# 1. load network driver defined by kernel parameter nic
563
#
565
#
564
load_network_module_nic()
566
load_network_module_nic()
565
{
567
{
566
    NIC="`cmdline_value nic`"
568
    NIC="`cmdline_value nic`"
567
    if [ -n "$NIC" ]; then
569
    if [ -n "$NIC" ]; then
568
	echolog "load module $NIC"
570
	echolog "load module $NIC"
569
	modprobe_module $NIC
571
	modprobe_module $NIC
570
    fi
572
    fi
571
}
573
}
572
 
574
 
573
 
575
 
574
# 2. auto probe for network card drivers
576
# 2. auto probe for network card drivers
575
#
577
#
576
load_network_module_auto()
578
load_network_module_auto()
577
{
579
{
578
    echolog "auto-detection of network driver ..."
580
    echolog "auto-detection of network driver ..."
579
    FOUND_NICS=""
581
    FOUND_NICS=""
580
    KERNEL="`uname -r`"
582
    KERNEL="`uname -r`"
581
    NETDRIVERS="`find /lib/modules/$KERNEL/kernel/drivers/net | grep -v mii | grep .ko | cut -d"/" -f8 | cut -d"." -f1 | uniq`"
583
    NETDRIVERS="`find /lib/modules/$KERNEL/kernel/drivers/net | grep -v mii | grep .ko | cut -d"/" -f8 | cut -d"." -f1 | uniq`"
582
    for driver in $NETDRIVERS; do
584
    for driver in $NETDRIVERS; do
583
       	modprobe_module $driver > /dev/null 2>&1
585
       	modprobe_module $driver > /dev/null 2>&1
584
	found_nic
586
	found_nic
585
	if [ $? -eq 0 ]; then
587
	if [ $? -eq 0 ]; then
586
	    echolog "found network card $driver"
588
	    echolog "found network card $driver"
587
	    echolog "load module $driver"
589
	    echolog "load module $driver"
588
	    FOUND_NICS="$FOUND_NICS $driver"
590
	    FOUND_NICS="$FOUND_NICS $driver"
589
	else
591
	else
590
	    rmmod $driver > /dev/null 2>&1
592
	    rmmod $driver > /dev/null 2>&1
591
	fi
593
	fi
592
    done
594
    done
593
 
595
 
594
    # clean up: remove unused modules until driver "mii"
596
    # clean up: remove unused modules until driver "mii"
595
    LOADED_DRIVERS="`lsmod | grep -v Module | cut -d" " -f1`"
597
    LOADED_DRIVERS="`lsmod | grep -v Module | cut -d" " -f1`"
596
    for driver in $LOADED_DRIVERS; do
598
    for driver in $LOADED_DRIVERS; do
597
	[ "$driver" = "mii" ]  && break
599
	[ "$driver" = "mii" ]  && break
598
	[ "$driver" = "ntfs" ] && break
600
	[ "$driver" = "ntfs" ] && break
599
	[ "$driver" = "vfat" ] && break
601
	[ "$driver" = "vfat" ] && break
600
	do_not_remove=""
602
	do_not_remove=""
601
	for nic in $FOUND_NICS; do
603
	for nic in $FOUND_NICS; do
602
	    echo $driver | grep -q $nic 
604
	    echo $driver | grep -q $nic 
603
	    [ $? -eq 0 ] && do_not_remove="$driver"
605
	    [ $? -eq 0 ] && do_not_remove="$driver"
604
	done
606
	done
605
	[ ! $do_not_remove ] && rmmod $driver > /dev/null 2>&1
607
	[ ! $do_not_remove ] && rmmod $driver > /dev/null 2>&1
606
    done
608
    done
607
}
609
}
608
 
610
 
609
# 3. detecting network card from pcitable list
611
# 3. detecting network card from pcitable list
610
#
612
#
611
load_network_module_pcitable()
613
load_network_module_pcitable()
612
{
614
{
613
    PCITABLE=/bin/pcitable
615
    PCITABLE=/bin/pcitable
614
    NICS=`lspci -n | awk '/Class 0200/ {print $4}' | tr ':' ' ' \
616
    NICS=`lspci -n | awk '/Class 0200/ {print $4}' | tr ':' ' ' \
615
	| while read x y ; do grep "0x$x.*0x$y" $PCITABLE \
617
	| while read x y ; do grep "0x$x.*0x$y" $PCITABLE \
616
	| awk '$3 !~ /"unknown"/ {print $3}' | tr -d '"' ; done`
618
	| awk '$3 !~ /"unknown"/ {print $3}' | tr -d '"' ; done`
617
    
619
    
618
    if [ -n "$NICS" ]; then
620
    if [ -n "$NICS" ]; then
619
	echolog "found network card(s): $NICS"
621
	echolog "found network card(s): $NICS"
620
	for driver in $NICS; do
622
	for driver in $NICS; do
621
	    echolog "load module $driver"
623
	    echolog "load module $driver"
622
	    modprobe_module $driver
624
	    modprobe_module $driver
623
	done
625
	done
624
    fi
626
    fi
625
}
627
}
626
 
628
 
627
# 4. ask the user for a network driver
629
# 4. ask the user for a network driver
628
#
630
#
629
load_network_module_ask()
631
load_network_module_ask()
630
{
632
{
631
    echo "ERROR: No network card detected!"
633
    echo "ERROR: No network card detected!"
632
    echo "Type in your network card driver (e.g. tg3, e1000). "
634
    echo "Type in your network card driver (e.g. tg3, e1000). "
633
    echo "Or ask your system administrator for help."
635
    echo "Or ask your system administrator for help."
634
    echo -n "Network card driver: "
636
    echo -n "Network card driver: "
635
    read driver
637
    read driver
636
    echo "load module $driver"
638
    echo "load module $driver"
637
    modprobe_module $driver
639
    modprobe_module $driver
638
}
640
}
639
 
641
 
640
# Try to find a network driver
642
# Try to find a network driver
641
#
643
#
642
load_network_modules()
644
load_network_modules()
643
{
645
{
644
    echolog "load network modules"
646
    echolog "load network modules"
645
 
647
 
646
    # mii maybe need by NIC driver
648
    # mii maybe need by NIC driver
647
    modprobe_module mii
649
    modprobe_module mii
648
 
650
 
649
    FOUND_IFACE=""
651
    FOUND_IFACE=""
650
    load_network_module_nic
652
    load_network_module_nic
651
    found_nic          || load_network_module_auto
653
    found_nic          || load_network_module_auto
652
    [ "$FOUND_IFACE" ] || load_network_module_pcitable
654
    [ "$FOUND_IFACE" ] || load_network_module_pcitable
653
    [ "$FOUND_IFACE" ] || load_network_module_ask
655
    [ "$FOUND_IFACE" ] || load_network_module_ask
654
 
656
 
655
    # remove mii, if not needed
657
    # remove mii, if not needed
656
    rmmod mii > /dev/null 2>&1
658
    rmmod mii > /dev/null 2>&1
657
}
659
}
658
 
660
 
659
 
661
 
660
# get DHCP lease
662
# get DHCP lease
661
# Urs Beyerle
663
# Urs Beyerle
662
#
664
#
663
get_dhcp_lease()
665
get_dhcp_lease()
664
{
666
{
665
    # create /dev/urandom (needed by udhcpc)
667
    # create /dev/urandom (needed by udhcpc)
666
    mknod /dev/urandom c 1 9
668
    mknod /dev/urandom c 1 9
667
 
669
 
668
    for iface in eth0 eth1 eth2 eth3 eth4 eth5; do
670
    for iface in eth0 eth1 eth2 eth3 eth4 eth5; do
669
	# interface up ?
671
	# interface up ?
670
	ifconfig $iface > /dev/null 2>&1
672
	ifconfig $iface > /dev/null 2>&1
671
	if [ $? -eq 0 ]; then
673
	if [ $? -eq 0 ]; then
672
	    # get dhcp lease
674
	    # get dhcp lease
673
	    echolog "try to get DHCP lease on $iface"
675
	    echolog "try to get DHCP lease on $iface"
674
	    udhcpc --now --quit --interface=$iface --script=/bin/udhcpc.script
676
	    udhcpc --now --quit --interface=$iface --script=/bin/udhcpc.script
675
	    [ $? -eq 0 ] && return
677
	    [ $? -eq 0 ] && return
676
	    echo "ERROR: couldn't get DHCP lease on $iface."
678
	    echo "ERROR: couldn't get DHCP lease on $iface."
677
	fi
679
	fi
678
    done
680
    done
679
}
681
}