1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # $Id: mindi 939 2006-11-17 12:41:11Z bruno $
|
---|
4 | #
|
---|
5 | #-----------------------------------------------------------------------------
|
---|
6 | # mindi - mini-Linux distro based on the user's filesystem & distribution
|
---|
7 | #
|
---|
8 | # Mindi can create a multi-floppy boot/root kit. The first floppy is the boot
|
---|
9 | # disk: it contains a kernel, a ramdisk etc. The second disk is data disk #1;
|
---|
10 | # the third disk is data disk #2; and so it goes.
|
---|
11 | #
|
---|
12 | # See http://www.mondorescue.org for details.
|
---|
13 | #-----------------------------------------------------------------------------
|
---|
14 |
|
---|
15 | ### Which arch are we on (useful for ia64 port)
|
---|
16 | ARCH=`/bin/arch`
|
---|
17 |
|
---|
18 | #RUN_AFTER_INITIAL_BOOT_PHASE="echo \"Who lives in a pineapple under the sea?\" > /tmp/spongebob.squarepants.txt"
|
---|
19 | # after booting from floppy/CD image but before
|
---|
20 | # accessing auxiliary data disks (or the rest of
|
---|
21 | # the CD), the initscript will run the above command.
|
---|
22 |
|
---|
23 | RUN_AFTER_BOOT_PHASE_COMPLETE="ide-opt"
|
---|
24 | # after the emergency boot process is complete but
|
---|
25 | # before the init script runs mondorestore, it will
|
---|
26 | # run this command.
|
---|
27 |
|
---|
28 | MINDI_REV=RRR
|
---|
29 | MINDI_VER=VVV
|
---|
30 |
|
---|
31 | MINDI_VERSION=${MINDI_VER}-r$MINDI_REV
|
---|
32 | MINDI_PREFIX=XXX
|
---|
33 | MINDI_CONF=YYY
|
---|
34 | MINDI_SBIN=${MINDI_PREFIX}/sbin
|
---|
35 | MINDI_LIB=LLL
|
---|
36 |
|
---|
37 | MINDI_CONFIG_DIST="$MINDI_CONF/mindi.conf.dist"
|
---|
38 | if [ ! -f $MINDI_CONFIG_CONF ]; then
|
---|
39 | echo "Unable to find $MINDI_CONFIG_CONF. Please reinstall mindi"
|
---|
40 | MindiExit -1
|
---|
41 | fi
|
---|
42 | . $MINDI_CONFIG_DIST
|
---|
43 |
|
---|
44 | MINDI_CONFIG="$MINDI_CONF/mindi.conf"
|
---|
45 | if [ ! -f $MINDI_CONFIG ]; then
|
---|
46 | echo "No $MINDI_CONFIG file found using sensible values"
|
---|
47 | else
|
---|
48 | echo "Using $MINDI_CONFIG as additional config file"
|
---|
49 | . $MINDI_CONFIG
|
---|
50 | fi
|
---|
51 |
|
---|
52 | #
|
---|
53 | # Manages defaults coming from conf files
|
---|
54 | #
|
---|
55 | EXTRA_SPACE=$mindi_extra_space
|
---|
56 | IA64_BOOT_SIZE=$mindi_ia64_boot_size
|
---|
57 | DEPLIST_DIR="$mindi_deplist_dir"
|
---|
58 | # TBC
|
---|
59 | WRITE_BOOT_FLOPPIES="$mindi_write_boot_floppy"
|
---|
60 | # TBC
|
---|
61 | WRITE_MINDI_CD="$mindi_write_cd"
|
---|
62 | # TBC
|
---|
63 | CACHEDIR="$mindi_images_dir"
|
---|
64 | FORCE_DUAL_FLOPPIES="$mindi_dual_floppies"
|
---|
65 | TMP_ROOT="$mindi_tmp_dir"
|
---|
66 | FDDEVICE="$mindi_fd_device"
|
---|
67 | ADDITIONAL_BOOT_PARAMS="$mindi_boot_params"
|
---|
68 | MY_FSTAB="$mindi_etc_fstab"
|
---|
69 | LOGFILE="$mindi_log_file"
|
---|
70 | INTERACTIVE="$mindi_interactive"
|
---|
71 |
|
---|
72 | if [ $INTERACTIVE == "yes" ]; then
|
---|
73 | # do you want to be prompted to write
|
---|
74 | # floppy images out to floppy disks?
|
---|
75 | # if 'no', images will not be written to floppies
|
---|
76 | PROMPT_WRITE_BOOT_FLOPPIES="yes"
|
---|
77 |
|
---|
78 | # Ask if you want to make a CD Image to be written?
|
---|
79 | # if this is set to 'no', then the image will be created automatically
|
---|
80 | PROMPT_MAKE_CD_IMAGE="yes"
|
---|
81 |
|
---|
82 | # If set to "no", you will be prompted for whether or not
|
---|
83 | # you want to use your own kernel, or the supplied default.
|
---|
84 | # If "yes" mindi will automatically use your own kernel.
|
---|
85 | USE_OWN_KERNEL="no"
|
---|
86 | else
|
---|
87 | PROMPT_WRITE_BOOT_FLOPPIES="no"
|
---|
88 | PROMPT_MAKE_CD_IMAGE="no"
|
---|
89 | USE_OWN_KERNEL="yes"
|
---|
90 | fi
|
---|
91 |
|
---|
92 | FLOPPY_MODS="ide-floppy floppy"
|
---|
93 | TAPE_MODS="ht st osst ide-tape ide_tape"
|
---|
94 | SCSI_MODS="3w-xxxx 53c7,8xx a100u2w a320raid aacraid advansys aha152x aha1542 aha1740 aic79xx aic79xx_mod aic7xxx aic7xxx_mod aic7xxx_old AM53C974 atp870u BusLogic cciss cpqfc dmx3191d dpt_i2o dtc eata eata_dma eata_pio fdomain gdth g_NCR5380 i2o_block i2o_core ide-scsi ieee1394 imm in2000 initio ips iscsi isp megaraid mptbase mptscsih NCR53c406a ncr53c8xx nsp32 pas16 pci2000 pci2220i pcmcia ppa psi240i qla1280 qla2200 qla2300 qlogicfas qlogicfc qlogicisp raw1394 scsi_debug scsi_mod sd_mod seagate sg sim710 sr_mod sym53c416 sym53c8xx sym53c8xx_2 t128 tmscsim u14-34f ultrastor wd7000 vmhgfs"
|
---|
95 | IDE_MODS="ide ide-generic ide-detect ide-mod ide-disk ide-cd ide_cd ide-cs ide-core ide_core libata edd paride ata_piix libata via82cxxx generic"
|
---|
96 | PCMCIA_MODS="pcmcia_core ds yenta_socket"
|
---|
97 | USB_MODS="usb-storage usb-ohci usb-uhci usbcore usb_storage hid uhci_hcd ehci_hcd uhci-hcd ehci-hcd usbkbd usbhid"
|
---|
98 | CDROM_MODS="$TAPE_MODS $FLOPPY_MODS $IDE_MODS af_packet cdrom isocd isofs inflate_fs nls_iso8859-1 nls_cp437 sg sr_mod zlib_inflate $USB_MODS $PCMCIA_MODS"
|
---|
99 | NET_MODS="sunrpc nfs nfs_acl lockd loop mii 3c59x e100 bcm5700 bnx2 e1000 eepro100 ne2k-pci tg3 pcnet32 8139cp 8139too 8390 vmxnet"
|
---|
100 | EXTRA_MODS="$CDROM_MODS vfat fat loop md-mod linear raid0 raid1 xor raid5 lvm-mod dm-mod jfs xfs xfs_support pagebuf reiserfs ext2 ext3 minix nfs nfs_acl nfsd lockd sunrpc jbd"
|
---|
101 |
|
---|
102 | BOOT_MEDIA_MESSAGE="$mindi_boot_msg"
|
---|
103 | FDISK=$MINDI_SBIN/parted2fdisk
|
---|
104 | FDISKLOG=$MONDOTMP/parted2fdisk.log
|
---|
105 | touch $FDISKLOG
|
---|
106 |
|
---|
107 | # Using a config file allow to overwrite some values
|
---|
108 | MINDI_CONFIG="$MINDI_CONF/mindi.conf"
|
---|
109 | if [ -f $MINDI_CONFIG ]; then
|
---|
110 | . $MINDI_CONFIG
|
---|
111 | fi
|
---|
112 |
|
---|
113 | # Now we can create what we nedd
|
---|
114 | MONDOTMP=`mktemp -d $TMPDIR/mondobuild.XXXXXXXXXX`
|
---|
115 | mkdir -p $MONDOTMP
|
---|
116 | mkdir -p $CACHE_LOC
|
---|
117 | # ----------------------------------------------------------------------------
|
---|
118 |
|
---|
119 |
|
---|
120 | AbortHere() {
|
---|
121 | [ "$mountpoint" ] && umount $mountpoint 2>> $LOGFILE
|
---|
122 | Die "Program is terminating in response to signal received from OS/user"
|
---|
123 | }
|
---|
124 |
|
---|
125 |
|
---|
126 | HackSyslinuxFile() {
|
---|
127 | local incoming
|
---|
128 | incoming=`ReadLine`
|
---|
129 | while [ "$incoming" ] ; do
|
---|
130 | echo -en "$incoming" | sed s/24000/$1/
|
---|
131 | if [ "`echo "$incoming" | grep append`" ] ; then
|
---|
132 | echo -en " $ADDITIONAL_BOOT_PARAMS"
|
---|
133 | fi
|
---|
134 | echo -en "\n"
|
---|
135 | incoming=`ReadLine`
|
---|
136 | done
|
---|
137 | if [ -e "$MINDI_LIB/memtest.img" ] ; then
|
---|
138 | echo -en "label memtest\n kernel memdisk\n append initrd=memtest.img\n\n"
|
---|
139 | fi
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | AbortIfYourDistroIsAPieceOfStercus() {
|
---|
144 | which which > /dev/null 2> /dev/null || Die "Please install 'which'."
|
---|
145 | which strings > /dev/null 2> /dev/null || Die "Please install binutils and libbinutils; you have no 'strings' executable."
|
---|
146 | which gawk > /dev/null 2> /dev/null || Die "Gawk is missing from your computer. Please install gawk. You may find the package on Debian's website. How did I know you're running Debian? Because only Debian would be stupid enough not to include gawk in your distribution."
|
---|
147 | which gawk > /dev/null 2> /dev/null && AWK=`which gawk 2>/dev/null` || AWK="`which awk 2>/dev/null`"
|
---|
148 | if which awk &> /dev/null ; then
|
---|
149 | if ! which gawk &> /dev/null ; then
|
---|
150 | LogIt "You have awk but not gawk.\nPlease note that mindi works fine with a _sane_ awk binary.\nIf your awk binary misbehaves then please contact your vendor\nor distribution's mailing list for technical support.\n"
|
---|
151 | fi
|
---|
152 | fi
|
---|
153 | which mke2fs > /dev/null 2> /dev/null || Die "Please put mke2fs in system path"
|
---|
154 | [ ! -e "$FDISK" ] && Die "Cannot find (s)fdisk"
|
---|
155 | }
|
---|
156 |
|
---|
157 |
|
---|
158 | AbortIfMkfsVfatMissing() {
|
---|
159 | #if grep -F "vfat" /etc/fstab &> /dev/null ; then
|
---|
160 | if ! which mkfs.vfat &> /dev/null ; then
|
---|
161 | Die "mkfs.vfat missing from your filesystem - please install your dosfstools RPM or DEB package. Perhaps your PATH environmental variable is broken, too?"
|
---|
162 | fi
|
---|
163 | #fi
|
---|
164 | }
|
---|
165 |
|
---|
166 |
|
---|
167 | Aborted() {
|
---|
168 | trap SIGHUP SIGTERM SIGTRAP SIGINT
|
---|
169 | [ "$CACHE_LOC" != "" ] && rm -f $CACHE_LOC/mindi*img $CACHE_LOC/*gz $CACHE_LOC/mindi.iso
|
---|
170 | [ "$minidir_root" != "" ] && rm -Rf $minidir_root/*
|
---|
171 | Die "User abort."
|
---|
172 | }
|
---|
173 |
|
---|
174 |
|
---|
175 | AddFileToCfgIfExists() {
|
---|
176 | [ -e "$1" ] && echo -en "$2 `cat $1`\n" >> $3
|
---|
177 | }
|
---|
178 |
|
---|
179 |
|
---|
180 | AddFileToDir() {
|
---|
181 | local filename minidir_root noof_disks diskno res filesize disksize would_occupy zipsize complevel cutoff compressed_fname siz
|
---|
182 | filename=$1
|
---|
183 | minidir_root=$2
|
---|
184 | noof_disks=$3
|
---|
185 |
|
---|
186 | diskno=$noof_disks
|
---|
187 | mkdir -p $minidir_root/$diskno
|
---|
188 | [ "$LAST_COMPRESSED_SIZE" = "" ] && LAST_COMPRESSED_SIZE=0
|
---|
189 | if [ ! -e "$filename" ] ; then
|
---|
190 | if [ -h "$filename" ] ; then
|
---|
191 | cp --parents -pRdf $filename $minidir_root/$diskno
|
---|
192 | return $noof_disks
|
---|
193 | else
|
---|
194 | Die "AddFileToDir asked me to add $filename, which does not exist. Oops! Did you run out of disk space or is your Linux distro severely broken?"
|
---|
195 | fi
|
---|
196 | fi
|
---|
197 |
|
---|
198 | # move to the disk that has room on it (or end up using the last, if all full)
|
---|
199 | while [ "$diskno" -lt "40" ] ; do
|
---|
200 | mkdir -p $minidir_root/$diskno
|
---|
201 | filesize=`du -sk $filename | cut -f1`
|
---|
202 | cp --parents -Rdf $filename $minidir_root/$diskno
|
---|
203 | if [ "$filesize" -le "4" ] ; then
|
---|
204 | siz=$filesize
|
---|
205 | elif [ ! -f "$filename" ] ; then
|
---|
206 | siz=0
|
---|
207 | else
|
---|
208 | siz=`grep -m 1 "$filename.gz$" $minidir_root/compressed/compressed.txt | cut -f1`
|
---|
209 | [ "$siz" = "" ] && Die "FIXME - can't find $filename's size."
|
---|
210 | siz=$(($siz-2));# to allow for sectors & the fact that they round up
|
---|
211 | fi
|
---|
212 | [ ! "$siz" ] && siz=4
|
---|
213 | [ "$siz" -lt "0" ] && siz=0
|
---|
214 | LAST_COMPRESSED_SIZE=$(($LAST_COMPRESSED_SIZE+$siz))
|
---|
215 | [ "$LAST_COMPRESSED_SIZE" -le "$MAX_COMPRESSED_SIZE" ] &&return $diskno
|
---|
216 | echo "disk=$diskno siz=$LAST_COMPRESSED_SIZE" >> $LOGFILE
|
---|
217 | LAST_COMPRESSED_SIZE=0
|
---|
218 | rm -f $minidir_root/$diskno/$filename
|
---|
219 | diskno=$(($diskno+1))
|
---|
220 | done
|
---|
221 | return 0 ; # failed
|
---|
222 | }
|
---|
223 |
|
---|
224 |
|
---|
225 | AddKeyboardMappingFile() {
|
---|
226 | local mappath r included_list included_item i res ii sss
|
---|
227 | mappath=$1
|
---|
228 | KBDEPTH=$(($KBDEPTH+1))
|
---|
229 | [ "$KBDEPTH" -gt "128" ] && Die "Edit $MINDI_SBIN/mindi and disable FindAndAddUserKeyboardMappingFile (line 2160, approx.)"
|
---|
230 | if [ -e "$bigdir/$mappath" ] ; then
|
---|
231 | echo "$mappath already added" >> $LOGFILE
|
---|
232 | return
|
---|
233 | elif [ -d "$bigdir/$mappath" ] ; then
|
---|
234 | echo "Cannot add $mappath: it's a directory. Sorry."
|
---|
235 | return
|
---|
236 | fi
|
---|
237 | echo "Added kbd map $mappath" >> $LOGFILE
|
---|
238 | if [ ! -e "$mappath" ] ; then
|
---|
239 | mappath=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep "$locale[^r][^/]" | grep -vx " *#.*"`
|
---|
240 | if [ ! -e "$mappath" ] ; then
|
---|
241 | LogIt "Cannot add $mappath: kbd map file not found\n"
|
---|
242 | return
|
---|
243 | fi
|
---|
244 | else
|
---|
245 | echo -en "`basename $mappath | tr '.' '#' | sed s/#kmap#gz// | sed s/#inc#gz//` " | tr '#' '.'
|
---|
246 | fi
|
---|
247 |
|
---|
248 | mkdir -p $bigdir/etc
|
---|
249 | cp --parents -pRdf $mappath $bigdir || LogIt "AKMF -- Could not copy $mappath to $bigdir\n"
|
---|
250 | if [ "`echo $mappath | grep -F ".gz"`" ] ; then
|
---|
251 | included_list=`gzip -dc $mappath | grep -Fi include | sed s/'"'// | sed s/'"'// | cut -d' ' -f2`
|
---|
252 | else
|
---|
253 | included_list=`grep -Fi include $mappath | sed s/'"'// | sed s/'"'// | cut -d' ' -f2`
|
---|
254 | fi
|
---|
255 | for included_item in $included_list ; do
|
---|
256 | if [ ! -e "$included_item" ] ; then
|
---|
257 | sss=`find $KEYDIR/keymaps | grep -F "${included_item}.inc"`
|
---|
258 | [ "$sss" = "" ] && sss=`find $KEYDIR/keymaps | grep -F "$included_item"`
|
---|
259 | for ii in $sss ; do
|
---|
260 | [ -e "$ii" ] && AddKeyboardMappingFile $ii
|
---|
261 | done
|
---|
262 | else
|
---|
263 | AddKeyboardMappingFile $included_item
|
---|
264 | fi
|
---|
265 | done
|
---|
266 | }
|
---|
267 |
|
---|
268 |
|
---|
269 | ChopUpAndCopyFile() {
|
---|
270 | local filename slicesize outdir res biggienumber filesize sliceno noof_slices testfile scratchfile
|
---|
271 | filename=$1
|
---|
272 | outdir=$2
|
---|
273 | slicesize=$3
|
---|
274 | biggienumber=$4
|
---|
275 |
|
---|
276 | [ -d "$filename" ] && Die "Cannot chop up $filename: it's a directory. Please amend deplist file accordingly."
|
---|
277 | mkdir -p $outdir
|
---|
278 |
|
---|
279 | sliceno=0
|
---|
280 | scratchfile=$MONDOTMP/blah.$$.dat
|
---|
281 | cp -f $filename $scratchfile || Die "CUACF -- cannot copy $filename to $scratchfile - did you run out of disk space?"
|
---|
282 | [ "`head $scratchfile -n1 | grep -F "bin/sh"`" != "" ] && StripComments $scratchfile "-$filename-"
|
---|
283 | [ "`echo "$filename" | grep -F "etc/termcap"`" != "" ] && StripComments $scratchfile "-$filename-"
|
---|
284 | if [ "`echo "$filename" | grep -F "lib/modules/" | grep "\.*o\.gz"`" != "" ] ; then
|
---|
285 | mv $scratchfile $scratchfile.gz
|
---|
286 | gunzip -f $scratchfile || LogIt "Cannot gunzip $scratchfile.gz\n"
|
---|
287 | filename=`echo "$filename" | tr '.' '#' | sed s/#o#gz/#o/ | sed s/#ko#gz/#ko/ | tr '#' '.'`
|
---|
288 | fi
|
---|
289 | filesize=`du -sk $scratchfile | cut -f1`
|
---|
290 | noof_slices=$(($filesize/$slicesize))
|
---|
291 | echo "$filename" > $outdir/slice-$biggienumber.name
|
---|
292 | echo "$filesize" > $outdir/slice-$biggienumber.size
|
---|
293 | [ -x "$scratchfile" ] && StripExecutable $scratchfile "-$filename-"
|
---|
294 | while [ "$sliceno" -le "$noof_slices" ] ; do
|
---|
295 | dd if=$scratchfile skip=$(($sliceno*$slicesize)) of=$outdir/slice-$biggienumber.`printf "%03d" $sliceno` bs=1k count=$slicesize 2> /dev/null
|
---|
296 | sliceno=$(($sliceno+1))
|
---|
297 | done
|
---|
298 | rm -f $scratchfile
|
---|
299 | }
|
---|
300 |
|
---|
301 |
|
---|
302 | CopyBootBFile() {
|
---|
303 | local copy_to copy_from possible_locations liloc
|
---|
304 | copy_to=$1
|
---|
305 | copy_from=/boot/boot.b
|
---|
306 | liloc=`which lilo.real 2>/dev/null`
|
---|
307 | [ $liloc ] || liloc=`which lilo 2>/dev/null`
|
---|
308 | if [ $liloc ]; then
|
---|
309 | if ! [ `strings $liloc | grep "boot\.b"` ]; then
|
---|
310 | LogIt "boot.b files built into lilo; I'll create a dummy.\n"
|
---|
311 | > $copy_to
|
---|
312 | return 0
|
---|
313 | fi
|
---|
314 | fi
|
---|
315 | if [ ! -f "$copy_from" ] ; then
|
---|
316 | LogIt "OK, you don't have a /boot/boot.b file, which is odd because\n most _good_ Linux distributions come with one, even if it's only a softlink"
|
---|
317 | copy_from=`grep install= /etc/lilo.conf | grep "\.b" | cut -d'=' -f2`
|
---|
318 | if [ ! -f "$copy_from" ] ; then
|
---|
319 | LogIt "Nor can I find it from your /etc/lilo.conf file. This is very odd.\n"
|
---|
320 | copy_from=`FindSensibleBootBFile`
|
---|
321 | LogIt "I'm going to use '$copy_from'\n"
|
---|
322 | fi
|
---|
323 | fi
|
---|
324 | cp -f $copy_from $copy_to || LogIt "CBBF -- warning -- cannot find your boot.b file. That's it, I quit... (j/k)\n"
|
---|
325 | }
|
---|
326 |
|
---|
327 |
|
---|
328 | CopyDependenciesToDirectory() {
|
---|
329 | local outdir incoming fname filesize counter
|
---|
330 | outdir=$1
|
---|
331 | mkdir -p $outdir
|
---|
332 | incoming=`ReadLine`
|
---|
333 | counter=0
|
---|
334 | while [ "$incoming" != "" ] ; do
|
---|
335 | if [ -d "$incoming" ] ; then
|
---|
336 | find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir
|
---|
337 | elif [ -e "$incoming" ] ; then
|
---|
338 | filesize=`du -sk $incoming | cut -f1`
|
---|
339 | if [ "$filesize" -gt "$(($CHOPSIZE*2))" ] && [ ! -h "$incoming" ] ; then
|
---|
340 | ChopUpAndCopyFile $incoming $outdir $CHOPSIZE $BIGNO
|
---|
341 | BIGNO=$(($BIGNO+1))
|
---|
342 | else
|
---|
343 | cp --parents -Rdf $incoming $outdir || Die "Cannot copy $incoming to $outdir - did you run out of disk space?"
|
---|
344 | if [ "`echo "$incoming" | grep "lib/modules/.*\..*o\.gz"`" != "" ] ; then
|
---|
345 | gunzip -f $outdir/$incoming || LogIt "Cannot gunzip $outdir/$incoming\n"
|
---|
346 | fi
|
---|
347 | [ -x "$outdir" ] && StripExecutable $outdir "-$filename-"
|
---|
348 | fi
|
---|
349 | counter=$(($counter+1))
|
---|
350 | if [ "$counter" -ge "5" ] ; then
|
---|
351 | counter=0
|
---|
352 | echo -en "."
|
---|
353 | fi
|
---|
354 | fi
|
---|
355 | incoming=`ReadLine`
|
---|
356 | done
|
---|
357 | }
|
---|
358 |
|
---|
359 |
|
---|
360 | CopyImageToDisk() {
|
---|
361 | local image dev procno res comment
|
---|
362 | image=$1
|
---|
363 | dev=$2
|
---|
364 | comment=$3
|
---|
365 | [ ! -f "$image" ] && [ ! -b "$image" ] && Die "Image $image does not exist. Did you run out of disk space?"
|
---|
366 | Prompt "About to write $comment. Please press ENTER."
|
---|
367 | echo -en "Formatting disk..."
|
---|
368 | if which fdformat > /dev/null ; then
|
---|
369 | fdformat -n $dev > /dev/null 2> /dev/null || Die "Cannot format $dev - is your Linux distro broken?"
|
---|
370 | elif which superformat > /dev/null ; then
|
---|
371 | superformat $dev > /dev/null 2> /dev/null || Die "Cannot format $dev - is your Linux distro broken?"
|
---|
372 | else
|
---|
373 | Die "Please install either fdformat or superformat."
|
---|
374 | fi
|
---|
375 | echo -en "\rWriting $comment"
|
---|
376 | if echo $image | grep "mindi-[r|b]oot\.1440" &> /dev/null ; then
|
---|
377 | cat $image > $dev &
|
---|
378 | else
|
---|
379 | dd if=$image of=$dev &> /dev/null &
|
---|
380 | fi
|
---|
381 | procno=$!
|
---|
382 | ps $procno > /dev/null 2> /dev/null
|
---|
383 | while [ "$?" -eq "0" ] ; do
|
---|
384 | sleep 3
|
---|
385 | echo -en "."
|
---|
386 | ps $procno > /dev/null 2> /dev/null
|
---|
387 | done
|
---|
388 | echo -e "$DONE"
|
---|
389 | LogIt "$comment has been written.\n"
|
---|
390 | }
|
---|
391 |
|
---|
392 |
|
---|
393 | CountItemsIn() {
|
---|
394 | local r
|
---|
395 | r=0
|
---|
396 | for q in $1 ; do
|
---|
397 | r=$(($r+1))
|
---|
398 | done
|
---|
399 | echo $r
|
---|
400 | }
|
---|
401 |
|
---|
402 |
|
---|
403 | CreateDataDiskImagesFromTarballs() {
|
---|
404 | local tardir outdir diskno noof_disks kp
|
---|
405 | tardir=$1
|
---|
406 | outdir=$2
|
---|
407 | noof_disks=$3
|
---|
408 |
|
---|
409 | mkdir -p $outdir
|
---|
410 | diskno=1
|
---|
411 | echo -en "Creating data disk "
|
---|
412 | while [ "$diskno" -le "$noof_disks" ] ; do
|
---|
413 | echo -en "#$diskno..."
|
---|
414 | cp -f $tardir/$diskno.tar.gz $outdir || LogIt "[line 424] Cannot copy $tardir/$diskno.tar.gz to $outdir\n"
|
---|
415 | CreateOneDataDiskImage $tardir/$diskno.tar.gz $outdir/mindi-data-$diskno.img $diskno $noof_disks
|
---|
416 | diskno=$(($diskno+1))
|
---|
417 | done
|
---|
418 | mv -f $tardir/all.tar.gz $outdir
|
---|
419 | du -sk $outdir/*gz >> $LOGFILE
|
---|
420 | echo -e "$DONE"
|
---|
421 | }
|
---|
422 |
|
---|
423 |
|
---|
424 |
|
---|
425 | CreateOneDataDiskImage() {
|
---|
426 | local tarball imagefile dev diskno noof_disks mountpoint
|
---|
427 | tarball=$1
|
---|
428 | imagefile=$2
|
---|
429 | diskno=$3
|
---|
430 | noof_disks=$4
|
---|
431 |
|
---|
432 | mountpoint=$MONDOTMP/mountpoint.$$
|
---|
433 | mkdir -p $mountpoint
|
---|
434 | dd if=/dev/zero of=$imagefile bs=1k count=1440 &> /dev/null || LogIt "Cannot dd (CODI)\n"
|
---|
435 | mke2fs -N 12 -F $imagefile > $MONDOTMP/mke2fs.$$ 2>> $MONDOTMP/mke2fs.$$
|
---|
436 | [ "$?" -ne "0" ] && cat $MONDOTMP/mke2fs.$$
|
---|
437 | rm -f $MONDOTMP/mke2fs.$$
|
---|
438 | mount -t ext2 -o loop $imagefile $mountpoint || Die "Can't loopmount $imagefile to $mountpoint! The reason may be missing support for loopfs or ext2 (or both) in the running kernel."
|
---|
439 | mv $tarball $mountpoint/
|
---|
440 | if [ "$?" -ne "0" ] ; then
|
---|
441 | umount $mountpoint
|
---|
442 | Die "Tarball $tarball is too big for disk! (CODI)\nTell Dev Team to adjust MAX_COMPRESSED_SIZE"
|
---|
443 | fi
|
---|
444 | [ "$diskno" -eq "$noof_disks" ] && echo "This is the last disk ($diskno=$noof_disks)" >> $mountpoint/LAST-DISK
|
---|
445 | umount $mountpoint || LogIt "Cannot umount (CODI)\n"
|
---|
446 | rmdir $mountpoint || LogIt "Cannot rmdir (CODI)\n"
|
---|
447 | }
|
---|
448 |
|
---|
449 |
|
---|
450 | DidMondoCallMe() {
|
---|
451 | local res
|
---|
452 |
|
---|
453 | res=0
|
---|
454 | [ "`ps ax | grep -F "mondoarchive" | grep -v "grep"`" ] && res=$(($res+1))
|
---|
455 | [ -f "/var/run/monitas-mondo.pid" ] && res=$(($res+1))
|
---|
456 | [ "$res" -gt "1" ] && echo "yes"
|
---|
457 | }
|
---|
458 |
|
---|
459 | # Last function called before exiting
|
---|
460 | # Parameter is exit code value
|
---|
461 | MindiExit() {
|
---|
462 | local my_partitions
|
---|
463 |
|
---|
464 | echo "Mindi $MINDI_VERSION is exiting" >> $LOGFILE
|
---|
465 | echo "End date : `date`" >> $LOGFILE
|
---|
466 |
|
---|
467 | sync
|
---|
468 | cd /
|
---|
469 |
|
---|
470 | # Unmount whtat could remain mounted
|
---|
471 | my_partitions=`mount | grep -F $$ | cut -f1 -d' '`
|
---|
472 | [ "$my_partitions" != "" ] && umount $my_partitions
|
---|
473 | # Clean temporary files
|
---|
474 | rm -Rf $MONDOTMP $FDISKLOG
|
---|
475 | exit $1
|
---|
476 | }
|
---|
477 |
|
---|
478 | Die() {
|
---|
479 | local i
|
---|
480 | if [ "$1" = "" ] ; then
|
---|
481 | LogIt "Fatal error\n"
|
---|
482 | else
|
---|
483 | LogIt "Fatal error. $1\n"
|
---|
484 | fi
|
---|
485 |
|
---|
486 | # Creates a tar file containing all required files
|
---|
487 | for i in /etc/fstab /etc/lilo.conf /etc/raidtab $LOGFILE /var/log/mondo-archive.log $FDISKLOG ; do
|
---|
488 | [ -e "$i" ] && cp -f $i $MONDOTMP
|
---|
489 | done
|
---|
490 | rm -f $TMPDIR/mindi.err.*.tgz
|
---|
491 | tar -cf - $MONDOTMP | gzip -9 > $TMPDIR/mindi.err.$$.tgz
|
---|
492 | LogIt "Please e-mail a copy of $TMPDIR/mindi.err.$$.tgz to the mailing list.\n"
|
---|
493 | LogIt "See http://www.mondorescue.org for more information.\n"
|
---|
494 | LogIt "WE CANNOT HELP unless you enclose that file.\n"
|
---|
495 | MindiExit -1
|
---|
496 | }
|
---|
497 |
|
---|
498 |
|
---|
499 | DropOptimizedLibraries() {
|
---|
500 | local outdir filelist list_of_optimized_libraries optimized_lib_name vanilla_lib_name reason msg resolved res
|
---|
501 | filelist=$1
|
---|
502 | outdir=$2
|
---|
503 |
|
---|
504 | list_of_optimized_libraries=`grep "lib/i[5-7]86/" $filelist`
|
---|
505 | if [ "$list_of_optimized_libraries" = "" ] ; then
|
---|
506 | return 0
|
---|
507 | fi
|
---|
508 | echo -en "Dropping i686-optimized libraries if appropriate"
|
---|
509 | for optimized_lib_name in $list_of_optimized_libraries ; do
|
---|
510 | echo -en "."
|
---|
511 | reason=""
|
---|
512 | vanilla_lib_name=`echo "$optimized_lib_name" | sed s/i[5-7]86// | tr -s '/' '/'`
|
---|
513 | echo "$vanilla_lib_name" >> $filelist
|
---|
514 | resolved=$vanilla_lib_name
|
---|
515 | echo "Adding $resolved to filelist" >> $LOGFILE
|
---|
516 | resolved=`ReadAllLink $resolved`
|
---|
517 | echo "Adding $resolved to filelist" >> $LOGFILE
|
---|
518 | mkdir -p $outdir$optimized_lib_name > /dev/null 2> /dev/null
|
---|
519 | rmdir $outdir$optimized_lib_name > /dev/null 2> /dev/null
|
---|
520 | ln -sf $vanilla_lib_name $outdir$optimized_lib_name
|
---|
521 | echo "Excluding $optimized_lib_name" >> $LOGFILE
|
---|
522 | grep -Fvx "$optimized_lib_name" "$filelist" > $filelist.tmp
|
---|
523 | echo "Replacing it with $vanilla_lib_name" >> $LOGFILE
|
---|
524 | echo "$vanilla_lib_name" >> $filelist.tmp
|
---|
525 | mv -f $filelist.tmp $filelist
|
---|
526 | done
|
---|
527 | $AWK '{ print $1; }' $filelist | sort -u > $filelist.tmp
|
---|
528 | mv -f $filelist.tmp $filelist
|
---|
529 | echo -e "$DONE"
|
---|
530 | }
|
---|
531 |
|
---|
532 |
|
---|
533 | FindAndAddUserKeyboardMappingFile() {
|
---|
534 | local r res mapfile mappath included_item included_list keyfile mp locale
|
---|
535 | LogIt "Analyzing your keyboard's configuration.\n"
|
---|
536 | KEYDIR=/lib/kbd
|
---|
537 | [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share/kbd # Slackware
|
---|
538 | [ ! -e "$KEYDIR" ] && KEYDIR=/usr/lib/kbd
|
---|
539 | [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share
|
---|
540 | if [ ! -e "$KEYDIR" ] ; then
|
---|
541 | LogIt "Keyboard mapping directory not found. I shall use default map at boot-time.\n"
|
---|
542 | return 0
|
---|
543 | fi
|
---|
544 | if [ -e "/etc/sysconfig/keyboard" ] ; then
|
---|
545 | echo "Red Hat-style config detected." >> $LOGFILE
|
---|
546 | keyfile=/etc/sysconfig/keyboard
|
---|
547 | elif [ -e "/etc/rc.d/rc.keymap" ] ; then
|
---|
548 | echo "Slackware-style config detected." >> $LOGFILE
|
---|
549 | keyfile=/etc/rc.d/rc.keymap
|
---|
550 | elif [ -e "/etc/rc.config" ] ; then
|
---|
551 | echo "Debian-style config detected." >> $LOGFILE
|
---|
552 | keyfile=/etc/rc.config
|
---|
553 | elif [ -e "/etc/console/boottime.kmap.gz" ] ; then
|
---|
554 | echo "Debian-style config detected." >> $LOGFILE
|
---|
555 | echo -en "Adding the following keyboard mapping tables: "
|
---|
556 | mkdir -p $bigdir/tmp
|
---|
557 | echo "/etc/console/boottime.kmap.gz" > $bigdir/tmp/KEYMAP-LIVES-HERE
|
---|
558 | KBDEPTH=0
|
---|
559 | mkdir -p $bigdir/etc/console
|
---|
560 | cp /etc/console/boottime.kmap.gz $bigdir/etc/console
|
---|
561 | echo -e "$DONE"
|
---|
562 | return 0
|
---|
563 | else
|
---|
564 | echo -en "Searching for rc.config ..."
|
---|
565 | keyfile=`find /etc -name rc.config | head -n1`
|
---|
566 | if [ "$keyfile" = "" ] || [ ! -e "$keyfile" ] ; then
|
---|
567 | LogIt "Unknown config detected. Default keyboard map will be used.\n"
|
---|
568 | return
|
---|
569 | else
|
---|
570 | echo "Found $keyfile" >> $LOGFILE
|
---|
571 | fi
|
---|
572 | fi
|
---|
573 | if [ ! -e "$KEYDIR/keymaps" ] ; then
|
---|
574 | LogIt "Keyboard mapping directory not found. Default keyboard map will be used.\n"
|
---|
575 | return
|
---|
576 | fi
|
---|
577 | echo "keyfile=$keyfile" >> $LOGFILE
|
---|
578 | locale=`grep -F KEYTABLE "$keyfile" | tr -d '"' |cut -d'=' -f2`
|
---|
579 | [ ! "$locale" ] && locale=`grep '.map$' "$keyfile" | sed 's/^.* //'` # Slackware
|
---|
580 | echo "locale=$locale" >> $LOGFILE
|
---|
581 | mp=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep -F "/${locale}." | grep -vx " *#.*"`
|
---|
582 | [ ! "$mp" ] && mp=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep "$locale[^r][^/]" | grep -vx " *#.*"`
|
---|
583 | # If we have multiple keymaps then log it !!
|
---|
584 | echo "$mp" | grep -q " "
|
---|
585 | if [ $? -eq 0 ]; then
|
---|
586 | echo "WARNING: Multiple keymaps found: $mp" | tee -a $LOGFILE
|
---|
587 | echo "The following one will be used" >> $LOGFILE
|
---|
588 | fi
|
---|
589 | for i in $mp ; do
|
---|
590 | mappath=$i
|
---|
591 | [ -e "$i" ] && [ ! -d "$i" ] && break
|
---|
592 | done
|
---|
593 | if [ ! -e "$mappath" ] || [ -d "$mappath" ] ; then
|
---|
594 | mappath=$(locate */kbd/keymaps/*/$locale)
|
---|
595 | fi
|
---|
596 | echo "mappath = $mappath" >> $LOGFILE
|
---|
597 | if [ ! -e "$mappath" ] || [ -d "$mappath" ] ; then
|
---|
598 | LogIt "Keyboard mapping file not found. Default keyboard map will be used.\n"
|
---|
599 | return
|
---|
600 | fi
|
---|
601 | echo -en "Adding the following keyboard mapping tables: "
|
---|
602 | mkdir -p $bigdir/tmp
|
---|
603 | echo "$mappath" > $bigdir/tmp/KEYMAP-LIVES-HERE
|
---|
604 | KBDEPTH=0
|
---|
605 | AddKeyboardMappingFile $mappath
|
---|
606 | echo -e "$DONE"
|
---|
607 | return 0
|
---|
608 | }
|
---|
609 |
|
---|
610 |
|
---|
611 | FindHomeOfMindiAndMondo() {
|
---|
612 | [ "$MINDI_PREFIX" = "XXX" ] && Die "Mindi has not been installed correctly."
|
---|
613 | echo "MINDI_LIB = $MINDI_LIB" >> $LOGFILE
|
---|
614 | echo "MINDI_SBIN = $MINDI_SBIN" >> $LOGFILE
|
---|
615 | [ "$MINDI_CONF" = "YYY" ] && Die "Mindi has not been installed correctly."
|
---|
616 | echo "MINDI_CONF = $MINDI_CONF" >> $LOGFILE
|
---|
617 | echo "MONDO_SHARE = $MONDO_SHARE" >> $LOGFILE
|
---|
618 | }
|
---|
619 |
|
---|
620 |
|
---|
621 | FindIsolinuxBinary() {
|
---|
622 | ISOLINUX=/usr/lib/isolinux.bin
|
---|
623 | [ ! -e "$ISOLINUX" ] && ISOLINUX=/usr/lib/syslinux/isolinux.bin
|
---|
624 | [ ! -e "$ISOLINUX" ] && ISOLINUX=/usr/share/syslinux/isolinux.bin
|
---|
625 | [ ! -e "$ISOLINUX" ] && ISOLINUX=/usr/share/lib/syslinux/isolinux.bin
|
---|
626 | [ ! -e "$ISOLINUX" ] && ISOLINUX=`locate isolinux.bin | grep -x "/.*/isolinux.bin"`
|
---|
627 | [ ! -e "$ISOLINUX" ] && Die "Please install isolinux first. If your syslinux RPM doesn't include isolinux, you may download an isolinux RPM from Mondo's website - go to http://www.mondorescue.com and click on 'Download'"
|
---|
628 | echo "Found isolinux.bin at $ISOLINUX" >> $LOGFILE
|
---|
629 | }
|
---|
630 |
|
---|
631 |
|
---|
632 | FindLiloBinary() {
|
---|
633 | if which lilo &> /dev/null ; then
|
---|
634 | if which lilo.real > /dev/null 2> /dev/null ; then
|
---|
635 | LILO_EXE=lilo.real
|
---|
636 | LogIt "lilo.real found; will be used instead of lilo (*grumble* *mutter*)\n"
|
---|
637 | else
|
---|
638 | LILO_EXE=lilo
|
---|
639 | fi
|
---|
640 | $LILO_EXE -V | grep -F "21.6" > /dev/null && Die "Please upgrade LILO. Your version has a serious bug. If you're not _using_ LILO, fine, uninstall it. :)"
|
---|
641 | else
|
---|
642 | LILO_EXE=`which false`
|
---|
643 | fi
|
---|
644 | }
|
---|
645 |
|
---|
646 |
|
---|
647 | FindELiloBinary() {
|
---|
648 | if which elilo &> /dev/null ; then
|
---|
649 | LILO_EXE=elilo
|
---|
650 | else
|
---|
651 | LILO_EXE=`which false`
|
---|
652 | fi
|
---|
653 | }
|
---|
654 |
|
---|
655 |
|
---|
656 | FixPathIfBroken() {
|
---|
657 | if [ -e "/sbin/mkfs" ] && ! which mkfs &> /dev/null ; then
|
---|
658 | PATH=$PATH:/sbin:/usr/sbin
|
---|
659 | export PATH
|
---|
660 | echo "Your PATH did not include /sbin or /usr/sbin. I have fixed that, temporarily." >> $LOGFILE
|
---|
661 | echo "However, you may wish to ask your vendor to provide a permanent fix..." >> $LOGFILE
|
---|
662 | echo "You might like to call 'su -' instead of 'su', for example." >> $LOGFILE
|
---|
663 | fi
|
---|
664 | }
|
---|
665 |
|
---|
666 |
|
---|
667 | FindSensibleBootBFile() {
|
---|
668 | local i out last
|
---|
669 | out=""
|
---|
670 | last=""
|
---|
671 | for i in `find /boot -type f | grep -v chain | grep -v os2 | sort -u` ; do
|
---|
672 | if [ "`strings $i 2> /dev/null | head -n1`" = "LILO" ] ; then
|
---|
673 | out="$out $i"
|
---|
674 | last="$i"
|
---|
675 | fi
|
---|
676 | done
|
---|
677 | echo "$last"
|
---|
678 | }
|
---|
679 |
|
---|
680 |
|
---|
681 | FindSpecificModuleInPath() {
|
---|
682 | local modpaths pwd line
|
---|
683 | pwd=`pwd`
|
---|
684 | if [ "$YOUR_KERNEL_SUCKS" ] ; then
|
---|
685 | cd $MONDOTMP
|
---|
686 | else
|
---|
687 | cd /
|
---|
688 | fi
|
---|
689 | if [ ! -e "$1" ] ; then
|
---|
690 | LogIt "Warning - cannot search specific path '$1'\n"
|
---|
691 | return 1
|
---|
692 | fi
|
---|
693 | modpaths=`find $1 -name $2.*o -type f`
|
---|
694 | [ "$?" -ne "0" ] && Die "find $1 -name $2.o -type f --- failed"
|
---|
695 | [ "$modpaths" = "" ] && modpaths=`find $1 -name $2.o.gz -type f`
|
---|
696 | [ "$modpaths" = "" ] && modpaths=`find $1 -name $2.ko.gz -type f`
|
---|
697 | [ "$modpaths" = "" ] && modpaths=`find $1 -name $2 -type f`
|
---|
698 | echo "$modpaths"
|
---|
699 | cd $pwd
|
---|
700 | }
|
---|
701 |
|
---|
702 |
|
---|
703 | GenerateGiantDependencyList() {
|
---|
704 | local incoming loc fname list_of_files i tempfile outfile progress filelist res r mapfile mappath included_list included_item old_pwd tempdepfile modres noof_lines lvmversion lvmresolved
|
---|
705 |
|
---|
706 | echo -en "Analyzing dependency requirements"
|
---|
707 | outfile=$1
|
---|
708 | tempfile=$MONDOTMP/$$.txt
|
---|
709 | incoming=`ReadLine`
|
---|
710 |
|
---|
711 | > $tempfile
|
---|
712 | progress=0
|
---|
713 | res=0
|
---|
714 | noof_lines=$2
|
---|
715 | while [ "$incoming" != "" ] ; do
|
---|
716 | if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
|
---|
717 | incoming=`ReadLine`
|
---|
718 | continue
|
---|
719 | fi
|
---|
720 | if [ "$incoming" = "LVMFILES:" ] ; then
|
---|
721 | break
|
---|
722 | fi
|
---|
723 | filelist=`GenerateListForFile "$incoming"`
|
---|
724 | r=$?
|
---|
725 | [ "$r" -ne "0" ] && LogIt "$incoming not found\n"
|
---|
726 | res=$(($res+$r))
|
---|
727 | # echo "'$incoming' generates filelist '$filelist'" >> $LOGFILE
|
---|
728 | for fname in $filelist ; do
|
---|
729 | [ "$fname" != "" ] && echo "$fname" >> $tempfile
|
---|
730 | done
|
---|
731 | progress=$(($progress+1))
|
---|
732 | echo -en "\r\t\t\t\t\t\t\t\t"
|
---|
733 | i=$(($progress*100))
|
---|
734 | i=$(($i/$noof_lines))
|
---|
735 | echo -en "$i"
|
---|
736 | echo -en "%"
|
---|
737 | modres=$(($progress%4))
|
---|
738 | [ "$modres" -eq "0" ] && echo -en "\t/"
|
---|
739 | [ "$modres" -eq "1" ] && echo -en "\t-"
|
---|
740 | [ "$modres" -eq "2" ] && echo -en "\t\\"
|
---|
741 | [ "$modres" -eq "3" ] && echo -en "\t|"
|
---|
742 | incoming=`ReadLine`
|
---|
743 | done
|
---|
744 | if [ "$incoming" = "LVMFILES:" ] ; then
|
---|
745 | incoming=`ReadLine`
|
---|
746 | lvmversion=""
|
---|
747 | while [ "$incoming" != "" ] ; do
|
---|
748 | if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
|
---|
749 | incoming=`ReadLine`
|
---|
750 | continue
|
---|
751 | fi
|
---|
752 | filelist=`GenerateListForFile "$incoming"`
|
---|
753 | for tool in $filelist ; do
|
---|
754 | lvmresolved=`readlink -f $tool`
|
---|
755 | if [ "$tool" == "$lvmresolved" ]; then
|
---|
756 | echo "$tool" >> $tempfile
|
---|
757 | elif echo "$lvmresolved" | grep "lvmiopversion" &> /dev/null ; then
|
---|
758 | if [ "$lvmversion" = "" ] ; then
|
---|
759 | lvmversion=`$lvmresolved`
|
---|
760 | echo "$lvmresolved" >> $tempfile
|
---|
761 | fi
|
---|
762 | toolstripped=`echo $tool | $AWK -F / '{print $NF;}'`
|
---|
763 | if [ "$lvmversion" == "200" ]; then
|
---|
764 | # pvdata and lvmcreate_initrd don't exist in LVM2
|
---|
765 | case "$toolstripped" in
|
---|
766 | "pvdata")
|
---|
767 | continue
|
---|
768 | ;;
|
---|
769 | "lvmcreate_initrd")
|
---|
770 | continue
|
---|
771 | ;;
|
---|
772 | esac
|
---|
773 | fi
|
---|
774 | toolpath="/sbin/lvm-"$lvmversion"/"$toolstripped
|
---|
775 | if [ -e "$toolpath" ] ; then
|
---|
776 | echo "$toolpath" >> $tempfile
|
---|
777 | echo "$tool" >> $tempfile
|
---|
778 | else
|
---|
779 | toolpath="/lib/lvm-"$lvmversion"/"$toolstripped
|
---|
780 | fi
|
---|
781 | if [ -e "$toolpath" ] ; then
|
---|
782 | echo "$toolpath" >> $tempfile
|
---|
783 | echo "$tool" >> $tempfile
|
---|
784 | else
|
---|
785 | echo "Where are your LVM-Tools? Couldn't find $tool"
|
---|
786 | fi
|
---|
787 | else
|
---|
788 | echo "$tool" >> $tempfile
|
---|
789 | fi
|
---|
790 | done
|
---|
791 | progress=$(($progress+1))
|
---|
792 | echo -en "\r\t\t\t\t\t\t\t\t"
|
---|
793 | i=$(($progress*100))
|
---|
794 | i=$(($i/$noof_lines))
|
---|
795 | echo -en "$i"
|
---|
796 | echo -en "%"
|
---|
797 | modres=$(($progress%4))
|
---|
798 | [ "$modres" -eq "0" ] && echo -en "\t/"
|
---|
799 | [ "$modres" -eq "1" ] && echo -en "\t-"
|
---|
800 | [ "$modres" -eq "2" ] && echo -en "\t\\"
|
---|
801 | [ "$modres" -eq "3" ] && echo -en "\t|"
|
---|
802 | incoming=`ReadLine`
|
---|
803 | done
|
---|
804 | fi
|
---|
805 | echo -en "$DONE\nMaking complete dependency list"
|
---|
806 |
|
---|
807 | tr -s '/' '/' < $tempfile | sort -u > $tempfile.new
|
---|
808 | mv -f $tempfile.new $tempfile
|
---|
809 | > $outfile.pre
|
---|
810 | progress=0
|
---|
811 | noof_lines=`cat $tempfile | wc -l`
|
---|
812 | for fname in `cat $tempfile` ; do
|
---|
813 | echo "$fname" >> $outfile.pre
|
---|
814 | LocateDeps $fname >> $outfile.pre
|
---|
815 | progress=$(($progress+1))
|
---|
816 | echo -en "\r\t\t\t\t\t\t\t\t"
|
---|
817 | i=$(($progress*100))
|
---|
818 | i=$(($i/$noof_lines))
|
---|
819 | echo -en "$i"
|
---|
820 | echo -en "%"
|
---|
821 | modres=$(($progress%4))
|
---|
822 | [ "$modres" -eq "0" ] && echo -en "\t/"
|
---|
823 | [ "$modres" -eq "1" ] && echo -en "\t-"
|
---|
824 | [ "$modres" -eq "2" ] && echo -en "\t\\"
|
---|
825 | [ "$modres" -eq "3" ] && echo -en "\t|"
|
---|
826 | done
|
---|
827 | if [ "`DidMondoCallMe`" ] ; then
|
---|
828 | mkdir -p $bigdir/tmp
|
---|
829 | mkdir -p $bigdir/sbin
|
---|
830 | mkdir -p $bigdir/bin
|
---|
831 | if [ -e "$MONDOTMP/post-nuke.tgz" ] ; then
|
---|
832 | LogIt "\nIncorporating post-nuke tarball\n"
|
---|
833 | old_pwd=`pwd`
|
---|
834 | cd $bigdir
|
---|
835 | tar -zxf $MONDOTMP/post-nuke.tgz || LogIt "Error occurred when untarring post-nuke tarball\n"
|
---|
836 | cd $old_pwd
|
---|
837 | fi
|
---|
838 | if cp -f $MONDOTMP/mondo*restore $bigdir/usr/bin ; then
|
---|
839 | LocateDeps $bigdir/usr/bin/mondo*restore >> $outfile.pre
|
---|
840 | else
|
---|
841 | LogIt "Cannot find mondo*restore in mondo's tempdir, $MONDOTMP\n"
|
---|
842 | LogIt "I bet you've got a spare copy of Mondo or Mindi floating around on your system.\n"
|
---|
843 | LogIt "If Mindi was called by Mondo then send me a bug report.\n It not, type 'ps ax' to see which Mondo-related process is still running;\n then kill it. :-)\n Finally, run Mindi again."
|
---|
844 | Die "Odd."
|
---|
845 | fi
|
---|
846 | cp -f $MONDOTMP/BOOTLOADER.* $bigdir 2> /dev/null || LogIt "\nMondo v1.2x defaults to LILO as the bootloader, BTW.\n"
|
---|
847 | if [ -e "$MONDOTMP/NFS-DEV" ] ; then
|
---|
848 | LogIt "Incorporating NFS-related settings\n"
|
---|
849 | for r in NFS-* ISO-PREFIX ; do
|
---|
850 | cp -f $MONDOTMP/$r $bigdir/tmp || Die "Cannot copy $r - did you run out of disk space?"
|
---|
851 | echo "Copying $r to ramdisk" >> $LOGFILE
|
---|
852 | done
|
---|
853 | fi
|
---|
854 | fi
|
---|
855 | tr ' ' '\n' < $outfile.pre | tr -s '/' '/' | grep -Fvx "" | sort -u | grep -Ev "/libX11|/libXext|/libXi|/libgtk|/libgdk" > $outfile
|
---|
856 | rm -f $tempfile $outfile.pre
|
---|
857 | [ "$res" -eq "0" ] && echo -e "\r\t\t\t\t\t\t\t\t$DONE" || echo "\nFailed."
|
---|
858 | return $res
|
---|
859 | }
|
---|
860 |
|
---|
861 |
|
---|
862 | GenerateListForFile() {
|
---|
863 | local files_found loc fname incoming i res
|
---|
864 | incoming="$1"
|
---|
865 | files_found=""
|
---|
866 | res=0
|
---|
867 |
|
---|
868 | for fname in $incoming ; do
|
---|
869 | files_found="$files_found `LocateFile $fname`"
|
---|
870 | done
|
---|
871 |
|
---|
872 | echo "$files_found" | tr ' ' '\n' | sort -u | tr '\n' ' '
|
---|
873 | }
|
---|
874 |
|
---|
875 |
|
---|
876 | # Returns all disk devices which are part of a raid array
|
---|
877 | GetAllRaidMembers() {
|
---|
878 | $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*device/ if(\$2) {print \$2}" < /etc/raidtab
|
---|
879 | }
|
---|
880 |
|
---|
881 |
|
---|
882 | GetFileSizeList() {
|
---|
883 | local i
|
---|
884 | for i in `find $1 -type d -o -print` ; do
|
---|
885 | du -sk $i
|
---|
886 | done
|
---|
887 | }
|
---|
888 |
|
---|
889 |
|
---|
890 | GetHomeDir() {
|
---|
891 | local res loc
|
---|
892 | loc=`which $1 2>/dev/null`
|
---|
893 | res=`file $loc | $AWK '{print $NF;}'`
|
---|
894 | dirname $res
|
---|
895 | }
|
---|
896 |
|
---|
897 |
|
---|
898 | # Searches parent raid device of given disk device
|
---|
899 | # $1: disk device (i.e. /dev/hda1)
|
---|
900 | GetParentRaidDev() {
|
---|
901 | $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*raiddev/ {dev=\$2} /^[[:space:]]*device/ {if(\$2==\"$1\") {print dev; exit}}" < /etc/raidtab
|
---|
902 | }
|
---|
903 |
|
---|
904 |
|
---|
905 | # Searches members of raid device
|
---|
906 | # $1: raid device (/dev/md...)
|
---|
907 | GetRaidDevMembers() {
|
---|
908 | $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*raiddev/ {if(dev) exit; if(\$2 == \"$1\") dev=\$2} /^[[:space:]]*device/ {if(dev) {print \$2}}" < /etc/raidtab
|
---|
909 | }
|
---|
910 |
|
---|
911 |
|
---|
912 | HackPathsToFailsafe() {
|
---|
913 | local incoming newpath kver stub i pwd
|
---|
914 | kver=`uname -r`
|
---|
915 | incoming=`ReadLine`
|
---|
916 | pwd=`pwd`
|
---|
917 | cd $MONDOTMP
|
---|
918 | while [ "$incoming" != "" ] ; do
|
---|
919 | stub=`basename $incoming`
|
---|
920 | newpath=`FindSpecificModuleInPath lib/modules/$FAILSAFE_KVER $stub`
|
---|
921 | for i in $newpath ; do
|
---|
922 | echo "$i"
|
---|
923 | done
|
---|
924 | read incoming
|
---|
925 | done
|
---|
926 | cd $pwd
|
---|
927 | }
|
---|
928 |
|
---|
929 |
|
---|
930 | ListAllPartitions() {
|
---|
931 | local res currline partition all_partitions ap_orig remaining i j
|
---|
932 |
|
---|
933 | grep -vx " *#.*" $MY_FSTAB | grep -vx " *none.*" | $AWK '/^\/dev\/[imhs]d||LABEL\=\// && !/fdd|cdr|zip|floppy/ {print $1}'
|
---|
934 | [ -e "/etc/raidtab" ] && $AWK '/^ *device/ {print $2}' /etc/raidtab
|
---|
935 | return
|
---|
936 | }
|
---|
937 |
|
---|
938 |
|
---|
939 | ListImagesForUser() {
|
---|
940 | local path fname
|
---|
941 | path=$1
|
---|
942 | echo -en "In the directory '$path' you will find the images:-\n"
|
---|
943 | for fname in `ls $path | grep -F mindi-` ; do
|
---|
944 | printf "%19s " $fname
|
---|
945 | done
|
---|
946 | echo " "
|
---|
947 | }
|
---|
948 |
|
---|
949 |
|
---|
950 | ListKernelModulePaths() {
|
---|
951 | local module_list module fname oss r kern
|
---|
952 | oss="/root/oss/modules"
|
---|
953 | module_list="`lsmod | sed -n '2,$s/ .*//p'`"
|
---|
954 | ###
|
---|
955 | ### Sq-Modification ... Use kernelname for module search path if specified
|
---|
956 | ###
|
---|
957 | # kern="`uname -r`"
|
---|
958 | if [ "${kernelname}" != "" -a "${kernelname}" != "FAILSAFE" ]
|
---|
959 | then
|
---|
960 | kern=${kernelname}
|
---|
961 | else
|
---|
962 | kern="`uname -r`"
|
---|
963 | fi
|
---|
964 | ###
|
---|
965 | ### Sq-Mod End
|
---|
966 | ###
|
---|
967 | for module in $module_list $EXTRA_MODS ; do
|
---|
968 | r=`find /lib/modules/$kern -type f | grep "/${module}\..*o" | tail -n1`
|
---|
969 | echo "module $module --> $r" >> $LOGFILE
|
---|
970 | [ "$r" ] && echo "$r"
|
---|
971 | [ -f "$oss" ] && find $oss | grep -F $module
|
---|
972 | done
|
---|
973 | find /lib/modules/$kern/modules.* -type f 2> /dev/null
|
---|
974 | [ -f "$oss" ] && find $oss.* 2> /dev/null
|
---|
975 | }
|
---|
976 |
|
---|
977 |
|
---|
978 | LocateDeps() {
|
---|
979 | local incoming fname deps
|
---|
980 | incoming="$1"
|
---|
981 | for fname in $incoming ; do
|
---|
982 | if [ ! -e "$fname" ] ; then
|
---|
983 | echo "Warning - $fname does not exist; cannot be LDD'd." >> $LOGFILE
|
---|
984 | if echo $fname | grep lvm &> /dev/null ; then
|
---|
985 | echo "This warning only affects you if you are using LVM." >> $LOGFILE
|
---|
986 | if lsmod | grep lvm &> /dev/null ; then
|
---|
987 | echo "I think you are, so please take heed!" >> $LOGFILE
|
---|
988 | # LogIt "Where is liblvm? You need it."
|
---|
989 | else
|
---|
990 | echo "I don't think you are, so don't worry about it." >> $LOGFILE
|
---|
991 | fi
|
---|
992 | fi
|
---|
993 | elif [ -h "$fname" ] && [ -x "$fname" ] ; then
|
---|
994 | echo "$fname is softlink" >> $LOGFILE
|
---|
995 | else
|
---|
996 | ldd $fname 2> /dev/null | ProcessLDD $fname
|
---|
997 | fi
|
---|
998 | done
|
---|
999 | }
|
---|
1000 |
|
---|
1001 |
|
---|
1002 | # Give all symlinks recursively of a full path name
|
---|
1003 | ReadAllLink() {
|
---|
1004 | file="$1"
|
---|
1005 |
|
---|
1006 | if [ ! -h $file ]; then
|
---|
1007 | echo "$file"
|
---|
1008 | return 0
|
---|
1009 | fi
|
---|
1010 |
|
---|
1011 | link=`readlink $file`
|
---|
1012 | d=`dirname $file`
|
---|
1013 | if [ ! -e "$link" -a ! -e "$d/$link" ]; then
|
---|
1014 | echo "Problem with dead link on $file -> $link" >> $LOGFILE
|
---|
1015 | fi
|
---|
1016 | if [ "`echo $link | cut -c1`" = "/" ]; then
|
---|
1017 | echo "$link `ReadAllLink $link`"
|
---|
1018 | else
|
---|
1019 | d=`dirname $file`
|
---|
1020 | echo "$link `ReadAllLink $d/$link`"
|
---|
1021 | fi
|
---|
1022 | }
|
---|
1023 |
|
---|
1024 |
|
---|
1025 | LocateFile() {
|
---|
1026 | local i path fname_to_find location output resolved tmp stub cache_id loclist
|
---|
1027 | fname_to_find="$1"
|
---|
1028 | if echo "$fname_to_find" | grep -x "/.*" ; then
|
---|
1029 | output="$fname_to_find"
|
---|
1030 | if [ -h "$output" ] ; then
|
---|
1031 | output="`ReadAllLink $output` $output"
|
---|
1032 | fi
|
---|
1033 | echo "$output"
|
---|
1034 | return 0
|
---|
1035 | fi
|
---|
1036 | output=""
|
---|
1037 | #for path in /etc /usr /usr/bin /usr/sbin /bin /usr/X11R6/bin /sbin /usr/local/bin /usr/local/sbin /usr/lib /usr/lib64 /lib /lib64 /usr/local/lib /usr/local/lib64 /usr/X11R6/lib /usr/X11R6/lib64 `find /usr/lib64 /lib64 /usr/local/lib64 /usr/X11R6/lib64 -type d` ; do
|
---|
1038 | for path in /etc /usr /usr/bin /usr/sbin /bin /usr/X11R6/bin /sbin /usr/local/bin /usr/local/sbin /usr/lib /usr/lib64 /usr/lib64/* /lib /lib64 /lib64/* /usr/local/lib /usr/local/lib64 /usr/local/lib64/* /usr/X11R6/lib /usr/X11R6/lib64 /usr/X11R6/lib64/* ; do
|
---|
1039 | [ ! -d "$path" ] && continue
|
---|
1040 | for location in "$path/$fname_to_find" ; do
|
---|
1041 | [ ! -e "$location" ] && continue
|
---|
1042 | output="$location $output"
|
---|
1043 | if [ -h "$location" ] ; then
|
---|
1044 | output="`ReadAllLink $location` $output"
|
---|
1045 | fi
|
---|
1046 | done
|
---|
1047 | done
|
---|
1048 | if [ "$output" = "" ] ; then
|
---|
1049 | return 1
|
---|
1050 | fi
|
---|
1051 | echo "$output"
|
---|
1052 | return 0
|
---|
1053 | }
|
---|
1054 |
|
---|
1055 |
|
---|
1056 | LogIt() {
|
---|
1057 | if [ -e /dev/stderr ] ; then
|
---|
1058 | echo -e "$1" >> /dev/stderr
|
---|
1059 | elif [ -e /usr/bin/logger ] ; then
|
---|
1060 | /usr/bin/logger -s $1
|
---|
1061 | fi
|
---|
1062 | echo -en "$1" >> $LOGFILE
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 |
|
---|
1066 | # Called by TurnTgzIntoRdz, to make /tmp/mondo-restore.cfg
|
---|
1067 | MakeMondoConfigFile() {
|
---|
1068 | local outfile use_lzo use_comp use_star
|
---|
1069 | outfile=$1
|
---|
1070 | > $outfile
|
---|
1071 | [ "$TAPESIZE" ] && echo "media-size $TAPESIZE" >> $outfile
|
---|
1072 | [ "$TAPEDEV" ] && echo "media-dev $TAPEDEV" >> $outfile
|
---|
1073 | [ "$FILES_IN_FILELIST" ] && echo "files-in-filelist $FILES_IN_FILELIST" >> $outfile
|
---|
1074 | [ "$LAST_FILELIST_NUMBER" ] && echo "last-filelist-number $LAST_FILELIST_NUMBER" >> $outfile
|
---|
1075 | [ "$INTERNAL_TAPE_BLOCK_SIZE" ] && echo "internal-tape-block-size $INTERNAL_TAPE_BLOCK_SIZE" >> $outfile
|
---|
1076 | use_lzo=$USE_LZO; [ "$use_lzo" = "" ] && use_lzo="no"
|
---|
1077 | use_comp=$USE_COMP; [ "$use_comp" = "" ] && use_comp="yes"
|
---|
1078 | use_star=$USE_STAR; [ "$use_star" = "" ] && use_star="no"
|
---|
1079 | echo "use-lzo $use_lzo" >> $outfile
|
---|
1080 | echo "use-star $use_star" >> $outfile
|
---|
1081 | echo "use-comp $use_comp" >> $outfile
|
---|
1082 | echo "datestamp `date`" >> $outfile
|
---|
1083 | [ "$ESTIMATED_TOTAL_NOOF_SLICES" ] && echo "total-slices $ESTIMATED_TOTAL_NOOF_SLICES" >> $outfile
|
---|
1084 | AddFileToCfgIfExists $MONDOTMP/NFS-CLIENT-IPADDR nfs-client-ipaddr $outfile
|
---|
1085 | AddFileToCfgIfExists $MONDOTMP/NFS-CLIENT-NETMASK nfs-client-netmask $outfile
|
---|
1086 | AddFileToCfgIfExists $MONDOTMP/NFS-CLIENT-BROADCAST nfs-client-broadcast $outfile
|
---|
1087 | AddFileToCfgIfExists $MONDOTMP/NFS-CLIENT-DEFGW nfs-client-defgw $outfile
|
---|
1088 | AddFileToCfgIfExists $MONDOTMP/NFS-SERVER-MOUNT nfs-server-mount $outfile
|
---|
1089 | AddFileToCfgIfExists $MONDOTMP/NFS-SERVER-PATH nfs-server-path $outfile
|
---|
1090 | AddFileToCfgIfExists $MONDOTMP/NFS-DEV nfs-dev $outfile
|
---|
1091 | AddFileToCfgIfExists $MONDOTMP/NFS-SERVER-IPADDR nfs-server-ipaddr $outfile
|
---|
1092 | AddFileToCfgIfExists $MONDOTMP/ISO-DEV iso-dev $outfile
|
---|
1093 | AddFileToCfgIfExists $MONDOTMP/ISO-MNT iso-mnt $outfile
|
---|
1094 | AddFileToCfgIfExists $MONDOTMP/ISO-PREFIX iso-prefix $outfile
|
---|
1095 | AddFileToCfgIfExists $MONDOTMP/ISODIR isodir $outfile
|
---|
1096 | AddFileToCfgIfExists $MONDOTMP/BOOTLOADER.DEVICE bootloader.device $outfile
|
---|
1097 | AddFileToCfgIfExists $MONDOTMP/BOOTLOADER.NAME bootloader.name $outfile
|
---|
1098 | AddFileToCfgIfExists $MONDOTMP/KEYMAP-LIVES-HERE keymap-lives-here $outfile
|
---|
1099 | AddFileToCfgIfExists $MONDOTMP/TAPEDEV-HAS-DATA-DISKS tapedev-has-data-disks $outfile
|
---|
1100 | AddFileToCfgIfExists $MONDOTMP/BACKUP-MEDIA-TYPE backup-media-type $outfile
|
---|
1101 | AddFileToCfgIfExists $MONDOTMP/DIFFERENTIAL differential $outfile
|
---|
1102 | }
|
---|
1103 |
|
---|
1104 |
|
---|
1105 | MakeModuleLoadingScript() {
|
---|
1106 | local module fname params modpath kver outerloop i modpaths kver searchpath list_to_echo j
|
---|
1107 | tmpmodprobe_flag=$1
|
---|
1108 | outfile=$2
|
---|
1109 | > $outfile || Die "Cannot create empty $outfile"
|
---|
1110 | echo -en "#\041/bin/sh\n\n" >> $outfile
|
---|
1111 | echo "echo -en \"Loading your modules...\"" >> $outfile
|
---|
1112 | if [ "$YOUR_KERNEL_SUCKS" ] ; then
|
---|
1113 | kver=$FAILSAFE_KVER
|
---|
1114 | cd $MONDOTMP
|
---|
1115 | searchpath=lib/modules/$kver
|
---|
1116 | else
|
---|
1117 | ###
|
---|
1118 | ### Sq-Modification ... Use kernelname for module search path if specified
|
---|
1119 | ###
|
---|
1120 | #kver=`uname -r`
|
---|
1121 | if [ "${kernelname}" != "" ]
|
---|
1122 | then
|
---|
1123 | kver=${kernelname}
|
---|
1124 | else
|
---|
1125 | kver=`uname -r`
|
---|
1126 | fi
|
---|
1127 | ###
|
---|
1128 | ### Sq-Modification end
|
---|
1129 | ###
|
---|
1130 | searchpath=/lib/modules/$kver
|
---|
1131 | fi
|
---|
1132 |
|
---|
1133 | echo -en "for outerloop in 1 2 3 4 5 ; do\necho -en \".\"\n" >> $outfile
|
---|
1134 | list_to_echo="`lsmod | sed -n '2,$s/ .*//p'`"
|
---|
1135 |
|
---|
1136 | # Make temporary modprobe.conf file if we are told so
|
---|
1137 | if [ $tmpmodprobe_flag == "Y" ] ; then
|
---|
1138 | infile="$MONDOTMP/modprobe.conf.mindi"
|
---|
1139 | find /etc/modprobe.d -maxdepth 1 -name "*" -xtype f -print0 | xargs -0 cat > $infile
|
---|
1140 | else
|
---|
1141 | infile="/etc/modules.conf"
|
---|
1142 | fi
|
---|
1143 | for module in $list_to_echo $EXTRA_MODS ; do
|
---|
1144 | params=`sed -n "s/^options \\+$module \\+//p" $infile`
|
---|
1145 | modpaths=`FindSpecificModuleInPath $searchpath $module`
|
---|
1146 | for i in $modpaths ; do
|
---|
1147 | echo "MyInsmod $i $params > /dev/null 2> /dev/null" \
|
---|
1148 | | tr '.' '#' \
|
---|
1149 | | sed s/#o#gz/#o/ \
|
---|
1150 | | sed s/#o#gz/#o/ \
|
---|
1151 | | sed s/#ko#gz/#ko/ \
|
---|
1152 | | sed s/#ko#gz/#ko/ \
|
---|
1153 | | tr '#' '.' >> $outfile
|
---|
1154 | echo -en "$i added to module list.\n" >> $LOGFILE
|
---|
1155 | done
|
---|
1156 | done
|
---|
1157 | echo -en "done\n" >> $outfile
|
---|
1158 | echo "echo \"Done.\"" >> $outfile
|
---|
1159 | chmod +x $outfile
|
---|
1160 | cd /
|
---|
1161 | # Remove temporary modprobe.conf file if we have created one
|
---|
1162 | if [ $tmpmodprobe_flag == "Y" ] ; then
|
---|
1163 | rm -f $infile
|
---|
1164 | fi
|
---|
1165 | }
|
---|
1166 |
|
---|
1167 |
|
---|
1168 | MakeMountlist() {
|
---|
1169 | local scratchdir mountlist all_partitions current_partition \
|
---|
1170 | partition_size partition_format outstring partition_number \
|
---|
1171 | partition_mountpt c_p lwm_info psz lvm_dev unofficial_outstring \
|
---|
1172 | absolute_partition old_partition_fmt current_lvolume
|
---|
1173 |
|
---|
1174 | echo "Your raw fstab file looks like this:-" >> $LOGFILE
|
---|
1175 | cat $MY_FSTAB >> $LOGFILE
|
---|
1176 | echo "Your mountlist will look like this:-"
|
---|
1177 |
|
---|
1178 | # scratchdir, mountlist(OUT)
|
---|
1179 | scratchdir=$MONDOTMP
|
---|
1180 | mountlist=$1
|
---|
1181 |
|
---|
1182 | # NB: partition = device
|
---|
1183 | # NB: mountpt = where the device is mounted
|
---|
1184 |
|
---|
1185 | [ -e "$MY_FSTAB" ] || Die "Cannot find your fstab file ($MY_FSTAB)"
|
---|
1186 |
|
---|
1187 | rm -f $mountlist
|
---|
1188 | mkdir -p $mountlist
|
---|
1189 | rm -Rf $mountlist
|
---|
1190 | > $mountlist
|
---|
1191 | echo -en "\rHang on...\r"
|
---|
1192 | all_partitions=""
|
---|
1193 |
|
---|
1194 | if [ $LVM != "false" ]; then
|
---|
1195 | echo -en "\rAnalyzing LVM...\r"
|
---|
1196 | all_partitions=`$MINDI_LIB/analyze-my-lvm | grep -F ">>>" | cut -d' ' -f2-32`
|
---|
1197 | fi
|
---|
1198 | all_partitions="$all_partitions `ListAllPartitions 2> /dev/null`"
|
---|
1199 | # echo "all partitions = $all_partitions" > /dev/stderr
|
---|
1200 | for i in $IMAGE_DEVS ; do
|
---|
1201 | mount | grep -F "$i " > /dev/null 2> /dev/null && Die "Sorry, $i is already mounted! CANNOT DO IMAGEDEV on it if it's mounted."
|
---|
1202 | done
|
---|
1203 | [ "$IMAGE_DEVS" != "" ] && all_partitions="`echo "$all_partitions $IMAGE_DEVS" | tr ' ' '\n' | sort -u | tr '\n ' ' '`"
|
---|
1204 | printf " %-15s %-15s %-15s %-15s %-15s\n" DEVICE MOUNTPOINT FORMAT "SIZE (MB)" LABEL
|
---|
1205 | useless_dev="/dev/floppy /dev/fd0h1440 /dev/fd0H1440 /dev/cdrom /dev/cdrom/cdrom /dev/cdrom/cdrom1 /dev/cdrom/cdrom2 /dev/cdrom0 /dev/cdrom1 /dev/cdrom2 /dev/cdrom3 /dev/cdrw /dev/scd /dev/ram :/ /dev/sr0 /dev/sr1 /dev/cdrom1"
|
---|
1206 | for c_p in $all_partitions ; do
|
---|
1207 | [ "`echo "$useless_dev" | grep -F "$c_p"`" != "" ] || [ "`echo "$c_p" | grep ":"`" != "" ] && continue
|
---|
1208 | [ "`echo "$c_p" | grep -x "/dev/cdroms.*"`" ] && continue
|
---|
1209 | if [ -h "$c_p" ] && [ "`echo "$c_p" | grep -F "/dev/hd"`" = "" ] && [ "`echo "$c_p" | grep -F "/dev/sd"`" = "" ] && [ "`echo "$c_p" | grep -F "/dev/md"`" = "" ] ; then
|
---|
1210 | current_partition=`readlink -f $c_p`
|
---|
1211 | [ "`echo "$current_partition" | grep -F "/dev/mapper"`" != "" ] && current_partition="$c_p"
|
---|
1212 | [ "`echo "$useless_dev" | grep -F "$current_partition"`" ] && continue
|
---|
1213 | else
|
---|
1214 | current_partition="$c_p"
|
---|
1215 | fi
|
---|
1216 | [ "$c_p" = "none" ] && continue
|
---|
1217 | redhat_label=""
|
---|
1218 | absolute_partition=`readlink -f $c_p`
|
---|
1219 | partition_mountpt=`tr -s '\t' ' ' < $MY_FSTAB | /bin/grep -w "$current_partition" | /bin/grep -vx " *#.*" | $AWK '{print $2}' | head -n1`
|
---|
1220 |
|
---|
1221 | # Detects noauto partitions not mounted and exclude them
|
---|
1222 | partition_option=`tr -s '\t' ' ' < $MY_FSTAB | /bin/grep -w "$current_partition" | /bin/grep -vx " *#.*" | $AWK '{print $4}' | head -n1`
|
---|
1223 | if [ "`echo "$partition_option" | grep -i noauto`" != "" ] && [ "`mount | grep -w "$partition_mountpt"`" = "" ] ; then
|
---|
1224 | continue
|
---|
1225 | fi
|
---|
1226 |
|
---|
1227 | # This part tries to retrieve the correct device from a LABEL line in /etc/fstab
|
---|
1228 | # current_partition contains only first column of /etc/fstab
|
---|
1229 | if [ "`echo "$current_partition" | /bin/grep -i "LABEL="`" != "" ]; then
|
---|
1230 | str_to_find_fmt_with=$current_partition
|
---|
1231 | redhat_label=`echo "$current_partition" | /bin/cut -d'=' -f2`
|
---|
1232 | actual_dev=""
|
---|
1233 |
|
---|
1234 | # 1st try, findfs - the RHEL way of finding labels and their partitions
|
---|
1235 | if [ -x "/sbin/findfs" ]; then
|
---|
1236 | actual_dev=`/sbin/findfs LABEL=${redhat_label} 2> /dev/null`
|
---|
1237 | fi
|
---|
1238 |
|
---|
1239 | # 2nd try : blkid, the good way for all LABEL except swap
|
---|
1240 | if [ "x$actual_dev" = "x" -a -x "/sbin/blkid" ]; then
|
---|
1241 | actual_dev=`/sbin/blkid | /bin/grep "$redhat_label" | grep LABEL= | /bin/cut -d':' -f1`
|
---|
1242 | # For LVM FS it will give a /dev/dm-# which should then be converted
|
---|
1243 | if [ $LVM = "v2" ] && [ "`echo $actual_dev | grep '/dev/dm'`" ]; then
|
---|
1244 | major=`/bin/ls -l $actual_dev | awk '{print $5}'`
|
---|
1245 | minor=`/bin/ls -l $actual_dev | awk '{print $6}'`
|
---|
1246 | for dev in `ls /dev/mapper/*`; do
|
---|
1247 | major1=`/bin/ls -l $dev | awk '{print $5}'`
|
---|
1248 | minor1=`/bin/ls -l $dev | awk '{print $6}'`
|
---|
1249 | if [ $major1 = $major ] && [ $minor1 = $minor ]; then
|
---|
1250 | actual_dev=`/bin/ls -l $dev | awk '{print $10}'`
|
---|
1251 | break
|
---|
1252 | fi
|
---|
1253 | done
|
---|
1254 | fi
|
---|
1255 | fi
|
---|
1256 |
|
---|
1257 | # 3rd try, which works on a standard partition (ext2/3), but not on swap
|
---|
1258 | # For LVM gives a /dev/mapper entry
|
---|
1259 | if [ "x$actual_dev" = "x" ]; then
|
---|
1260 | actual_dev=`/bin/mount -l | /bin/grep "\[$redhat_label\]" | /bin/cut -d' ' -f1`
|
---|
1261 | fi
|
---|
1262 |
|
---|
1263 | # 4th try, with vol_id
|
---|
1264 | # SWAP only
|
---|
1265 | if [ "x$actual_dev" = "x" -a -x "/sbin/vol_id" ]; then
|
---|
1266 | list_swaps=`cat /proc/swaps | /bin/grep "/dev/" | /bin/awk '{ print $1 }' `
|
---|
1267 | for dev_swap in $list_swaps ; do
|
---|
1268 | dev_exists=`/sbin/vol_id $dev_swap | /bin/grep "$redhat_label"`
|
---|
1269 | if [ "x$dev_exists" != "x" ]; then
|
---|
1270 | actual_dev=$dev_swap
|
---|
1271 | break;
|
---|
1272 | fi
|
---|
1273 | done
|
---|
1274 | fi
|
---|
1275 |
|
---|
1276 | # 5th try : pre-formated LABEL. Format is : LABEL=SWAP-mydevice or SW-mydevice. e.g. : LABEL=SWAP-hda5
|
---|
1277 | # LABEL=SW-cciss/c0d0p3 (RDP)
|
---|
1278 | # or could be a string that isn't a complete device name (eg. LABEL =SWAP-cciss/c0d0p)
|
---|
1279 | # SWAP only
|
---|
1280 | if [ "x$actual_dev" = "x" -a _"`echo $current_partition | /bin/grep -iE 'LABEL=SWAP|LABEL=SW-'`" != _"" ]; then
|
---|
1281 | for try_dev in `tail +2 /proc/swaps | cut -d' ' -f1`
|
---|
1282 | do
|
---|
1283 | # Location of the swap label for kernel 2.6
|
---|
1284 | try_dev_label=`dd bs=1 count=16 skip=1052 if=$try_dev 2> /dev/null`
|
---|
1285 | if [ "x$try_dev_label" = "x$redhat_label" ]; then
|
---|
1286 | actual_dev=$try_dev
|
---|
1287 | fi
|
---|
1288 | done
|
---|
1289 | fi
|
---|
1290 |
|
---|
1291 | # Check if one of all those tries has known success
|
---|
1292 | if [ "x$actual_dev" != "x" ]; then
|
---|
1293 | current_partition=$actual_dev
|
---|
1294 | else
|
---|
1295 | Die "Your system uses a labelled partition ($current_partition), but you lack the tool to support it.\nPlease replace labels with their correct devices in /etc/fstab or install findfs|blkid|vol_id\n"
|
---|
1296 | fi
|
---|
1297 | else
|
---|
1298 | str_to_find_fmt_with=$current_partition
|
---|
1299 | fi
|
---|
1300 |
|
---|
1301 | partition_format=`$AWK '$1 == "'"$str_to_find_fmt_with"'" {print $3}' $MY_FSTAB`
|
---|
1302 | # Some distributions such as Debian do not put /dev/<VG>/<LV> in fstab
|
---|
1303 | # for LVM partitions but use /dev/mapper/<VG>-<LV> instead. Fortunately,
|
---|
1304 | # the former is then a link to the latter, so we test whether
|
---|
1305 | # $current_partition is actually such a link or not and set
|
---|
1306 | # $current_lvolume accordingly. On Debian you may find more than one answer
|
---|
1307 | # so we remove the one corresponding to /dev/.static
|
---|
1308 | # On RedHat even if the device name is different (/dev/mapper/<VG><LV>), the
|
---|
1309 | # principle is the same and we need to find the link to it as well.
|
---|
1310 | # Note that $current_lvolume may well be an
|
---|
1311 | # ordinary device. It is just to make sure that we feed the right value
|
---|
1312 | # into any of the LVM tools if possible.
|
---|
1313 |
|
---|
1314 | current_lvolume="$current_partition"
|
---|
1315 | if [ $LVM = "v2" ] && [ "`echo $current_partition | grep -E '^/dev/mapper/'`" ]; then
|
---|
1316 | # .static dir are a Debian specificity
|
---|
1317 | current_lvolume="`find /dev -lname "$current_partition" | grep -Ev '^/dev/\.static/'`"
|
---|
1318 | echo $current_lvolume | grep -q ' '
|
---|
1319 | if [ $? -eq 0 ]; then
|
---|
1320 | echo "WARNING: Multiple Logical Volumes found. Report to dev team" >> $LOGFILE
|
---|
1321 | fi
|
---|
1322 | fi
|
---|
1323 | #
|
---|
1324 | # End of LVM device style variation code (other than $current_lvolume).
|
---|
1325 |
|
---|
1326 | if [ $LVM != "false" ] && [ "`$LVMCMD lvdisplay $current_lvolume 2> /dev/null`" ]; then
|
---|
1327 | # Size computed via LVM not directly
|
---|
1328 | partition_size="lvm"
|
---|
1329 | else
|
---|
1330 | partition_size=`SizeOfPartition $current_partition`
|
---|
1331 | [ "`echo "$current_partition" | grep "[0-9]"`" = "" ] && continue
|
---|
1332 | [ "`echo "$current_partition" | grep -c "^/"`" -ne "1" ] && continue
|
---|
1333 | if [ "$partition_format" = "swap" ] || [ "$partition_mountpt" = "swap" ] ; then
|
---|
1334 | partition_size=`grep -Fv "Priority" /proc/swaps | tr -s '\t' ' ' | grep -F "$current_partition" | $AWK '{print $3}'`
|
---|
1335 | [ "$partition_mountpt" != "swap" ] && partition_mountpt="swap"
|
---|
1336 | [ "$partition_format" != "swap" ] && partition_format="swap"
|
---|
1337 | if [ "$partition_size" = "" ] ; then
|
---|
1338 | totalsize=0
|
---|
1339 | items=0
|
---|
1340 | for i in `tr -s ' ' '\t' < /proc/swaps | grep -Fv "Filename" | cut -f3` ; do
|
---|
1341 | totalsize=$(($totalsize+$i))
|
---|
1342 | items=$(($items+1))
|
---|
1343 | done
|
---|
1344 | [ "$items" -gt "0" ] && partition_size=$(($totalsize/$items)) || partition_size=0
|
---|
1345 | [ "$partition_size" -lt "125000" ] && partition_size=125000
|
---|
1346 | echo "I'm guessing $c_p is $(($partition_size/1024))MB" >> $LOGFILE
|
---|
1347 | fi
|
---|
1348 | fi
|
---|
1349 | fi
|
---|
1350 | [ "$partition_mountpt" = "swap" ] && partition_format="swap"
|
---|
1351 | [ "$partition_format" = "swap" ] && partition_mountpt="swap"
|
---|
1352 | if [ "$partition_mountpt" = "" ] ; then
|
---|
1353 | if [ "`$LVMCMD pvdisplay $current_lvolume 2> /dev/null`" != "" ] ; then
|
---|
1354 | if [ "`grep -F device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
|
---|
1355 | partition_mountpt="raid"
|
---|
1356 | partition_format="raid"
|
---|
1357 | else
|
---|
1358 | partition_mountpt="lvm"
|
---|
1359 | partition_format="lvm"
|
---|
1360 | fi
|
---|
1361 | fi
|
---|
1362 | fi
|
---|
1363 | psz=$partition_size
|
---|
1364 | echo "Examining $current_partition (mount=$partition_mountpt fmt=$partition_format psz=$psz)" >> $LOGFILE
|
---|
1365 | [ "$psz" != "lvm" ] && psz=$(($psz/1024))
|
---|
1366 | if [ "`echo " $IMAGE_DEVS " | grep -F " $current_partition "`" != "" ] ; then
|
---|
1367 | partition_mountpt="image"
|
---|
1368 | old_partition_fmt=$partition_format
|
---|
1369 | # partition_format="`$FDISK -l 2>> $LOGFILE | tr -s '\t' ' ' | grep -w "$absolute_partition" | $AWK 'x=$(NF-1}'`"
|
---|
1370 | partition_format="`$FDISK -l 2>> $LOGFILE | tr '*' ' ' | tr '+' ' ' | tr -s ' ' '\t' | grep -w "$absolute_partition" | cut -f5`"
|
---|
1371 | echo "------- $FDISK -l log ------------" >> $LOGFILE
|
---|
1372 | cat $FDISKLOG >> $LOGFILE
|
---|
1373 | echo "------- $FDISK log end ------------" >> $LOGFILE
|
---|
1374 | partition_size=$(($partition_size+1)); # just in case
|
---|
1375 | if [ "$partition_format" = "Linux" ] ; then
|
---|
1376 | echo "Are you imaging a mounted swap partition? Silly..." >> $LOGFILE
|
---|
1377 | echo "Reverting format from $old_partition_fmt to $partition_format" >> $LOGFILE
|
---|
1378 | partition_format=$old_partition_fmt
|
---|
1379 | fi
|
---|
1380 | fi
|
---|
1381 | if [ "$EXCLUDE_DEVS" ] && [ "`echo " $EXCLUDE_DEVS " | grep -F " $current_partition "`" ] || [ "`echo " $EXCLUDE_DEVS " | grep " $current_partition "`" ] ; then
|
---|
1382 | echo "Excluding $current_partition from mountlist" >> $LOGFILE
|
---|
1383 | continue
|
---|
1384 | fi
|
---|
1385 | if [ ! "$partition_mountpt" ] ; then
|
---|
1386 | for qq in "" `find /dev/ida/c*d* ! -name '*p*'` ; do
|
---|
1387 | partition_format=`$FDISK -l $qq 2>> $LOGFILE | grep -w "$c_p" | sed 's/12/|/' | tr -s '\t' ' ' | cut -d'|' -f2 | cut -d' ' -f2-9`
|
---|
1388 | echo "------- $FDISK -l $qq log ------------" >> $LOGFILE
|
---|
1389 | cat $FDISKLOG >> $LOGFILE
|
---|
1390 | echo "------- $FDISK log end ------------" >> $LOGFILE
|
---|
1391 | [ "$partition_format" ] && break
|
---|
1392 | done
|
---|
1393 | if [ "$partition_format" = "Compaq diagnostics" ] ; then
|
---|
1394 | partition_format="compaq"
|
---|
1395 | elif [ ! "`grep -F device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
|
---|
1396 | LogIt "Unable to find mountpoint of $current_partition - ignoring\n"
|
---|
1397 | continue
|
---|
1398 | fi
|
---|
1399 | fi
|
---|
1400 | partition_format="`echo "$partition_format" | cut -d',' -f1`"; # in case user has ext3,ext2 or something dumb like that
|
---|
1401 | [ "$partition_format" = "auto" ] && partition_format="`mount | grep -w $current_partition | awk '{print$5;}'`"; # in case user uses 'auto' (dumb!)
|
---|
1402 | unofficial_outstring=`printf "\t%-15s %-15s %-15s %7s\n" $current_partition $partition_mountpt $partition_format $psz`
|
---|
1403 | if [ "$current_partition" = "" ] ; then
|
---|
1404 | echo "Unknown partition (outstring = $unofficial_outstring)" >> $LOGFILE
|
---|
1405 | elif [ "$partition_mountpt" = "" ] && [ -f "/etc/raidtab" ] ; then
|
---|
1406 | if [ "`grep -F device /etc/raidtab 2>/dev/null | grep -F $current_partition`" ] ; then
|
---|
1407 | partition_mountpt=raid
|
---|
1408 | partition_format=raid
|
---|
1409 | printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
|
---|
1410 | printf "%s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" >> $mountlist
|
---|
1411 | else
|
---|
1412 | echo "Unknown mountpoint (outstring = $unofficial_outstring)" >> $LOGFILE
|
---|
1413 | fi
|
---|
1414 | elif [ "$partition_format" = "" ] ; then
|
---|
1415 | echo "Unknown format (outstring = $unofficial_outstring)" >> $LOGFILE
|
---|
1416 | elif [ "$partition_size" = "" ] ; then
|
---|
1417 | echo "Unknown partition size (outstring = $unofficial_outstring)" >> $LOGFILE
|
---|
1418 | elif [ "$partition_mountpt" = "/proc" ] || [ "$partition_mountpt" = "/dev/pts" ] ; then
|
---|
1419 | continue
|
---|
1420 | else
|
---|
1421 | if [ "$partition_format" = "dos" ] || [ "$partition_format" = "msdos" ] ; then
|
---|
1422 | echo "Stupid bastard..." >> $LOGFILE
|
---|
1423 | partition_format="vfat"
|
---|
1424 | fi
|
---|
1425 | printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
|
---|
1426 | printf "%s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" >> $mountlist
|
---|
1427 | fi
|
---|
1428 | done
|
---|
1429 | }
|
---|
1430 |
|
---|
1431 |
|
---|
1432 | MakeSureNumberIsInteger() {
|
---|
1433 | res=`echo "$1" | tr -s '\-[0-9]' ' '`
|
---|
1434 | if [ "$res" != " " ] && [ "$res" != "" ] ; then
|
---|
1435 | echo "result = '$res'"
|
---|
1436 | Die "$1 should be an integer"
|
---|
1437 | fi
|
---|
1438 | }
|
---|
1439 |
|
---|
1440 |
|
---|
1441 | MakeSyslinuxMessageFile() {
|
---|
1442 | mkdir -p $1
|
---|
1443 | rmdir $1
|
---|
1444 | echo -en " " > $1
|
---|
1445 | if [ "`grep -Fi "debian" /etc/issue.net 2> /dev/null`" ] ; then
|
---|
1446 | sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cut -d ' ' -f 3 /etc/issue.net` `hostname`"% | sed s/KKKKK/"Kernel `uname -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ >> $1.tmp
|
---|
1447 | else
|
---|
1448 | sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`grep -i "linux" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`grep -i "kernel" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' '\\r' 'on' 'an' '\/' '`uname -r`' 'on' 'an' '`uname -m`/ >> $1.tmp
|
---|
1449 | fi
|
---|
1450 | sed s/%r/"`uname -r`"/ $1.tmp | sed s/%t/"`hostname`"/ > $1
|
---|
1451 | rm -f $1.tmp
|
---|
1452 | if [ "$CDRECOVERY" != "yes" ] ; then
|
---|
1453 | if [ -e "$MONDOTMP/NFS-DEV" ] ; then
|
---|
1454 | echo -en "Press <enter> to continue.\n" >> $1
|
---|
1455 | elif [ ! "$MONDOTMP" ] ; then
|
---|
1456 | echo -en "FYI, this is _not_ a Mondo Rescue CD.\n" >> $1
|
---|
1457 | if [ -e "$MINDI_LIB/memtest.img" ] ; then
|
---|
1458 | echo -en "Type 'memtest' <Enter> to test your PC's memory intensively.\nJust press <Enter> to go to the main test menu.\n" >> $1
|
---|
1459 | fi
|
---|
1460 | else
|
---|
1461 | echo -en "$BOOT_MEDIA_MESSAGE" >> $1
|
---|
1462 | fi
|
---|
1463 | else
|
---|
1464 | echo -en " \
|
---|
1465 | To restore your disk to factory defaults, type 'RESTORE' <enter>.\n\
|
---|
1466 | CAUTION: THIS WILL ERASE YOUR WHOLE DISK !!!\n" >> $1
|
---|
1467 | fi
|
---|
1468 | }
|
---|
1469 |
|
---|
1470 |
|
---|
1471 | MoveHyperlinkSensibly() {
|
---|
1472 | local filename minidir_root resides_on_diskno noof_disks old_diskno d old_pwd
|
---|
1473 | filename=$1
|
---|
1474 | minidir_root=$2
|
---|
1475 | resides_on_diskno=$3
|
---|
1476 | noof_disks=$4
|
---|
1477 |
|
---|
1478 | [ -h "$minidir_root/$resides_on_diskno/$filename" ] || Die "$filename isn't a softlink (or doesn't exist): how can I move it sensibly?"
|
---|
1479 |
|
---|
1480 | old_diskno=$resides_on_diskno
|
---|
1481 | d=1
|
---|
1482 | while [ "$d" -le "$noof_disks" ] ; do
|
---|
1483 | if [ "$d" -ne "$old_diskno" ] ; then
|
---|
1484 | old_pwd=`pwd`
|
---|
1485 | cd $minidir_root/$old_diskno
|
---|
1486 | cp --parents -Rdf $filename $minidir_root/$d/ || Die "Can't move $filename (sensibly) from $old_diskno to $d"
|
---|
1487 | rm -f $filename
|
---|
1488 | cd $old_pwd
|
---|
1489 | fi
|
---|
1490 | # when the softlink is resolvable, our work here is done
|
---|
1491 | [ -e "$minidir_root/$d/$filename" ] && return 0
|
---|
1492 | old_diskno=$d
|
---|
1493 | d=$(($d+1))
|
---|
1494 | done
|
---|
1495 | return 1
|
---|
1496 | }
|
---|
1497 |
|
---|
1498 |
|
---|
1499 | OfferToCopyImagesToDisks() {
|
---|
1500 | local imagesdir i imagename dev count boot_dev data_dev
|
---|
1501 | imagesdir=$1
|
---|
1502 | boot_dev=$2
|
---|
1503 | data_dev=$3
|
---|
1504 |
|
---|
1505 | echo -en "Would you like to create boot+data floppy disks now (y/n) ?"
|
---|
1506 | read i
|
---|
1507 | [ "$i" != "y" ] && [ "$i" != "Y" ] && return
|
---|
1508 | mount | grep -F /dev/fd > /dev/null && Die "Please unmount your floppies first."
|
---|
1509 | echo "WARNING! THIS WILL ERASE YOUR FLOPPY DISKS."
|
---|
1510 | [ ! -e "$boot_dev" ] && Die "Cannot find $boot_dev - is your Linux distro broken?"
|
---|
1511 | [ ! -e "$data_dev" ] && Die "Cannot find $data_dev - is your Linux distro broken?"
|
---|
1512 | i=`find $imagesdir -type f | grep -F "/mindi-root.1" 2> /dev/null`
|
---|
1513 | j=`find $imagesdir -type f | grep -F "/mindi-boot" | grep -Ev '2880|5760'`
|
---|
1514 | if [ "$i" ] ; then
|
---|
1515 | CopyImageToDisk $j $data_dev "boot disk"
|
---|
1516 | CopyImageToDisk $i $data_dev "root disk"
|
---|
1517 | else
|
---|
1518 | CopyImageToDisk $j $boot_dev "boot/root disk"
|
---|
1519 | fi
|
---|
1520 | count=1
|
---|
1521 | for i in `find $imagesdir | grep -F mindi-data` ; do
|
---|
1522 | CopyImageToDisk $i $data_dev "data disk #$count"
|
---|
1523 | count=$(($count+1))
|
---|
1524 | done
|
---|
1525 | }
|
---|
1526 |
|
---|
1527 |
|
---|
1528 | OfferToMakeBootableISO() {
|
---|
1529 | local i old_pwd
|
---|
1530 | if [ "$PROMPT_MAKE_CD_IMAGE" = "yes" ] && [ ! "`DidMondoCallMe`" ] ; then
|
---|
1531 | echo -en "Shall I make a bootable CD image? (y/n) "
|
---|
1532 | read i
|
---|
1533 | [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
|
---|
1534 | fi
|
---|
1535 | if [ ! "$MONDOTMP" ] ; then
|
---|
1536 | LogIt "NB: Mindi's bootable CD always uses isolinux.\n"
|
---|
1537 | LogIt "For a bootable CD w/LILO, please use Mondo.\n"
|
---|
1538 | fi
|
---|
1539 | rm -Rf $MONDOTMP/iso
|
---|
1540 | mkdir -p $MONDOTMP/iso/{images,archives,isolinux}
|
---|
1541 | cp -f $1/*.img $1/*.gz $MONDOTMP/iso/images || LogIt "OfferToMakeBootableISO: Cannot copy $i to $MONDOTMP/iso/images\n"
|
---|
1542 | old_pwd=`pwd`
|
---|
1543 | cd $MONDOTMP/iso
|
---|
1544 | mkdir -p $MONDO_ROOT/iso/isolinux
|
---|
1545 | echo "mindi_lib = $MINDI_LIB" >> $LOGFILE
|
---|
1546 | cp $MINDI_LIB/mem{test,disk}* $MONDO_ROOT 2>> $LOGFILE
|
---|
1547 | for i in memdisk memtest.bin memtest.img ; do
|
---|
1548 | j=$MINDI_LIB/$i
|
---|
1549 | k=$MONDOTMP/iso/isolinux
|
---|
1550 | if [ -e "$j" ] ; then
|
---|
1551 | LogIt "Copying $j to $k\n"
|
---|
1552 | cp -f $j $k || Die "Failed to copy $j to $k"
|
---|
1553 | cp -f $j $MONDOTMP || Die "Failed to copy $j to $k"
|
---|
1554 | fi
|
---|
1555 | done
|
---|
1556 | MakeSyslinuxMessageFile $MONDOTMP/iso/isolinux/message.txt
|
---|
1557 | cp $kernelpath $MONDOTMP/iso/isolinux/vmlinuz || Die "Cannot copy vmlinuz ($kernelpath) to mondo root ($MONDO_ROOT/isolinux/vmlinuz). Did you run out of disk space?"
|
---|
1558 | cp $MONDOTMP/mindi.rdz $MONDOTMP/iso/isolinux/initrd.img
|
---|
1559 | cp $MONDOTMP/mindi.rdz $CACHE_LOC/initrd.img
|
---|
1560 | [ -e "$iso_cfg_file" ] || Die "FIXME - unable to find $iso_cfg_file - this should never occur"
|
---|
1561 | cd $MONDOTMP/iso/isolinux
|
---|
1562 | cat $iso_cfg_file | HackSyslinuxFile $ramdisk_size $MONDOTMP/iso > isolinux.cfg || Die "Cannot copy isolinux.cfg from mindi_home to tmp_root - did you run out of disk space?"
|
---|
1563 | if [ -e "$MONDOTMP/NFS-DEV" ] ; then
|
---|
1564 | mv isolinux.cfg isolinux.cfg.old
|
---|
1565 | sed s/interactive/iso/ isolinux.cfg.old > isolinux.cfg
|
---|
1566 | fi
|
---|
1567 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1568 | cp $ISOLINUX isolinux.bin || Die "Cannot copy isolinux.bin ($ISOLINUX) to tmp_root - did you run out of disk space?"
|
---|
1569 | cp $ISOLINUX ../
|
---|
1570 | fi
|
---|
1571 | cd $MONDOTMP/iso
|
---|
1572 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1573 | cp -f $MONDOTMP/iso/isolinux/{isolinux.cfg,initrd.img,vmlinuz,isolinux.bin,message.txt} $MONDO_ROOT || Die "Cannot copy core files to ramdisk for boot disk. Did you run out of disk space?"
|
---|
1574 | fi
|
---|
1575 | [ "$MONDO_SHARE" ] && cp -f $MONDO_SHARE/autorun .
|
---|
1576 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1577 | mkisofs -U -J -r -o $CACHEDIR/mindi.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table . > /dev/null 2> /tmp/$$.mk
|
---|
1578 | else
|
---|
1579 | mkisofs -J -r -o $CACHEDIR/mindi.iso -b images/mindi-bootroot.$IA64_BOOT_SIZE.img -c isolinux/boot.cat -no-emul-boot . > /dev/null 2> /tmp/$$.mk
|
---|
1580 | fi
|
---|
1581 | if [ "$?" -ne "0" ] ; then
|
---|
1582 | echo "----------- mkisofs's errors --------------" >> $LOGFILE
|
---|
1583 | cat $MONDOTMP/mkisofs.log >> $LOGFILE
|
---|
1584 | echo "mkisofs returned the following errors:-"
|
---|
1585 | cat $MONDOTMP/mkisofs.log
|
---|
1586 | LogIt "Failed to create ISO image.\n"
|
---|
1587 | else
|
---|
1588 | echo "Created bootable ISO image at $CACHEDIR/mindi.iso" >> $LOGFILE
|
---|
1589 | fi
|
---|
1590 | rm -f $MONDOTMP/mkisofs.log
|
---|
1591 | cd $old_pwd
|
---|
1592 | }
|
---|
1593 |
|
---|
1594 |
|
---|
1595 | PluralOrNot() {
|
---|
1596 | [ "$1" -gt "1" ] && echo -en "s"
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 |
|
---|
1600 | MakeMessageFile() {
|
---|
1601 | local disksize
|
---|
1602 | disksize=$1
|
---|
1603 | if [ "`grep -Fi "debian" /etc/issue.net 2> /dev/null`" ] ; then
|
---|
1604 | sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cut -d ' ' -f 3 /etc/issue.net` `hostname`"% | sed s/KKKKK/"Kernel `uname -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/
|
---|
1605 | else
|
---|
1606 | sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`grep -i "linux" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`grep -i "kernel" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' 'r' 'on' 'an' 'm/' '`uname -r`' 'on' 'an' '`uname -m`/
|
---|
1607 | fi
|
---|
1608 | if [ "$disksize" -gt "2880" ] ; then
|
---|
1609 | if [ "`DidMondoCallMe`" ] ; then
|
---|
1610 | if [ "$CDRECOVERY" != "yes" ] ; then
|
---|
1611 | if [ -e "$MONDOTMP/NFS-DEV" ] ; then
|
---|
1612 | echo -en "Press <enter> to continue.\n"
|
---|
1613 | elif [ ! "$MONDOTMP" ] ; then
|
---|
1614 | echo -en "FYI, this is _not_ a Mondo Rescue CD.\n"
|
---|
1615 | else
|
---|
1616 | echo -en "$BOOT_MEDIA_MESSAGE"
|
---|
1617 | fi
|
---|
1618 | fi
|
---|
1619 | fi
|
---|
1620 | fi
|
---|
1621 | if [ "$CDRECOVERY" = "yes" ] ; then
|
---|
1622 | echo -en "\
|
---|
1623 | To restore your disk to factory defaults, type 'RESTORE' <enter>.\n\
|
---|
1624 | CAUTION: THIS WILL ERASE YOUR WHOLE DISK !!!\n"
|
---|
1625 | fi
|
---|
1626 | echo -en "\n\n\n"
|
---|
1627 | }
|
---|
1628 |
|
---|
1629 |
|
---|
1630 | write_full_floppy_of_kernel() {
|
---|
1631 | local mtpt image old_pwd res disksize
|
---|
1632 |
|
---|
1633 | res=0
|
---|
1634 | old_pwd=`pwd`
|
---|
1635 | KERN_DISK_MADE=1
|
---|
1636 | disksize=$3
|
---|
1637 | rand1=$RANDOM
|
---|
1638 | rand2=$RANDOM
|
---|
1639 | image=$MONDOTMP/$rand1.$rand2.img
|
---|
1640 | mtpt=$MONDOTMP/$rand1.$rand2.mtpt
|
---|
1641 | dd if=/dev/zero of=$image bs=1k count=$disksize
|
---|
1642 | mke2fs -N 26 -F $image > /dev/null
|
---|
1643 | mkdir -p $mtpt
|
---|
1644 | mount -o loop $image $mtpt
|
---|
1645 | cd $mtpt
|
---|
1646 | mkdir -p {dev,tmp,boot}
|
---|
1647 | cp -f $1 vmlinuz
|
---|
1648 | if [ "$?" -ne "0" ] ; then
|
---|
1649 | LogIt "Failed to copy $1 to ramdisk\n"
|
---|
1650 | cd $old_pwd
|
---|
1651 | umount $mtpt
|
---|
1652 | rmdir $mtpt
|
---|
1653 | rm $image
|
---|
1654 | return 1
|
---|
1655 | fi
|
---|
1656 |
|
---|
1657 | rdev vmlinuz 2,0
|
---|
1658 | rdev -R vmlinuz 0
|
---|
1659 | rdev -r vmlinuz 49152
|
---|
1660 |
|
---|
1661 | tar -zxf $MINDI_LIB/dev.tgz || LogIt "Cannot untar dev.tgz\n"
|
---|
1662 | losetup /dev/loop0 > /dev/null 2> /dev/null
|
---|
1663 | [ "$?" -eq "0" ] || losetup /dev/loop0 -d || Die "Please free up /dev/loop0 by typing 'losetup /dev/loop0 -d'.\nReboot if necessary.\n"
|
---|
1664 | CopyBootBFile $mtpt/boot.b
|
---|
1665 |
|
---|
1666 | MakeLiloConfFile $disksize >> bdlilo.conf
|
---|
1667 |
|
---|
1668 | chmod 644 bdlilo.conf
|
---|
1669 | MakeMessageFile $disksize > message
|
---|
1670 | lilo -v -C bdlilo.conf -r $mtpt
|
---|
1671 | res=$?
|
---|
1672 |
|
---|
1673 | cd $old_pwd
|
---|
1674 | umount $mtpt
|
---|
1675 | mv -f $image $2
|
---|
1676 | rmdir $mtpt
|
---|
1677 |
|
---|
1678 | return $res
|
---|
1679 | }
|
---|
1680 |
|
---|
1681 |
|
---|
1682 | MakeLiloConfFile() {
|
---|
1683 | local disksize options i ooo
|
---|
1684 | disksize=$1
|
---|
1685 | options=""
|
---|
1686 |
|
---|
1687 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1688 | echo -en "boot=/dev/loop0\ndisk=/dev/loop0\n"
|
---|
1689 | fi
|
---|
1690 | if [ "$disksize" -eq "2880" ] ; then
|
---|
1691 | echo -en "bios=0x00\nsectors=36\nheads=2\ncylinders=80\n"
|
---|
1692 | elif [ "$disksize" -eq "1722" ] ; then
|
---|
1693 | echo -en "bios=0x00\nsectors=21\nheads=2\ncylinders=82\n"
|
---|
1694 | elif [ "$disksize" -gt "2880" ] ; then
|
---|
1695 | /bin/true
|
---|
1696 | else
|
---|
1697 | echo -en "bios=0x00\nsectors=18\nheads=2\ncylinders=80\n"
|
---|
1698 | fi
|
---|
1699 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1700 | echo -en "install=/boot.b\nmap=/boot.map\n"
|
---|
1701 | fi
|
---|
1702 | if [ "$CDRECOVERY" = "yes" ] ; then
|
---|
1703 | echo -en "default=RESTORE\n"
|
---|
1704 | elif [ "$disksize" -gt "2880" ] && [ "`DidMondoCallMe`" ] ; then
|
---|
1705 | if [ -e "$MONDOTMP/NFS-DEV" ] ; then
|
---|
1706 | echo -en "default=iso\n"
|
---|
1707 | else
|
---|
1708 | echo -en "default=interactive\n"
|
---|
1709 | fi
|
---|
1710 | else
|
---|
1711 | echo -en "default=expert\n"
|
---|
1712 | fi
|
---|
1713 |
|
---|
1714 | echo -en "prompt\n"
|
---|
1715 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1716 | echo -en "vga=normal\nbackup=/dev/null\nmessage=/message\n"
|
---|
1717 | fi
|
---|
1718 | if [ "$CDRECOVERY" != "yes" ] ; then
|
---|
1719 | echo -en "timeout=300\n"
|
---|
1720 | fi
|
---|
1721 | echo -en "\n"
|
---|
1722 | if [ "$CDRECOVERY" = "yes" ] ; then
|
---|
1723 | options="RESTORE expert"
|
---|
1724 | elif [ "$disksize" -gt "2880" ] ; then
|
---|
1725 | if [ "`DidMondoCallMe`" ] ; then
|
---|
1726 | if [ -e "$MONDOTMP/NFS-DEV" ] ; then
|
---|
1727 | options="iso"
|
---|
1728 | else
|
---|
1729 | options="interactive expert compare iso nuke isonuke"
|
---|
1730 | # hda hdb hdc hdd"
|
---|
1731 | fi
|
---|
1732 | else
|
---|
1733 | options="expert"
|
---|
1734 | fi
|
---|
1735 | else
|
---|
1736 | options="expert"
|
---|
1737 | fi
|
---|
1738 | for i in $options ; do
|
---|
1739 | ooo=$i
|
---|
1740 | [ "$ooo" = "RESTORE" ] && ooo="nuke"
|
---|
1741 | if [ "$ARCH" = "ia64" ] ; then
|
---|
1742 | rootpart="root=/dev/ram0\n\t"
|
---|
1743 | else
|
---|
1744 | rootpart=""
|
---|
1745 | fi
|
---|
1746 | outstr="image=vmlinuz\n\tlabel=$i\n\tinitrd=/mindi.rdz\n\t${rootpart}append=\" rw ramdisk=$ramdisksize ramdisk_size=$ramdisksize maxcpus=1 $ooo_mode $ADDITIONAL_BOOT_PARAMS"
|
---|
1747 |
|
---|
1748 | outstr=$outstr" $ooo_mode"
|
---|
1749 | outstr=$outstr"\"\n"
|
---|
1750 | if [ "$disksize" = "1440" ] ; then
|
---|
1751 | echo -en "$outstr" | sed s/initrd=.*// | grep -v root=
|
---|
1752 | else
|
---|
1753 | echo -en "$outstr"
|
---|
1754 | fi
|
---|
1755 | done
|
---|
1756 | }
|
---|
1757 |
|
---|
1758 |
|
---|
1759 | PrepareBootDiskImage_LILO() {
|
---|
1760 | local disksize imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf
|
---|
1761 | imagesdir=$1
|
---|
1762 | disksize=$2
|
---|
1763 | kernelpath=$3
|
---|
1764 | ramdisksize=$4
|
---|
1765 |
|
---|
1766 | retval=0
|
---|
1767 | [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
|
---|
1768 | echo -en "Making "$disksize"KB boot disk..."
|
---|
1769 | TurnTgzIntoRdz $MINDI_LIB/rootfs $MONDOTMP/mindi.rdz $ramdisksize $disksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
|
---|
1770 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1771 | [ "$disksize" != "1722" ] && [ "$disksize" != "2880" ] && [ "$disksize" != "5760" ] && Die "PDBI - disksize is $disksize - bad size"
|
---|
1772 | fi
|
---|
1773 | echo -en "..."
|
---|
1774 | imagefile=$imagesdir/mindi-bootroot.$disksize.img
|
---|
1775 | mountpoint=$MONDOTMP/mountpoint.$$
|
---|
1776 | mkdir -p $mountpoint
|
---|
1777 | dd if=/dev/zero of=$imagefile bs=1k count=$disksize &> /dev/null || Die "Cannot dd blank file"
|
---|
1778 | if [ "$ARCH" = "ia64" ] ; then
|
---|
1779 | mkdosfs $imagefile > $MONDOTMP/mke2fs.log 2>> $MONDOTMP/mke2fs.log
|
---|
1780 | t=vfat
|
---|
1781 | else
|
---|
1782 | mke2fs -N 26 -m 0 -F $imagefile > $MONDOTMP/mke2fs.log 2>> $MONDOTMP/mke2fs.log
|
---|
1783 | t=ext2
|
---|
1784 | fi
|
---|
1785 | [ "$?" -ne "0" ] && cat $MONDOTMP/mke2fs.log
|
---|
1786 | rm -f $MONDOTMP/mke2fs.log
|
---|
1787 | mount -t $t -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)\n\n"
|
---|
1788 | # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
|
---|
1789 | mkdir -p $mountpoint/etc
|
---|
1790 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1791 | liloconf=$mountpoint/etc/lilo.conf
|
---|
1792 | else
|
---|
1793 | liloconf=$mountpoint/elilo.conf
|
---|
1794 | fi
|
---|
1795 | old_pwd=`pwd`
|
---|
1796 | cd $mountpoint
|
---|
1797 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1798 | tar -zxf $MINDI_LIB/dev.tgz || LogIt "Cannot untar dev.tgz\n"
|
---|
1799 | fi
|
---|
1800 | cd $old_pwd
|
---|
1801 | losetup /dev/loop0 > /dev/null 2> /dev/null
|
---|
1802 | [ "$?" -eq "0" ] || losetup /dev/loop0 -d || Die "Please free up /dev/loop0 by typing 'losetup /dev/loop0 -d'.\nReboot if necessary.\n"
|
---|
1803 | CopyBootBFile $mountpoint/boot.b
|
---|
1804 |
|
---|
1805 | MakeLiloConfFile $disksize > $liloconf
|
---|
1806 |
|
---|
1807 | echo "Copying $MONDOTMP/mindi.rdz to $mountpoint..." >> $LOGFILE
|
---|
1808 | cp -f $MONDOTMP/mindi.rdz $mountpoint 2>> $LOGFILE
|
---|
1809 | if [ "$?" -ne "0" ] ; then
|
---|
1810 | LogIt "Failed to copy $MONDOTMP/mindi.rdz to $mountpoint\n"
|
---|
1811 | cat $MONDOTMP/mtpt.$$ >> $LOGFILE
|
---|
1812 | LogIt "Please unload some of your modules and try again.\n"
|
---|
1813 | rm -f $MONDOTMP/mtpt.$$
|
---|
1814 | LogIt "Cannot incorporate mindi.rdz in bootdisk (kernel / modules too big?)\n"
|
---|
1815 | retval=$(($retval+1))
|
---|
1816 | fi
|
---|
1817 | MakeMessageFile $disksize > $mountpoint/message
|
---|
1818 |
|
---|
1819 | mkdir -p $mountpoint/tmp
|
---|
1820 | cp -f $MONDOTMP/mondo-restore.cfg $mountpoint/tmp &> /dev/null
|
---|
1821 | if [ -e "$MINDI_LIB/memtest.img" ] ; then
|
---|
1822 | echo -en "image=/memtest.bin\nlabel=memtest\nn" >> $liloconf
|
---|
1823 | echo -en "image=/memdisk\nlabel=memtest\nappend=\"initrd=memtest.img\"\n" >> $liloconf
|
---|
1824 | # echo "Yep, this is a multi-function CD" > $mountpoint/MULTIFUNC
|
---|
1825 | fi
|
---|
1826 |
|
---|
1827 | # copy the kernel across
|
---|
1828 | rm -Rf $mountpoint/lost+found
|
---|
1829 | dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
|
---|
1830 | free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
|
---|
1831 | cp -f $kernelpath $mountpoint/vmlinuz > /dev/null 2> /dev/null
|
---|
1832 | if [ "$?" -ne "0" ] || [ "$FORCE_DUAL_FLOPPIES" = "yes" ] ; then
|
---|
1833 | echo "Files at mountpoint ($mountpoint) :-" >> $LOGFILE
|
---|
1834 | du -sk $mountpoint/* >> $LOGFILE
|
---|
1835 | echo "--- end of list of files ---" >> $LOGFILE
|
---|
1836 | echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n\
|
---|
1837 | Sorry, your kernel is too big for a boot/root floppy.\nI'll try the new boot/root two-disk thingy.\n" >> $LOGFILE
|
---|
1838 | rm -f $mountpoint/vmlinuz
|
---|
1839 | cd $old_pwd
|
---|
1840 | umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
|
---|
1841 | rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
|
---|
1842 | # losetup /dev/loop0 -d
|
---|
1843 | res=0
|
---|
1844 | write_full_floppy_of_kernel $kernelpath $imagesdir/mindi-boot.1440.img 1440
|
---|
1845 | res=$(($res+$?))
|
---|
1846 | cp -f $MONDOTMP/mindi.rdz $imagesdir/mindi-root.1440.img
|
---|
1847 | res=$(($res+$?))
|
---|
1848 | rm -f $imagefile
|
---|
1849 | if [ "$res" -ne "0" ]; then
|
---|
1850 | LogIt "Warning - failed to create 1.44MB boot/root floppies\n"
|
---|
1851 | rm -f $imagesdir/mindi-*.1440.img
|
---|
1852 | fi
|
---|
1853 | return $res
|
---|
1854 | fi
|
---|
1855 | free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
|
---|
1856 | max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
|
---|
1857 | echo "Free space left on floppy = $free_space KB" >> $LOGFILE
|
---|
1858 | echo "Max kernel size on $disksize KB floppy (est'd) = $max_kernel_size K" >> $LOGFILE
|
---|
1859 | # make it bootable
|
---|
1860 | rm -f $mountpoint/zero
|
---|
1861 | [ -e "$MINDI_LIB/memdisk" ] && cp -f $MINDI_LIB/memdisk $mountpoint
|
---|
1862 | if [ "$disksize" -gt "2880" ] && [ ! "$KERN_DISK_MADE" ] ; then
|
---|
1863 | if [ "$ARCH" != "ia64" ] ; then
|
---|
1864 | $LILO_EXE $LILO_OPTIONS -r $mountpoint >> $LOGFILE 2>> $LOGFILE
|
---|
1865 | else
|
---|
1866 | /bin/true
|
---|
1867 | fi
|
---|
1868 | elif [ ! "$KERN_DISK_MADE" ] ; then
|
---|
1869 | # 12/28/2001 - if 1.72MB floppy then don't use LILO's optimizations at all
|
---|
1870 | $LILO_EXE -r $mountpoint >> $LOGFILE 2>> $LOGFILE
|
---|
1871 | else
|
---|
1872 | echo "Not running LILO. It's not that kind of disk." >> $LOGFILE
|
---|
1873 | fi
|
---|
1874 |
|
---|
1875 | # BERLIOS does not test necessarily what it expects
|
---|
1876 | if [ $? -ne "0" ] ; then
|
---|
1877 | if [ "`grep -F "/tmp/dev.0" $LOGFILE`" ] ; then
|
---|
1878 | LogIt "The '/tmp/dev.0' error is NOT Mindi's fault. It is LILO's.\n"
|
---|
1879 | LogIt "Please reboot your PC as a workaround.\n"
|
---|
1880 | Die "LILO sneezed and Mindi caught a cold. Please read the README / FAQ.\n"
|
---|
1881 | fi
|
---|
1882 | echo "$LILO_EXE -r $mountpoint ...failed."
|
---|
1883 | echo -en "Press ENTER to continue."; read line
|
---|
1884 | LogIt "Cannot run lilo on $mountpoint\nPlease upgrade/downgrade your version of LILO. It has a bug.\n"
|
---|
1885 | retval=$(($retval+1))
|
---|
1886 | fi
|
---|
1887 | cp -f $liloconf $MONDOTMP/lilo.conf
|
---|
1888 | if [ "$ARCH" = "ia64" ] ; then
|
---|
1889 | cp `dirname $kernelpath`/*.efi $mountpoint
|
---|
1890 | fi
|
---|
1891 | umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
|
---|
1892 | echo -en "..."
|
---|
1893 | rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
|
---|
1894 | if [ "$retval" -eq "0" ] ; then
|
---|
1895 | echo -en "...$DONE\r"
|
---|
1896 | if [ "$KERN_DISK_MADE" ] ; then
|
---|
1897 | LogIt "... $disksize KB boot disks were created OK\r"
|
---|
1898 | fi
|
---|
1899 | else
|
---|
1900 | echo -en "...failed\r"
|
---|
1901 | LogIt $disksize"KB boot disk was NOT created\r"
|
---|
1902 | rm -f $imagefile
|
---|
1903 | fi
|
---|
1904 | [ "$retval" -ne "0" ] && LogIt "PrepareBootDiskImage() is returning nonzero\n"
|
---|
1905 | return $retval
|
---|
1906 | }
|
---|
1907 |
|
---|
1908 |
|
---|
1909 | PrepareBootDiskImage_SYSLINUX() {
|
---|
1910 | local disksize imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootimage
|
---|
1911 | imagesdir=$1
|
---|
1912 | disksize=$2
|
---|
1913 | kernelpath=$3
|
---|
1914 | ramdisksize=$4
|
---|
1915 | do_boot_root_thingy=""
|
---|
1916 | local retval old_pwd
|
---|
1917 | retval=0
|
---|
1918 |
|
---|
1919 | [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
|
---|
1920 | echo -en "Making "$disksize"KB boot disk..."
|
---|
1921 | TurnTgzIntoRdz $MINDI_LIB/rootfs $MONDOTMP/mindi.rdz $ramdisksize $disksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
|
---|
1922 | [ "$disksize" != "1722" ] && [ "$disksize" != "2880" ] && [ "$disksize" != "5760" ] && Die "PDBI - disksize is $disksize - bad size"
|
---|
1923 | echo -en "..."
|
---|
1924 | imagefile=$imagesdir/mindi-bootroot.$disksize.img
|
---|
1925 | mountpoint=$MONDOTMP/mountpoint.$$
|
---|
1926 | mkdir -p $mountpoint
|
---|
1927 | # If I format a 1722KB data file & run syslinux on it, the resultant image
|
---|
1928 | # won't boot. So, I have formatted a floppy, called syslinux on/to it, and
|
---|
1929 | # used 'dd' to copy it to sys-disk.raw (zipped to sys-disk.raw.gz).
|
---|
1930 | # If I extract it, mount it, copy my files to it, etc. then the resultant
|
---|
1931 | # image _is_ bootable. I don't know why syslinux and/or mkfs.vfat won't
|
---|
1932 | # play nicely and I don't care. :) I have worked around the problem. -Hugo, 06/27/2002
|
---|
1933 | if [ "$disksize" = "1722" ] ; then
|
---|
1934 | gzip -dc $MINDI_LIB/sys-disk.raw.gz > $imagefile || Die "Cannot dd blank file"
|
---|
1935 | else
|
---|
1936 | dd if=/dev/zero of=$imagefile bs=1k count=$disksize &> /dev/null || Die "Cannot dd blank file"
|
---|
1937 | mkfs.vfat $imagefile
|
---|
1938 | syslinux $imagefile
|
---|
1939 | fi
|
---|
1940 | mount -t vfat -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)\n\n"
|
---|
1941 |
|
---|
1942 | # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
|
---|
1943 | old_pwd=`pwd`
|
---|
1944 | MakeSyslinuxMessageFile $mountpoint/message.txt
|
---|
1945 | cd $mountpoint
|
---|
1946 | [ -e "$sys_cfg_file" ] || Die "Obi Wan, word up?"
|
---|
1947 | cat $sys_cfg_file | HackSyslinuxFile $ramdisk_size $mountpoint > syslinux.cfg || Die "Cannot copy syslinux.cfg from mindi_home to tmp_root"
|
---|
1948 | if [ -e "$MONDOTMP/NFS-DEV" ] ; then
|
---|
1949 | mv syslinux.cfg syslinux.cfg.orig
|
---|
1950 | sed s/interactive/iso/ syslinux.cfg.orig > syslinux.cfg
|
---|
1951 | fi
|
---|
1952 | cd $old_pwd
|
---|
1953 | echo "Copying $MONDOTMP/mindi.rdz to $mountpoint/initrd.img..." >> $LOGFILE
|
---|
1954 | cp -f $MONDOTMP/mindi.rdz $mountpoint/initrd.img 2>> $LOGFILE
|
---|
1955 | if [ "$?" -ne "0" ] ; then
|
---|
1956 | LogIt "Failed to copy $MONDOTMP/mindi.rdz to $mountpoint\n"
|
---|
1957 | cat $MONDOTMP/mtpt.$$ >> $LOGFILE
|
---|
1958 | LogIt "Please unload some of your modules and try again.\n"
|
---|
1959 | rm -f $MONDOTMP/mtpt.$$
|
---|
1960 | LogIt "Cannot incorporate mindi.rdz in bootdisk (kernel / modules too big?)\n"
|
---|
1961 | retval=$(($retval+1))
|
---|
1962 | fi
|
---|
1963 |
|
---|
1964 | mkdir -p $mountpoint/tmp
|
---|
1965 | cp -f $MONDOTMP/mondo-restore.cfg $mountpoint/tmp &> /dev/null
|
---|
1966 |
|
---|
1967 | # copy the kernel across
|
---|
1968 | rm -Rf $mountpoint/lost+found
|
---|
1969 | dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
|
---|
1970 | free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
|
---|
1971 | cp -f $kernelpath $mountpoint/vmlinuz &> /dev/null
|
---|
1972 | if [ "$?" -ne "0" ] || [ "$FORCE_DUAL_FLOPPIES" = "yes" ] ; then
|
---|
1973 | echo "Files at mountpoint ($mountpoint) :-" >> $LOGFILE
|
---|
1974 | du -sk $mountpoint/* >> $LOGFILE
|
---|
1975 | echo "--- end of list of files ---" >> $LOGFILE
|
---|
1976 | echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n\
|
---|
1977 | Sorry, your kernel is too big for a boot/root floppy.\nI'll try the new boot/root two-disk thingy.\n" >> $LOGFILE
|
---|
1978 | rm -f $mountpoint/vmlinuz
|
---|
1979 | cd $old_pwd
|
---|
1980 | umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
|
---|
1981 | rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
|
---|
1982 |
|
---|
1983 | res=0
|
---|
1984 | write_full_floppy_of_kernel $kernelpath $imagesdir/mindi-boot.1440.img 1440
|
---|
1985 | res=$(($res+$?))
|
---|
1986 | cp -f $MONDOTMP/mindi.rdz $imagesdir/mindi-root.1440.img
|
---|
1987 | res=$(($res+$?))
|
---|
1988 | rm -f $imagefile
|
---|
1989 | if [ "$res" -ne "0" ]; then
|
---|
1990 | LogIt "Warning - failed to create 1.44MB boot/root floppies\n"
|
---|
1991 | rm -f $imagesdir/mindi-*.1440.img
|
---|
1992 | fi
|
---|
1993 | return $res
|
---|
1994 | fi
|
---|
1995 | free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
|
---|
1996 | max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
|
---|
1997 | echo "Free space left on floppy = $free_space KB" >> $LOGFILE
|
---|
1998 | echo "Max kernel size on $disksize KB floppy (est'd) = $max_kernel_size K" >> $LOGFILE
|
---|
1999 |
|
---|
2000 | # make it bootable
|
---|
2001 | rm -f $mountpoint/zero
|
---|
2002 | mkdir -p $mountpoint/etc
|
---|
2003 | [ -e "$MINDI_LIB/memdisk" ] && cp -f $MINDI_LIB/memdisk $mountpoint
|
---|
2004 | umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
|
---|
2005 | echo -en "..."
|
---|
2006 | rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
|
---|
2007 |
|
---|
2008 | if [ "$retval" -eq "0" ] ; then
|
---|
2009 | echo -en "...$DONE\r"
|
---|
2010 | if [ "$KERN_DISK_MADE" ] ; then
|
---|
2011 | rm -f $imagefile
|
---|
2012 | LogIt "... $disksize KB boot disks were created OK\r"
|
---|
2013 | fi
|
---|
2014 | else
|
---|
2015 | echo -en "...failed\r"
|
---|
2016 | LogIt $disksize"KB boot disk was NOT created\r"
|
---|
2017 | rm -f $imagefile
|
---|
2018 | fi
|
---|
2019 | [ "$retval" -ne "0" ] && LogIt "PrepareBootDiskImage() is returning nonzero\n"
|
---|
2020 | return $retval
|
---|
2021 | }
|
---|
2022 |
|
---|
2023 |
|
---|
2024 | PrepareDataDiskImages() {
|
---|
2025 | local needlist bigdir minidir_root tardir diskdir imagesdir res i j k old_pwd lines
|
---|
2026 |
|
---|
2027 | imagesdir=$1
|
---|
2028 | rm -f $imagesdir/mindi-*.img $imagesdir/[0-9]*.tar.gz $imagesdir/mindi.iso
|
---|
2029 | needlist=$MONDOTMP/what-we-need.txt
|
---|
2030 | bigdir=$MONDOTMP/bigdir
|
---|
2031 | minidir_root=$MONDOTMP/minidir
|
---|
2032 | mkdir -p $minidir_root
|
---|
2033 | mkdir -p $bigdir/usr/bin
|
---|
2034 | tardir=$MONDOTMP/tardir
|
---|
2035 |
|
---|
2036 | lines=`grep -vx " *#.*" $MINDI_CONF/deplist.txt | grep -vx "" | wc -l`
|
---|
2037 | cat $MINDI_CONF/deplist.txt | GenerateGiantDependencyList $needlist $lines
|
---|
2038 | res=$?
|
---|
2039 | if [ "$YOUR_KERNEL_SUCKS" ]; then
|
---|
2040 | pwd=`pwd`
|
---|
2041 | cd $MONDOTMP
|
---|
2042 | for i in `ListKernelModulePaths | HackPathsToFailsafe` ; do
|
---|
2043 | cp --parents -pRdf ./$i $bigdir || Die "PDDI can't cp $i->$bigdir"
|
---|
2044 | if [ "`du -sk $i | cut -f1`" -lt "$(($CHOPSIZE*2))" ] ; then
|
---|
2045 | cp --parents -pRdf $i $bigdir
|
---|
2046 | else
|
---|
2047 | ChopUpAndCopyFile $i $bigdir $CHOPSIZE $BIGNO
|
---|
2048 | BIGNO=$(($BIGNO+1))
|
---|
2049 | fi
|
---|
2050 | done
|
---|
2051 | for i in $EXTRA_MODS ; do
|
---|
2052 | j=`find lib/modules/$FAILSAFE_KVER -name $i.*o 2> /dev/null`
|
---|
2053 | [ ! "$j" ] && echo "Warning - cannot find failsafe module $i.o" >> $LOGFILE
|
---|
2054 | for k in $j ; do
|
---|
2055 | if [ "`du -sk $k | cut -f1`" -lt "$CHOPSIZE" ] ; then
|
---|
2056 | cp --parents -pRdf $k $bigdir
|
---|
2057 | else
|
---|
2058 | ChopUpAndCopyFile $k $bigdir $CHOPSIZE $BIGNO
|
---|
2059 | BIGNO=$(($BIGNO+1))
|
---|
2060 | fi
|
---|
2061 | echo "Added failsafe module $k to ramdisk" >> $LOGFILE
|
---|
2062 | done
|
---|
2063 | done
|
---|
2064 | cd $pwd
|
---|
2065 | else
|
---|
2066 | ListKernelModulePaths >> $needlist
|
---|
2067 | fi
|
---|
2068 | if [ "$res" -ne "0" ] ; then
|
---|
2069 | Die "You have $res file`PluralOrNot $res` present in dependency list\nbut absent from filesystem."
|
---|
2070 | fi
|
---|
2071 | FindAndAddUserKeyboardMappingFile
|
---|
2072 | mkdir -p $bigdir/tmp
|
---|
2073 | if [ "`DidMondoCallMe`" ] ; then
|
---|
2074 | MakeMondoConfigFile $MONDOTMP/mondo-restore.cfg
|
---|
2075 | cp -f $MONDOTMP/mondo-restore.cfg $bigdir/tmp &> /dev/null
|
---|
2076 | fi
|
---|
2077 | [ -d "/mnt/.boot.d" ] && echo "Oh Jebus" > $bigdir/tmp/DUMBASS-GENTOO
|
---|
2078 | DropOptimizedLibraries $needlist $bigdir
|
---|
2079 | echo -en "Assembling dependency files"
|
---|
2080 | CopyDependenciesToDirectory < $needlist $bigdir
|
---|
2081 |
|
---|
2082 | # also copy io.sys and msdos.sys, if we can find them
|
---|
2083 | for i in `mount | cut -d' ' -f3` ; do
|
---|
2084 | for j in io.sys msdos.sys ; do
|
---|
2085 | [ -e "$i/$j" ] && cp -f $i/$j $bigdir
|
---|
2086 | done
|
---|
2087 | done
|
---|
2088 |
|
---|
2089 | # master boot record, too
|
---|
2090 | i=`cat $MONDOTMP/BOOTLOADER.DEVICE 2> /dev/null`
|
---|
2091 | if [ "$i" ] ; then
|
---|
2092 | LogIt "Backing up $i's MBR\n"
|
---|
2093 | dd if=$i of=$bigdir/BOOTLOADER.MBR bs=446 count=1 >> $LOGFILE 2>> $LOGFILE
|
---|
2094 | sleep 1
|
---|
2095 | sync
|
---|
2096 | j=$i
|
---|
2097 | [ -h "$j" ] && j=`readlink -f $j`
|
---|
2098 | LogIt "Creating /dev/boot_device ($j)\n"
|
---|
2099 | mkdir -p $bigdir/dev
|
---|
2100 | cp -pRdf $j $bigdir/dev/boot_device || Die "Unable to create /dev/boot_device on ramdisk"
|
---|
2101 | fi
|
---|
2102 |
|
---|
2103 | old_pwd=`pwd`
|
---|
2104 | cd $bigdir
|
---|
2105 |
|
---|
2106 | [ -e "$MINDI_LIB/aux-tools" ] || Die "aux-tools not found in Mindi's home dir. Do you have multiple copies of Mindi lying around? Please delete them. No, don't e-mail me and ask how. ;) Use 'rm'."
|
---|
2107 | cp -Rdf $MINDI_LIB/aux-tools/* . 2>> $LOGFILE || LogIt "Warning - error occurred while unzipping aux-tools\n"
|
---|
2108 | if [ -e "$MINDI_LIB/x11-tools.tgz" ] ; then
|
---|
2109 | tar -zxf $MINDI_LIB/x11-tools.tgz 2>> $LOGFILE || LogIt "Warning - error occurred while unzipping x11-tools.tgz\n"
|
---|
2110 | fi
|
---|
2111 | if [ -e "$MONDO_SHARE/restore-scripts" ] ; then
|
---|
2112 | cp -Rdf $MONDO_SHARE/restore-scripts/* . 2>> $LOGFILE
|
---|
2113 | [ "$?" -ne "0" ] && [ "`DidMondoCallMe`" ] && Die "Cannot find/install $MONDO_SHARE/restore-scripts"
|
---|
2114 | fi
|
---|
2115 | [ -d "/lib/dev-state" ] && cp --parents -pRdf /lib/dev-state .
|
---|
2116 | cd $old_pwd
|
---|
2117 | echo -e "$DONE"
|
---|
2118 | TOTAL_BIGDIR_SIZE=`du -sk $bigdir | cut -f1`
|
---|
2119 | SplitDirectoryIntoMinidirs $bigdir $minidir_root
|
---|
2120 | noof_disks=$?
|
---|
2121 | [ "$noof_disks" -eq "0" ] && Die "Too much stuff!"
|
---|
2122 | # if [ "$noof_disks" -ge "8" ] ; then
|
---|
2123 | # LogIt "You are putting a ludicrously large amount of data on these disks."
|
---|
2124 | # LogIt "I shall therefore double EXTRA_SPACE, just in case your ramdisk is too small."
|
---|
2125 | # EXTRA_SPACE=$(($EXTRA_SPACE*2))
|
---|
2126 | # fi
|
---|
2127 | MakeMountlist $MONDOTMP/mountlist.txt
|
---|
2128 | mkdir -p $minidir_root/$noof_disks/tmp
|
---|
2129 | cp -f $MONDOTMP/mountlist.txt $minidir_root/$noof_disks/tmp/mountlist.txt || Die "Cannot copy mountlist.txt from $MONDOTMP to data disk"
|
---|
2130 | [ "`DidMondoCallMe`" ] && cp -f $minidir_root/$noof_disks/tmp/mountlist.txt $MONDOTMP/.
|
---|
2131 | [ $LVM != "false" ] && $MINDI_LIB/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
|
---|
2132 | cat $minidir_root/$noof_disks/tmp/mountlist.txt >> $LOGFILE
|
---|
2133 | ZipMinidirsIntoTarballs $minidir_root $tardir $noof_disks
|
---|
2134 | CreateDataDiskImagesFromTarballs $tardir $imagesdir $noof_disks
|
---|
2135 | FRIENDLY_OUTSTRING="Boot and data disk images were created."
|
---|
2136 | # One 1.72MB boot disk, one 2.88MB boot disk and $noof_disks data disk images
|
---|
2137 | rmdir $tardir $bigdir
|
---|
2138 | rm -f $needlist
|
---|
2139 | return $noof_disks
|
---|
2140 | }
|
---|
2141 |
|
---|
2142 |
|
---|
2143 | ProcessLDD() {
|
---|
2144 | local main_fname incoming j i fname f newf
|
---|
2145 | main_fname=$1
|
---|
2146 | read incoming
|
---|
2147 | while [ "$incoming" != "" ] ; do
|
---|
2148 | # We take the full path name of the dyn. lib. we want
|
---|
2149 | incoming=`echo "$incoming" | sed '/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*(.*/d ; s/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*\(\/.*\)/\1/ ; s/[[:blank:]]*\(\/.*\)[[:blank:]]*(.*/\1/'`
|
---|
2150 | for f in `echo "$incoming"` ; do
|
---|
2151 | echo "$f `ReadAllLink $f`"
|
---|
2152 | done
|
---|
2153 | read incoming
|
---|
2154 | done
|
---|
2155 | }
|
---|
2156 |
|
---|
2157 |
|
---|
2158 | Prompt() {
|
---|
2159 | echo -en "$1"
|
---|
2160 | read line
|
---|
2161 | }
|
---|
2162 |
|
---|
2163 |
|
---|
2164 | ReadLine() {
|
---|
2165 | local i incoming
|
---|
2166 | read incoming
|
---|
2167 | i=0
|
---|
2168 | while [ "$i" -le "32" ] && [ "$incoming" = "" ] ; do
|
---|
2169 | i=$(($i+1))
|
---|
2170 | read incoming
|
---|
2171 | done
|
---|
2172 | echo "$incoming"
|
---|
2173 | }
|
---|
2174 |
|
---|
2175 |
|
---|
2176 | RejigHyperlinks() {
|
---|
2177 | local minidir_root noof_disks fname path diskno old_pwd awk_loc gawk_loc dir i
|
---|
2178 | minidir_root=$1
|
---|
2179 | noof_disks=$2
|
---|
2180 |
|
---|
2181 | old_pwd=`pwd`
|
---|
2182 | diskno=1
|
---|
2183 | while [ "$diskno" -le "$noof_disks" ] ; do
|
---|
2184 | mkdir -p $minidir_root/$diskno
|
---|
2185 | cd $minidir_root/$diskno
|
---|
2186 | for fname in `find -type d -o -print` ; do
|
---|
2187 | [ -h "$minidir_root/$diskno/$fname" ] && MoveHyperlinkSensibly $fname $minidir_root $diskno $noof_disks
|
---|
2188 | done
|
---|
2189 | diskno=$(($diskno+1))
|
---|
2190 | done
|
---|
2191 |
|
---|
2192 | cd $old_pwd
|
---|
2193 | return
|
---|
2194 | }
|
---|
2195 |
|
---|
2196 |
|
---|
2197 | ReplaceIndividualLine() {
|
---|
2198 | local orig_file new_file lino newstring lines_total lines_remaining
|
---|
2199 |
|
---|
2200 | orig_file=$1.orig
|
---|
2201 | mv -f $1 $orig_file || Die "Cannot move $1 to $orig_file"
|
---|
2202 | new_file=$1
|
---|
2203 | lino=$2
|
---|
2204 | newstring="$3"
|
---|
2205 | if [ "$lino" = "" ] || [ "$lino" -lt "1" ] ; then
|
---|
2206 | echo "Can't find string" >> $LOGFILE
|
---|
2207 | return 1
|
---|
2208 | fi
|
---|
2209 | lines_total=`wc -l $orig_file | gawk '{print $1;}'`
|
---|
2210 | lines_remaining=$(($lines_total-$lino))
|
---|
2211 | head -n$(($lino-1)) $orig_file > $new_file
|
---|
2212 | echo "$newstring" >> $new_file
|
---|
2213 | echo "# The above line was added by Mindi, at the user's instruction" >> $new_file
|
---|
2214 | tail -n$lines_remaining $orig_file >> $new_file
|
---|
2215 | echo "Replace line $lino of $new_file with user-specified line, '$newstring'" >> $LOGFILE
|
---|
2216 | [ -x "$orig_file" ] && chmod +x $new_file
|
---|
2217 | rm -f $orig_file
|
---|
2218 | return 0
|
---|
2219 | }
|
---|
2220 |
|
---|
2221 |
|
---|
2222 | ScanCDandTape() {
|
---|
2223 | local i
|
---|
2224 |
|
---|
2225 | for i in /dev/st0 /dev/ht0 /dev/cdrom /dev/cdrom0 /dev/cdrom 1 ; do
|
---|
2226 | dd if=$i of=/dev/null bs=64k count=1 &> /dev/null
|
---|
2227 | done
|
---|
2228 | }
|
---|
2229 |
|
---|
2230 |
|
---|
2231 | SizeOfPartition() {
|
---|
2232 | local devpath drive res stub
|
---|
2233 | device=$1
|
---|
2234 | if [ "`echo "$device" | grep -F "/dev/md"`" != "" ] ; then
|
---|
2235 | res=`SizeOfRaidPartition $device`
|
---|
2236 | [ "$res" = "" ] && Die "Cannot find $device's size - is your /etc/raidtab sane?"
|
---|
2237 | echo "$res"
|
---|
2238 | return 0
|
---|
2239 | fi
|
---|
2240 | # patch from Bill <bill@iwizard.biz> - 2003/08/25
|
---|
2241 | res=`$FDISK -s $device`
|
---|
2242 | echo "------- $FDISK -l $device log ------------" >> $LOGFILE
|
---|
2243 | cat $FDISKLOG >> $LOGFILE
|
---|
2244 | echo "------- $FDISK log end ------------" >> $LOGFILE
|
---|
2245 | # end patch
|
---|
2246 | [ "$res" = "" ] && res=`df -k -P -x supermount | tr -s '\t' ' ' | grep -F "$device " | cut -d' ' -f2`
|
---|
2247 | [ "$res" = "" ] && res="-1"
|
---|
2248 | echo $res
|
---|
2249 | return 0
|
---|
2250 | }
|
---|
2251 |
|
---|
2252 |
|
---|
2253 | SizeOfRaidPartition() {
|
---|
2254 | local real_dev smallest_size silly tmp
|
---|
2255 |
|
---|
2256 | silly=999999999
|
---|
2257 | smallest_size=$silly
|
---|
2258 |
|
---|
2259 | for real_dev in `GetRaidDevMembers $1` ; do
|
---|
2260 | tmp=`SizeOfPartition $real_dev`
|
---|
2261 | [ "$tmp" -lt "$smallest_size" ] && smallest_size=$tmp
|
---|
2262 | done
|
---|
2263 |
|
---|
2264 | if [ "$smallest_size" = "$silly" ] ; then
|
---|
2265 | echo "-1"
|
---|
2266 | return 1
|
---|
2267 | else
|
---|
2268 | echo "$smallest_size"
|
---|
2269 | return 0
|
---|
2270 | fi
|
---|
2271 | }
|
---|
2272 |
|
---|
2273 |
|
---|
2274 | StripComments()
|
---|
2275 | {
|
---|
2276 | local tempfile
|
---|
2277 |
|
---|
2278 | tempfile=$MONDOTMP/$$.strip.txt
|
---|
2279 | cp -f $1 $tempfile
|
---|
2280 | $AWK '{if (substr($0,0,1)!="#" || substr($0,0,3)=="#!/") {print $0;};}' $tempfile > $1
|
---|
2281 | rm -f $tempfile
|
---|
2282 | echo "Stripped comments from $2" >> $LOGFILE
|
---|
2283 | }
|
---|
2284 |
|
---|
2285 |
|
---|
2286 | SplitDirectoryIntoMinidirs() {
|
---|
2287 | local bigdir minidir_root i noof_disks old_pwd res
|
---|
2288 |
|
---|
2289 | bigdir=$1
|
---|
2290 | minidir_root=$2
|
---|
2291 | rm -Rf $minidir_root/*
|
---|
2292 |
|
---|
2293 | TryToFitDataIntoSeveralDirs $bigdir $minidir_root
|
---|
2294 | noof_disks=$?
|
---|
2295 | if [ "$noof_disks" -eq "0" ] ; then
|
---|
2296 | echo "Failed to fit data into several dirs."
|
---|
2297 | return 0
|
---|
2298 | fi
|
---|
2299 | RejigHyperlinks $minidir_root $noof_disks
|
---|
2300 | rm -Rf $bigdir/*
|
---|
2301 | return $noof_disks
|
---|
2302 | }
|
---|
2303 |
|
---|
2304 |
|
---|
2305 | StripExecutable()
|
---|
2306 | {
|
---|
2307 | local tmpfile
|
---|
2308 |
|
---|
2309 | tmpfile=$MONDOTMP/stripped.$$.dat
|
---|
2310 | [ -d "$1" ] || [ -h "$1" ] && return
|
---|
2311 | cp -f $1 $tmpfile
|
---|
2312 | strip $tmpfile 2> /dev/null
|
---|
2313 | if [ "$?" -eq "0" ] ; then
|
---|
2314 | cp -f $tmpfile $1
|
---|
2315 | echo "Stripped binary $2" >> $LOGFILE
|
---|
2316 | fi
|
---|
2317 | rm -f $tmpfile
|
---|
2318 | }
|
---|
2319 |
|
---|
2320 |
|
---|
2321 | TemporarilyCompressAllFiles() {
|
---|
2322 | local i orig_fname out_fname out_list
|
---|
2323 |
|
---|
2324 | i=0
|
---|
2325 | out_list=$2/compressed/compressed.txt
|
---|
2326 | mkdir -p $2/compressed
|
---|
2327 | > $out_list
|
---|
2328 | for orig_fname in $1 ; do
|
---|
2329 | out_fname=$2/compressed/$orig_fname.gz
|
---|
2330 | mkdir -p $out_fname 2> /dev/null
|
---|
2331 | rmdir $out_fname 2> /dev/null
|
---|
2332 | gzip -c6 $orig_fname > $out_fname 2> /dev/null
|
---|
2333 | i=$(((($i+1))%15))
|
---|
2334 | [ "$i" -eq "0" ] && echo -en "."
|
---|
2335 | du -sk $out_fname >> $out_list
|
---|
2336 | done
|
---|
2337 | }
|
---|
2338 |
|
---|
2339 |
|
---|
2340 | TryToFindKernelPath() {
|
---|
2341 | local fname incoming res fkern_ver we_want_version possible_kernels noof_kernels kernelpath kdate duff_kernels
|
---|
2342 |
|
---|
2343 | we_want_version=`uname -r`
|
---|
2344 | possible_kernels=""
|
---|
2345 | duff_kernels=""
|
---|
2346 |
|
---|
2347 | if [ "$ARCH" = "ia64" ] ; then
|
---|
2348 | root="/boot/efi/efi"
|
---|
2349 | else
|
---|
2350 | root="/"
|
---|
2351 | fi
|
---|
2352 | for fname in `find $root -maxdepth 2 -type f | grep -F lin | grep -Ev '^/proc/|^/net/'` ; do
|
---|
2353 | [ ! -e "$fname" ] && continue
|
---|
2354 | [ "$fname" = "/boot/vmlinuz.shipped" ] && [ -f "/boot/vmlinuz" ] && continue; # ignore SuSE's extra kernel
|
---|
2355 | file $fname | grep -q gzip
|
---|
2356 | if [ "$?" -eq "0" ] ; then
|
---|
2357 | # Used by ia64
|
---|
2358 | fkern_ver=`gzip -cd $fname | strings 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
|
---|
2359 | else
|
---|
2360 | fkern_ver=`strings $fname 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
|
---|
2361 | fi
|
---|
2362 | [ "$fkern_ver" = "" ] && continue
|
---|
2363 | [ "`echo "$fkern_ver" |grep -F "$we_want_version "`" = "" ] && continue
|
---|
2364 | [ -f "$fname" ] || continue
|
---|
2365 | [ -h "$fname" ] && continue
|
---|
2366 | kdate=`uname -v | $AWK '{for(i=1;i<NF;i++){if(index($i,":")){print $i;};};}' | $AWK '{print $NF;}'`
|
---|
2367 | file $fname | grep -q gzip
|
---|
2368 | if [ "$?" -eq "0" ] ; then
|
---|
2369 | # Used by ia64
|
---|
2370 | if [ "`gzip -cd $fname | strings 2> /dev/null | grep -F "$kdate"`" = "" ] ; then
|
---|
2371 | LogIt "Have you recompiled your kernel \"$fname\" w/o rebooting? Naughty but I'll allow it...\n"
|
---|
2372 | duff_kernels="$fname $duff_kernels"
|
---|
2373 | else
|
---|
2374 | [ "`echo "$fname" | grep -F "vmlinux"`" ] && continue
|
---|
2375 | possible_kernels="$fname $possible_kernels"
|
---|
2376 | fi
|
---|
2377 | else
|
---|
2378 | if [ "`strings $fname 2> /dev/null | grep -F "$kdate"`" = "" ] ; then
|
---|
2379 | LogIt "Have you recompiled your kernel \"$fname\" w/o rebooting?\n Naughty but I'll allow it...\n"
|
---|
2380 | duff_kernels="$fname $duff_kernels"
|
---|
2381 | else
|
---|
2382 | [ "`echo "$fname" | grep -F "vmlinux"`" ] && continue
|
---|
2383 | possible_kernels="$fname $possible_kernels"
|
---|
2384 | fi
|
---|
2385 | fi
|
---|
2386 | done
|
---|
2387 | if [ ! "$possible_kernels" ] && uname -a | grep Knoppix > /dev/null ; then
|
---|
2388 | possible_kernels=`find /boot/vmlinuz-2.* | tail -n1`
|
---|
2389 | fi
|
---|
2390 | if [ ! "$possible_kernels" ] ; then
|
---|
2391 | LogIt "No kernel matches exactly. Are there any duff kernels?\n"
|
---|
2392 | possible_kernels="$duff_kernels"
|
---|
2393 | if [ ! "$possible_kernels" ] ; then
|
---|
2394 | LogIt "Sorry, no duff kernels either\n"
|
---|
2395 | else
|
---|
2396 | LogIt "I bet you're running Debian or Gentoo, aren't you?\n"
|
---|
2397 | LogIt "Your kernel doesn't have a sane builddate. Oh well...\n"
|
---|
2398 | fi
|
---|
2399 | fi
|
---|
2400 | possible_kernels=`echo "$possible_kernels" | tr -s ' ' '\n' | sort -u | tr '\n' ' '`
|
---|
2401 | noof_kernels=`CountItemsIn "$possible_kernels"`
|
---|
2402 | if [ "$noof_kernels" -eq "0" ] ; then
|
---|
2403 | LogIt "Could not find your kernel.\n"
|
---|
2404 | if [ -e "/boot/vmlinuz" ] ; then
|
---|
2405 | LogIt "Using /boot/vmlinuz as a last resort.\n"
|
---|
2406 | output=/boot/vmlinuz
|
---|
2407 | else
|
---|
2408 | output=""
|
---|
2409 | fi
|
---|
2410 | elif [ "$noof_kernels" -eq "1" ] ; then
|
---|
2411 | kernelpath=`echo "$possible_kernels" | sed s/' '//`
|
---|
2412 | echo "Your kernel is $kernelpath (v`uname -r`)" >> $LOGFILE
|
---|
2413 | output="$kernelpath"
|
---|
2414 | else
|
---|
2415 | for i in $possible_kernels ; do
|
---|
2416 | if echo $i | grep "`uname -r`" ; then
|
---|
2417 | LogIt "OK, I used my initiative and found that "
|
---|
2418 | LogIt "$i is probably your kernel.\n "
|
---|
2419 | output="$i"
|
---|
2420 | return
|
---|
2421 | fi
|
---|
2422 | done
|
---|
2423 | if echo " $possible_kernels " | grep -F "/boot/vmlinuz " &> /dev/null ; then
|
---|
2424 | output=/boot/vmlinuz
|
---|
2425 | echo "Schlomo, this one's for you." >> $LOGFILE
|
---|
2426 | else
|
---|
2427 | LogIt "Two or more possible kernels found. You may specify any one of them and the \n"
|
---|
2428 | LogIt "boot disks will still work, probably. If one does not work, try another.\n"
|
---|
2429 | LogIt "$possible_kernels\n"
|
---|
2430 | echo ""
|
---|
2431 | fi
|
---|
2432 | fi
|
---|
2433 | echo "$output" | tr -s ' ' '\n' | sort -u | tr '\n' ' '
|
---|
2434 | }
|
---|
2435 |
|
---|
2436 |
|
---|
2437 | TryToFitDataIntoSeveralDirs() {
|
---|
2438 | local bigdir minidir_root noof_disks diskno list_of_files filename old_pwd progress
|
---|
2439 | local i retval noof_disks total_files list_of_devs
|
---|
2440 |
|
---|
2441 | bigdir=$1
|
---|
2442 | minidir_root=$2
|
---|
2443 | BIG_CLUNKY_SIZE_COUNTER=0
|
---|
2444 | retval=0
|
---|
2445 | noof_disks=1
|
---|
2446 |
|
---|
2447 | echo -en "\r \rDividing data into several groups..."
|
---|
2448 | old_pwd=`pwd`
|
---|
2449 | cd $bigdir
|
---|
2450 | list_of_files=`GetFileSizeList . | sort -nr | cut -f2 | grep -Fv "/dev/"`
|
---|
2451 | progress=0
|
---|
2452 | total_files=`CountItemsIn "$list_of_files"`
|
---|
2453 | if [ "`echo "$filename" | grep -x "/dev/.*"`" ] ; then
|
---|
2454 | filesize=1
|
---|
2455 | fi
|
---|
2456 | mkdir -p $minidir_root/$noof_disks
|
---|
2457 | if [ -e "dev" ] ; then
|
---|
2458 | echo "Copying dev/* to $minidir_root/$noof_disks" >> $LOGFILE
|
---|
2459 | cp --parents -pRdf dev $minidir_root/$noof_disks
|
---|
2460 | fi
|
---|
2461 | TemporarilyCompressAllFiles "$list_of_files" $minidir_root
|
---|
2462 | for filename in $list_of_files ; do
|
---|
2463 | AddFileToDir $filename $minidir_root $noof_disks
|
---|
2464 | i=$?
|
---|
2465 | if [ "$i" -gt "$noof_disks" ] ; then
|
---|
2466 | noof_disks=$i
|
---|
2467 | echo -en "\r\t\t\t\t\t\t($noof_disks disks)"
|
---|
2468 | fi
|
---|
2469 | if [ "$i" -eq "0" ] ; then
|
---|
2470 | LogIt "Cannot add file $filename to minidir $minidir_root\n"
|
---|
2471 | retval=$(($retval+1))
|
---|
2472 | fi
|
---|
2473 | progress=$(($progress+1))
|
---|
2474 | echo -en "\r\t\t\t\t\t\t\t\t$(($progress*100/$total_files))% complete\r"
|
---|
2475 | done
|
---|
2476 | cd $old_pwd
|
---|
2477 | echo -en "\rThe files have been subdivided into $noof_disks directories. \r"
|
---|
2478 | rm -Rf $minidir_root/compressed
|
---|
2479 | if [ "$retval" -gt "0" ] ; then
|
---|
2480 | return 0
|
---|
2481 | else
|
---|
2482 | return $noof_disks
|
---|
2483 | fi
|
---|
2484 | }
|
---|
2485 |
|
---|
2486 |
|
---|
2487 | TurnTgzIntoRdz() {
|
---|
2488 | local tgz_dir_fname rdz_fname ramdisksize tempfile mountpoint old_pwd nodes disksize kernelsize maxsize res currsize not_copied j k floppy_modules s w
|
---|
2489 |
|
---|
2490 | tgz_dir_fname=$1
|
---|
2491 | rdz_fname=$2
|
---|
2492 | ramdisksize=$3
|
---|
2493 | disksize=$4
|
---|
2494 | kernelsize=$5
|
---|
2495 | maxsize=$(($disksize-$kernelsize))
|
---|
2496 | maxsize=$(($maxsize*2)); # to allow for compression of 50%
|
---|
2497 | tempfile=$MONDOTMP/temp.rd
|
---|
2498 | mountpoint=$MONDOTMP/mnt1
|
---|
2499 | res=0
|
---|
2500 | echo -en "..."
|
---|
2501 | dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (TurnTgzIntoRdz)"
|
---|
2502 | echo -en "..."
|
---|
2503 | mke2fs -b 1024 -m 1 -i 2048 -F $tempfile >> $LOGFILE 2>> $LOGFILE
|
---|
2504 |
|
---|
2505 | [ "$?" -ne "0" ] && cat $MONDOTMP/mke2fs.log
|
---|
2506 | rm -f $MONDOTMP/mke2fs.log
|
---|
2507 | echo -en "..."
|
---|
2508 | mkdir -p $mountpoint
|
---|
2509 | mount -t ext2 -o loop $tempfile $mountpoint || Die "Cannot loopmount $tempfile to $mountpoint! The reason may be missing support for loopfs or ext2 (or both) in the running kernel."
|
---|
2510 | echo -en "..."
|
---|
2511 | old_pwd=`pwd`
|
---|
2512 | cd $mountpoint
|
---|
2513 | cp -Rdf $tgz_dir_fname/* . 2>> $LOGFILE >> $LOGFILE
|
---|
2514 | tar -zxf symlinks.tgz || Die "Cannot untar symlinks.tgz"
|
---|
2515 | cd dev || Die "Can't cd to dev"
|
---|
2516 | tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz"
|
---|
2517 | rm -f dev-entries.tgz
|
---|
2518 | cd ..
|
---|
2519 |
|
---|
2520 | for w in insmod.static insmod.static.old ; do
|
---|
2521 | s=`which $w 2> /dev/null`
|
---|
2522 | if [ -e "$s" ] ; then
|
---|
2523 | cp --parents -af $s .
|
---|
2524 | fi
|
---|
2525 | done
|
---|
2526 |
|
---|
2527 | mkdir -p tmp
|
---|
2528 | [ -e "/dev/.devfsd" ] && echo "/dev/.devfsd found" > tmp/USE-DEVFS
|
---|
2529 | for w in cdrom floppy groovy-stuff ; do
|
---|
2530 | mkdir -p mnt/$w
|
---|
2531 | done
|
---|
2532 | #if [ "$RUN_AFTER_INITIAL_BOOT_PHASE" ] ; then
|
---|
2533 | #ReplaceIndividualLine sbin/init `grep -n "#WHOLIVESINAPINEAPPLEUNDERTHESEA#" sbin/init | cut -d':' -f1` "$RUN_AFTER_INITIAL_BOOT_PHASE"
|
---|
2534 | #fi
|
---|
2535 | if [ "$RUN_AFTER_BOOT_PHASE_COMPLETE" ] ; then
|
---|
2536 | ReplaceIndividualLine sbin/init `grep -n "#ABSORBENTANDYELLOWANDPOROUSISHE#" sbin/init | cut -d':' -f1` "$RUN_AFTER_BOOT_PHASE_COMPLETE"
|
---|
2537 | fi
|
---|
2538 |
|
---|
2539 | lsmod > tmp/original-lsmod.txt
|
---|
2540 |
|
---|
2541 | cp --parents -Rdf /dev/fd0*[1,2][4,7,8]* . 2> /dev/null
|
---|
2542 | cd $old_pwd
|
---|
2543 | echo -en "..."
|
---|
2544 | MakeModuleLoadingScript $TMPMODPROBE_FLAG $mountpoint/sbin/insert-all-my-modules
|
---|
2545 | echo -en "..."
|
---|
2546 | old_pwd=`pwd`
|
---|
2547 | if [ "$YOUR_KERNEL_SUCKS" ] ; then
|
---|
2548 | cd $MONDOTMP
|
---|
2549 | floppy_modules_path=lib/modules/$FAILSAFE_KVER
|
---|
2550 | else
|
---|
2551 | cd /
|
---|
2552 | ###
|
---|
2553 | ### Sq-Modification... Use kernel name in module path if specified.
|
---|
2554 | ###
|
---|
2555 | #floppy_modules_path=lib/modules/`uname -r`
|
---|
2556 | if [ "${kernelname}" != "" ]
|
---|
2557 | then
|
---|
2558 | floppy_modules_path=lib/modules/${kernelname}
|
---|
2559 | else
|
---|
2560 | floppy_modules_path=lib/modules/`uname -r`
|
---|
2561 | fi
|
---|
2562 | ###
|
---|
2563 | ### Sq-Modification end
|
---|
2564 | ###
|
---|
2565 | fi
|
---|
2566 | floppy_modules=""
|
---|
2567 | if [ "$disksize" -lt "2880" ] ; then
|
---|
2568 | list_of_groovy_mods="$FLOPPY_MODS $IDE_MODS ide-scsi sr_mod cdrom isocd isofs `WhichOfTheseModulesAreLoaded "$SCSI_MODS"`"
|
---|
2569 | else
|
---|
2570 | list_of_groovy_mods="$CDROM_MODS `WhichOfTheseModulesAreLoaded "$SCSI_MODS"`"
|
---|
2571 | fi
|
---|
2572 | if [ -e "$MONDOTMP/NFS-DEV" ] ; then
|
---|
2573 | # For PXE boot
|
---|
2574 | list_of_groovy_mods="$list_of_groovy_mods $NET_MODS"
|
---|
2575 | fi
|
---|
2576 | [ -e "$floppy_modules_path" ] || LogIt "path $floppy_modules_path does not exist.\n If you're not using a modular kernel then you're NUTS.\n"
|
---|
2577 | for i in $list_of_groovy_mods ; do
|
---|
2578 | floppy_modules="$floppy_modules `FindSpecificModuleInPath $floppy_modules_path $i`"
|
---|
2579 | done
|
---|
2580 | for i in $floppy_modules ; do
|
---|
2581 | [ -e "$i" ] && s=`du -sk $i | cut -f1` || s=""
|
---|
2582 | [ "$YOUR_KERNEL_SUCKS" ] && i=$MONDOTMP/$i
|
---|
2583 | echo "Adding $i ($s KB) to the rootfs" >> $LOGFILE
|
---|
2584 | cp -df $i $mountpoint/ || LogIt "Unable to copy $i to $mountpoint\n"
|
---|
2585 | [ "`echo "$i" | grep -F ".gz"`" ] && gunzip -f $mountpoint/`basename $i`
|
---|
2586 | done
|
---|
2587 | if [ ! -e "/sbin/devfsd" ] || [ "$disksize" -lt "2880" ] || [ "$kernelpath" = "$MINDI_LIB/vmlinuz" ] ; then
|
---|
2588 | echo "Deleting devfsd daemon from ramdisk" >> $LOGFILE
|
---|
2589 | [ ! -e "/sbin/devfsd" ] && echo "...because /sbin/devfsd not found" >> $LOGFILE
|
---|
2590 | [ "$disksize" -lt "2880" ] && echo "...because disksize = $disksize" >> $LOGFILE
|
---|
2591 | [ "$kernelpath" = "$MINDI_LIB/vmlinuz" ] && echo "...because kernel is failsafe" >> $LOGFILE
|
---|
2592 | rm -f $mountpoint/sbin/devfsd
|
---|
2593 | fi
|
---|
2594 | cd $old_pwd
|
---|
2595 | [ "$TAPEDEV" ] && echo -en "$TAPEDEV" > $mountpoint/tmp/TAPEDEV-LIVES-HERE
|
---|
2596 | dd if=/dev/zero of=$mountpoint/zero &> /dev/null
|
---|
2597 | rm -f $mountpoint/zero
|
---|
2598 | if [ "`DidMondoCallMe`" ] ; then
|
---|
2599 | MakeMondoConfigFile $mountpoint/tmp/mondo-restore.cfg
|
---|
2600 | cp -f $mountpoint/tmp/mondo-restore.cfg $MONDOTMP &> /dev/null
|
---|
2601 | cp -f $MONDOTMP/mountlist.txt $mountpoint/tmp/ || Die "Cannot copy mountlist to ramdisk"
|
---|
2602 | echo -en "$FILES_IN_FILELIST" > $mountpoint/tmp/FILES-IN-FILELIST
|
---|
2603 | echo -en "$LAST_FILELIST_NUMBER" > $mountpoint/tmp/LAST-FILELIST-NUMBER
|
---|
2604 | [ "$USE_LZO" = "yes" ] && echo -en "Pras 4 Pres 2004" >> $mountpoint/tmp/USING-LZO
|
---|
2605 | [ "$USE_COMP" = "yes" ] && echo -en "Compression, yep" >> $mountpoint/tmp/USING-COMP
|
---|
2606 | [ "$USE_STAR" = "yes" ] && echo -en "Using star. Hooray." >> $mountpoint/tmp/USING-STAR
|
---|
2607 | fi
|
---|
2608 | mkdir -p $mountpoint/tmp
|
---|
2609 | mkdir -p $mountpoint/proc
|
---|
2610 | echo "$disksize" > $mountpoint/tmp/$disksize.siz
|
---|
2611 | find $mountpoint -name CVS -exec rm -rf '{}' \;
|
---|
2612 | umount $mountpoint || Die "Cannot unmount $tempfile"
|
---|
2613 | dd if=$tempfile bs=1k 2> /dev/null | gzip -v9 > $rdz_fname 2> /dev/null
|
---|
2614 | # gzip -9 $tempfile
|
---|
2615 | # mv $tempfile.gz $rdz_fname
|
---|
2616 | if [ "$res" -eq "0" ] ; then
|
---|
2617 | echo -en "..."
|
---|
2618 | else
|
---|
2619 | echo -en "\rMade an rdz WITH ERRORS. \n"
|
---|
2620 | fi
|
---|
2621 | return 0
|
---|
2622 | }
|
---|
2623 |
|
---|
2624 |
|
---|
2625 | WhichOfTheseModulesAreLoaded() {
|
---|
2626 | local modname loaded_modules
|
---|
2627 | loaded_modules=" `lsmod | tr -s ' ' '\t' | cut -f1 | grep -Fvx "Modules" | tr '\n' ' '` "
|
---|
2628 | for modname in $1 ; do
|
---|
2629 | [ "`echo "$loaded_modules" | grep -F " $modname "`" ] && echo "$modname"
|
---|
2630 | done
|
---|
2631 | }
|
---|
2632 |
|
---|
2633 |
|
---|
2634 | ZipMinidirsIntoTarballs() {
|
---|
2635 | local minidir_root tardir noof_disks diskno old_pwd i
|
---|
2636 | minidir_root=$1
|
---|
2637 | tardir=$2
|
---|
2638 | noof_disks=$3
|
---|
2639 |
|
---|
2640 | echo -en "Tarring and zipping the group`PluralOrNot $noof_disks`..."
|
---|
2641 | mkdir -p $tardir
|
---|
2642 | mkdir -p $minidir_root/all
|
---|
2643 | old_pwd=`pwd`
|
---|
2644 | diskno=1
|
---|
2645 | while [ "$diskno" -le "$noof_disks" ] ; do
|
---|
2646 | cd $minidir_root/$diskno || LogIt "Warning - cannot cd to $minidir_root/$diskno\n"
|
---|
2647 | tar -cf - . 2>> $LOGFILE | gzip -9 > $tardir/$diskno.tar.gz || Die "Can't tar/gzip disk#$diskno; please tell Dev Team -exactly- what the errors where."
|
---|
2648 | diskno=$(($diskno+1))
|
---|
2649 | echo -n "..."
|
---|
2650 | cp -pRdf * $minidir_root/all
|
---|
2651 | done
|
---|
2652 | mkdir -p $minidir_root/all/tmp
|
---|
2653 | cd $minidir_root/all
|
---|
2654 | size_of_all_tools=`du -sk . | cut -f1`
|
---|
2655 | if [ "`DidMondoCallMe`" ] ; then
|
---|
2656 | for q in filelist.full.gz biggielist.txt ; do
|
---|
2657 | [ ! -e "$MONDOTMP/$q" ] && Die "Cannot find $MONDOTMP/$q"
|
---|
2658 | cp -pRdf $MONDOTMP/$q tmp/
|
---|
2659 | done
|
---|
2660 | mkdir -p $minidir_root/all/tmp
|
---|
2661 | echo -en "$FILES_IN_FILELIST" > $minidir_root/all/tmp/FILES-IN-FILELIST 2> /dev/null
|
---|
2662 | echo -en "$LAST_FILELIST_NUMBER" > $minidir_root/all/tmp/LAST-FILELIST-NUMBER 2> /dev/null
|
---|
2663 | fi
|
---|
2664 | tar -b 4096 -cf - * 2> /dev/null | gzip -9 > $tardir/all.tar.gz
|
---|
2665 | dd if=/dev/zero bs=1k count=64 >> $imagesdir/all.tar.gz 2> /dev/null
|
---|
2666 | [ "`du -sm $imagesdir/all.tar.gz | cut -f1`" -ge "30" ] && Die "You have too many tools in your shed"
|
---|
2667 | cd $old_pwd
|
---|
2668 | rm -Rf $minidir_root
|
---|
2669 | echo -e "$DONE"
|
---|
2670 | }
|
---|
2671 |
|
---|
2672 |
|
---|
2673 | ##############################################################################
|
---|
2674 | #----------------------------------- main -----------------------------------#
|
---|
2675 | ##############################################################################
|
---|
2676 |
|
---|
2677 |
|
---|
2678 | if [ "$1" = "-printvar" ] ; then
|
---|
2679 | shift
|
---|
2680 | if [ _"$1" != _"" ] ; then
|
---|
2681 | set | egrep "^$1" | cut -d= -f2
|
---|
2682 | fi
|
---|
2683 | exit 0
|
---|
2684 | fi
|
---|
2685 |
|
---|
2686 | > $LOGFILE
|
---|
2687 | echo "mindi v$MINDI_VERSION" >> $LOGFILE
|
---|
2688 | echo "$ARCH architecture detected" >> $LOGFILE
|
---|
2689 | echo "mindi called with the following arguments:" >> $LOGFILE
|
---|
2690 | echo "$@" >> $LOGFILE
|
---|
2691 | echo "Start date : `date`" >> $LOGFILE
|
---|
2692 |
|
---|
2693 | if [ -e "/etc/conf.modules" ] && [ ! -e "/etc/modules.conf" ] ; then
|
---|
2694 | LogIt "Warning - Ancient distro detected.\n" 1
|
---|
2695 | ln -sf /etc/conf.modules /etc/modules.conf
|
---|
2696 | fi
|
---|
2697 | [ -e "/sbin/mkdosfs" ] && [ ! -e "/sbin/mkfs.vfat" ] && ln -sf /sbin/mkdosfs /sbin/mkfs.vfat
|
---|
2698 |
|
---|
2699 | FindHomeOfMindiAndMondo
|
---|
2700 | trap AbortHere SIGTERM SIGHUP SIGQUIT SIGKILL SIGABRT SIGINT
|
---|
2701 | AbortIfYourDistroIsAPieceOfStercus
|
---|
2702 | [ "`uname -r | grep "2.4.[0-6]" | grep -v "2.4.[0-9][0-9]"`" != "" ] && echo "WARNING! Your kernel may have buggy loopfs code. Consider upgrading to 2.4.7"
|
---|
2703 | # If we have a 2.6 kernel, the system uses module-init-tools which means that we
|
---|
2704 | # may have the modprobe configuration spread out across multiple files in
|
---|
2705 | # directory /etc/modprobe.d. If this is the case we concatenate these files into
|
---|
2706 | # a temporary file for further processing. Otherwise we continue in the standard
|
---|
2707 | # way. Note further that in case /etc/modprobe.d exists, we use it and ignore
|
---|
2708 | # /etc/modprobe.conf which is exactly what module-init-tools does. The temporary
|
---|
2709 | # modprobe.conf file is created in MakeModuleLoadingScript. AL041128.
|
---|
2710 | if [ -d "/etc/modprobe.d" ] && [ `uname -r | cut -c1-3` == "2.6" ] ; then
|
---|
2711 | TMPMODPROBE_FLAG="Y"
|
---|
2712 | else
|
---|
2713 | TMPMODPROBE_FLAG="N"
|
---|
2714 | [ -e "/etc/modprobe.conf" ] && [ ! -e "/etc/modules.conf" ] && ln -sf /etc/modprobe.conf /etc/modules.conf
|
---|
2715 | [ ! -e "/etc/modules.conf" ] && Die "/etc/modules.conf not found; you may have to create a softlink from /etc/conf.modules to /etc/modules.conf; of course, all good distros use modules.conf anyway..."
|
---|
2716 | fi
|
---|
2717 | FixPathIfBroken
|
---|
2718 | [ -f "$MINDI_LIB/vmlinuz" ] && FAILSAFE_KVER=`strings $MINDI_LIB/vmlinuz 2> /dev/null | grep -E "2\.[46]" | cut -d' ' -f1`
|
---|
2719 | AbortIfMkfsVfatMissing
|
---|
2720 | ### BERLIOS
|
---|
2721 | ### Fix as it's not mandatory on ia64
|
---|
2722 | if [ "$ARCH" = "ia64" ] ; then
|
---|
2723 | FindELiloBinary
|
---|
2724 | else
|
---|
2725 | FindIsolinuxBinary
|
---|
2726 | FindLiloBinary
|
---|
2727 | fi
|
---|
2728 | # BERLIOS: Remove as too dangerous and now useless
|
---|
2729 | #grep -F " $MONDOTMP " /proc/mounts | grep -F tmpfs > /dev/null 2> /dev/null && MONDOTMP=/home/tmpmondo && mkdir -p $MONDOTMP && LogIt "Changing MONDOTMP to $MONDOTMP because you're using tmpfs for /tmp\n" ; # tmpfs doesn't like Mindi and /tmp, for some reason
|
---|
2730 | trap "Aborted" SIGTERM
|
---|
2731 | DONE="\r\t\t\t\t\t\t\t\tDone. "
|
---|
2732 | CHOPSIZE=240
|
---|
2733 | BIGNO=0
|
---|
2734 | MAX_COMPRESSED_SIZE=1300
|
---|
2735 | kernelpath=""
|
---|
2736 | MONDO_ROOT=$TMPMONDO/mondo-root
|
---|
2737 | mkdir -p $MONDO_ROOT
|
---|
2738 |
|
---|
2739 | if [ -d "/proc/lvm" ]; then
|
---|
2740 | # LVM v1
|
---|
2741 | LVMCMD=""
|
---|
2742 | LVM="v1"
|
---|
2743 | elif [ -d "/dev/mapper" ]; then
|
---|
2744 | # LVM v2
|
---|
2745 | LVMCMD="lvm"
|
---|
2746 | LVM="v2"
|
---|
2747 | else
|
---|
2748 | LVM="false"
|
---|
2749 | fi
|
---|
2750 |
|
---|
2751 | if [ "$#" -ge "2" ] ; then
|
---|
2752 | if [ "$1" = "--max-compressed-size" ] ; then
|
---|
2753 | MAX_COMPRESSED_SIZE=$2
|
---|
2754 | shift; shift
|
---|
2755 | fi
|
---|
2756 | fi
|
---|
2757 |
|
---|
2758 | FLOPPY_WAS_MOUNTED=""
|
---|
2759 | for mtpt in /media/floppy /mnt/floppy /floppy ; do
|
---|
2760 | if mount | grep -w $mtpt &> /dev/null ; then
|
---|
2761 | FLOPPY_WAS_MOUNTED="$FLOPPY_WAS_MOUNTED $mtpt"
|
---|
2762 | umount $mtpt
|
---|
2763 | fi
|
---|
2764 | done
|
---|
2765 |
|
---|
2766 | if [ "$#" -ne "0" ] ; then
|
---|
2767 | if [ "$1" = "--findkernel" ] ; then
|
---|
2768 | res=`TryToFindKernelPath`
|
---|
2769 | if [ "$res" = "" ] ; then
|
---|
2770 | MindiExit -1
|
---|
2771 | else
|
---|
2772 | echo "$res"
|
---|
2773 | MindiExit 0
|
---|
2774 | fi
|
---|
2775 | elif [ "$1" = "--makemountlist" ] ; then
|
---|
2776 | [ ! "$2" ] && Die "Please specify the output file"
|
---|
2777 | MakeMountlist $2
|
---|
2778 | MindiExit $?
|
---|
2779 | elif [ "$1" = "-V" ] || [ "$1" = "-v" ] || [ "$1" = "--version" ] || [ "$1" = "-version" ] ; then
|
---|
2780 | echo "Mindi v$MINDI_VERSION"
|
---|
2781 | MindiExit 0
|
---|
2782 | elif [ "$#" -ge "9" ] && [ "$1" = "--custom" ] ; then
|
---|
2783 | MONDOTMP=$2
|
---|
2784 | CACHE_LOC=$3
|
---|
2785 | if [ _"$CACHE_LOC" != _"" ]; then
|
---|
2786 | mkdir -p $CACHE_LOC
|
---|
2787 | fi
|
---|
2788 | kernelpath=$4; [ "$kernelpath" = "(null)" ] && kernelpath=""
|
---|
2789 | ###
|
---|
2790 | ### Sq-Modification...
|
---|
2791 | ### Attempt to locate kernel specific module path
|
---|
2792 | ### if module path is found then use it other wise use uname -r to set it...
|
---|
2793 | ###
|
---|
2794 | kernelname=`echo $kernelpath | cut -d'-' -f2-`
|
---|
2795 | LogIt "kernelname = $kernelname\n"
|
---|
2796 | LogIt "kernelpath = $kernelpath\n"
|
---|
2797 | if [ ! -d "/lib/modules/$kernelname" ] && [ "$kernelpath" != "FAILSAFE" ]
|
---|
2798 | then
|
---|
2799 | LogIt "Module path for ${kernelpath} not found...\n"
|
---|
2800 | LogIt "using running kernel\'s modules.\n"
|
---|
2801 | kernelname=`uname -r`
|
---|
2802 | else
|
---|
2803 | LogIt "Using modules for kernel: ${kernelname}\n"
|
---|
2804 | fi
|
---|
2805 | ###
|
---|
2806 | ### end of Sq-Modification
|
---|
2807 | ###
|
---|
2808 | TAPEDEV=$5
|
---|
2809 | TAPESIZE=$6
|
---|
2810 | FILES_IN_FILELIST=$7
|
---|
2811 | USE_LZO=$8
|
---|
2812 | CDRECOVERY=$9
|
---|
2813 | if [ "${10}" = "(null)" ] || [ "${10}" = "" ] ; then
|
---|
2814 | IMAGE_DEVS=""
|
---|
2815 | else
|
---|
2816 | IMAGE_DEVS="`echo "${10}" | tr '|' ' '`"
|
---|
2817 | fi
|
---|
2818 | if [ "${11}" ] ; then
|
---|
2819 | LILO_OPTIONS=""
|
---|
2820 | # LogIt "LILO will use conservative settings, to be compatible with older BIOSes."
|
---|
2821 | fi
|
---|
2822 | LAST_FILELIST_NUMBER=${12}
|
---|
2823 | ESTIMATED_TOTAL_NOOF_SLICES=${13}
|
---|
2824 | EXCLUDE_DEVS="${14}"
|
---|
2825 | USE_COMP="${15}"
|
---|
2826 | USE_LILO="${16}"
|
---|
2827 | USE_STAR="${17}"
|
---|
2828 | INTERNAL_TAPE_BLOCK_SIZE="${18}"
|
---|
2829 | DIFFERENTIAL="${19}"
|
---|
2830 | NOT_BOOT="${20}"
|
---|
2831 | [ "$USE_COMP" = "" ] && USE_COMP=yes
|
---|
2832 | [ "$NOT_BOOT" = "" ] && NOT_BOOT=no
|
---|
2833 | [ "$TAPEDEV" ] && LogIt "This is a tape-based backup. Fine.\n"
|
---|
2834 | [ "$kernelpath" = "" ] && kernelpath=`TryToFindKernelPath`
|
---|
2835 | kernelname=`echo $kernelpath | cut -d'-' -f2-`
|
---|
2836 | if [ ! -d "/lib/modules/$kernelname" ] && [ "$kernelpath" != "FAILSAFE" ]
|
---|
2837 | then
|
---|
2838 | LogIt "Module path for ${kernelpath} not found...\n"
|
---|
2839 | LogIt "using running kernel\'s modules.\n"
|
---|
2840 | kernelname=`uname -r`
|
---|
2841 | else
|
---|
2842 | LogIt "Using modules for kernel: ${kernelname}\n"
|
---|
2843 | fi
|
---|
2844 | [ "$CDRECOVERY" = "yes" ] && [ "$TAPEDEV" != "" ] && Die "Sorry, you can't use --cd-recovery and --write-tapes at the same time"
|
---|
2845 | MONDO_ROOT=`echo $CACHEDIR | sed 's/\(.*\)\/.*/\1/'`
|
---|
2846 | if [ _"$MONDO_ROOT" != _"" ]; then
|
---|
2847 | mkdir -p $MONDO_ROOT
|
---|
2848 | else
|
---|
2849 | Die "MONDO_ROOT is undefined"
|
---|
2850 | fi
|
---|
2851 | else
|
---|
2852 | echo "Syntax: mindi (--custom ....)" >> /dev/stderr
|
---|
2853 | MindiExit -1
|
---|
2854 | fi
|
---|
2855 | fi
|
---|
2856 | #ScanCDandTape
|
---|
2857 | [ "$CDRECOVERY" = "yes" ] || CDRECOVERY=no
|
---|
2858 | if [ "$CDRECOVERY" = "yes" ] ; then
|
---|
2859 | iso_cfg_file=$MINDI_LIB/isolinux-H.cfg
|
---|
2860 | sys_cfg_file=$MINDI_LIB/syslinux-H.cfg
|
---|
2861 | else
|
---|
2862 | iso_cfg_file=$MINDI_LIB/isolinux.cfg
|
---|
2863 | sys_cfg_file=$MINDI_LIB/syslinux.cfg
|
---|
2864 | fi
|
---|
2865 |
|
---|
2866 |
|
---|
2867 | [ -e "$iso_cfg_file" ] || Die "Cannot find $iso_cfg_file"
|
---|
2868 | if [ ! "`DidMondoCallMe`" ] ; then
|
---|
2869 | LogIt "Mindi Linux mini-distro generator v$MINDI_VERSION\n"
|
---|
2870 | LogIt "Latest Mindi is available from http://www.mondorescue.org\n"
|
---|
2871 | LogIt "BusyBox sources are available from http://www.busybox.net\n"
|
---|
2872 | LogIt "------------------------------------------------------------------------------"
|
---|
2873 | else
|
---|
2874 | echo "You are using Mindi-Linux v$MINDI_VERSION to make boot+data disks" >> /var/log/mondo-archive.log
|
---|
2875 | fi
|
---|
2876 |
|
---|
2877 | # for Mandrake 9.2, which comes with two aes.o.gz modules :-/
|
---|
2878 | insmod /lib/modules/`uname -r`/*/*/misc/aes.*o.gz >> $LOGFILE 2>> $LOGFILE
|
---|
2879 | for i in loop cdrom ide-cd isofs linear raid0 raid1 raid5 ; do
|
---|
2880 | insmod $i >> $LOGFILE 2>> $LOGFILE
|
---|
2881 | done
|
---|
2882 |
|
---|
2883 | KERN_DISK_MADE=""
|
---|
2884 |
|
---|
2885 | echo "DIFFERENTIAL = $DIFFERENTIAL" >> $LOGFILE
|
---|
2886 | echo "INTERNAL TAPE BLOCK SIZE = $INTERNAL_TAPE_BLOCK_SIZE" >> $LOGFILE
|
---|
2887 | echo "NOT_BOOT = '$NOT_BOOT'" >> $LOGFILE
|
---|
2888 | if [ "$NOT_BOOT" != "" ] && [ "$NOT_BOOT" != "0" ] && [ "$NOT_BOOT" != "no" ] ; then
|
---|
2889 | LogIt "Just creating mondo-restore.cfg and a small all.tar.gz for Mondo. Nothing else.\n"
|
---|
2890 | MakeMondoConfigFile $MONDOTMP/mondo-restore.cfg
|
---|
2891 | MakeMountlist $MONDOTMP/mountlist.txt
|
---|
2892 | mkdir -p $MONDOTMP/small-all/tmp
|
---|
2893 | cd $MONDOTMP/small-all
|
---|
2894 | cp -f $MONDOTMP/{mountlist.txt,mondo-restore.cfg,filelist.full.gz,biggielist.txt} tmp || Die "Cannot copy small all.tar.gz"
|
---|
2895 | tar -cv tmp | gzip -9 > $MONDOTMP/all.tar.gz || Die "Cannot make small all.tar.gz"
|
---|
2896 | sleep 2
|
---|
2897 | LogIt "Done. Exiting.\n"
|
---|
2898 | MindiExit 0
|
---|
2899 | fi
|
---|
2900 |
|
---|
2901 | if [ "$kernelpath" = "" ] ; then
|
---|
2902 | [ "`DidMondoCallMe`" ] && Die "Please use -k <path> to specify kernel."
|
---|
2903 | if [ $USE_OWN_KERNEL != "yes" ]; then
|
---|
2904 | echo -en "Do you want to use your own kernel to build the boot disk (y/n) ?"
|
---|
2905 | read ch
|
---|
2906 | if [ "$ch" != "n" ] && [ "$ch" != "N" ] ; then
|
---|
2907 | USE_OWN_KERNEL="yes"
|
---|
2908 | fi
|
---|
2909 | fi
|
---|
2910 | if [ "$USE_OWN_KERNEL" = "yes" ]; then
|
---|
2911 | YOUR_KERNEL_SUCKS=""
|
---|
2912 | kernelpath=`TryToFindKernelPath`
|
---|
2913 | if [ "$kernelpath" = "" ] ; then
|
---|
2914 | echo -n "Please enter kernel path : "
|
---|
2915 | read kernelpath
|
---|
2916 | fi
|
---|
2917 | else
|
---|
2918 | YOUR_KERNEL_SUCKS="That's why you're using mine, dude. :-)"
|
---|
2919 | fi
|
---|
2920 | fi
|
---|
2921 | if [ ! "`DidMondoCallMe`" ] ; then
|
---|
2922 | echo -en "Would you like to use LILO (instead of syslinux)\nfor your boot CD/floppies (y/n) ?"
|
---|
2923 | read ch
|
---|
2924 | if [ "$ch" != "n" ] && [ "$ch" != "N" ] ; then
|
---|
2925 | USE_LILO=yes
|
---|
2926 | else
|
---|
2927 | USE_LILO=no
|
---|
2928 | fi
|
---|
2929 | fi
|
---|
2930 | if [ "$YOUR_KERNEL_SUCKS" != "" ] || [ "$kernelpath" = "" ] || [ "$kernelpath" = "SUCKS" ] || [ "$kernelpath" = "FAILSAFE" ] ; then
|
---|
2931 | kernelpath=$MINDI_LIB/vmlinuz
|
---|
2932 | LogIt "I shall include Mindi's failsafe kernel, not your kernel, in the boot disks.\n"
|
---|
2933 | LogIt "However, you are still running your kernel. If Mindi fails to create your\n"
|
---|
2934 | LogIt "disks then it may still be a result of a problem with your kernel.\n"
|
---|
2935 | pwd=`pwd`
|
---|
2936 | cd $MONDOTMP
|
---|
2937 | bzip2 -dc $MINDI_LIB/lib.tar.bz2 | tar -x || Die "Cannot unzip lib.tar.bz2"
|
---|
2938 | cd $pwd
|
---|
2939 | YOUR_KERNEL_SUCKS="Your kernel sucks"
|
---|
2940 | fi
|
---|
2941 | echo -e "Mindi's temp dir = $MONDOTMP \nMindi's output dir=$CACHE_LOC" >> $LOGFILE
|
---|
2942 | [ "$(($RANDOM%64))" -eq "0" ] && LogIt "Dude, I've looked inside your computer and it's really dusty...\n"
|
---|
2943 |
|
---|
2944 | [ "$YOUR_KERNEL_SUCKS" ] && [ ! "$FAILSAFE_KVER" ] && Die "Please install mindi-kernel package. You need it. Go to http://www.mondorescue.org and download it, then install it."
|
---|
2945 |
|
---|
2946 | rm -f $CACHEDIR/{*img,*gz,*iso}
|
---|
2947 |
|
---|
2948 | PrepareDataDiskImages $CACHEDIR
|
---|
2949 | noof_disks=$?
|
---|
2950 | [ "$noof_disks" -eq "0" ] && Die "Too much stuff!"
|
---|
2951 | MakeMountlist $TMP_ROOT/mountlist.txt
|
---|
2952 | mkdir -p $minidir_root/$noof_disks/tmp
|
---|
2953 | cp -f $TMP_ROOT/mountlist.txt $minidir_root/$noof_disks/tmp/mountlist.txt || Die "Cannot copy mountlist.txt from $TMP_ROOT to data disk"
|
---|
2954 | cp -f $TMP_ROOT/mountlist.txt $CACHEDIR
|
---|
2955 | [ "`DidMondoCallMe`" ] && cp -f $minidir_root/$noof_disks/tmp/mountlist.txt $MONDO_TMP/.
|
---|
2956 | [ -d "/proc/lvm" ] && $MINDI_SBIN/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
|
---|
2957 | [ -d "/dev/mapper" ] && $MINDI_SBIN/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
|
---|
2958 | cat $minidir_root/$noof_disks/tmp/mountlist.txt >> $LOGFILE
|
---|
2959 | ZipMinidirsIntoTarballs $minidir_root $tardir $noof_disks
|
---|
2960 | CreateDataDiskImagesFromTarballs $tardir $CACHEDIR $noof_disks
|
---|
2961 | FRIENDLY_OUTSTRING="Boot and data disk images were created."
|
---|
2962 | # One 1.72MB boot disk, one 2.88MB boot disk and $noof_disks data disk images
|
---|
2963 | rmdir $tardir $bigdir
|
---|
2964 | rm -f $needlist
|
---|
2965 | #return $noof_disks
|
---|
2966 |
|
---|
2967 | ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE))
|
---|
2968 | rds=$(($ramdisk_size-$((ramdisk_size%4096))))
|
---|
2969 | ramdisk_size=$rds
|
---|
2970 |
|
---|
2971 | echo "Ramdisk will be $ramdisk_size KB" >> $LOGFILE
|
---|
2972 | if [ "$USE_LILO" = "yes" ] ; then
|
---|
2973 | if [ "$ARCH" = "ia64" ] ; then
|
---|
2974 | PrepareBootDiskImage_LILO $CACHE_LOC $IA64_BOOT_SIZE $kernelpath $ramdisk_size || Die "Failed to create ia64 floppy disk image."
|
---|
2975 | else
|
---|
2976 | if ! PrepareBootDiskImage_LILO $CACHE_LOC 1722 $kernelpath $ramdisk_size ; then
|
---|
2977 | LogIt "Warning - failed to create 1.72MB boot image. Please reduce your kernel's size\n"
|
---|
2978 | LogIt "if you want to make a 1.72MB floppy disk.\n"
|
---|
2979 | fi
|
---|
2980 | if ! PrepareBootDiskImage_LILO $CACHE_LOC 2880 $kernelpath $ramdisk_size ; then
|
---|
2981 | LogIt "Warning - failed to create 2.88MB floppy disk image.\n"
|
---|
2982 | LogIt "Please reduce your kernel's size\n"
|
---|
2983 | LogIt "if you want to make a 2.88MB floppy disk.\n"
|
---|
2984 | PrepareBootDiskImage_LILO $CACHE_LOC 5760 $kernelpath $ramdisk_size || Die "Failed to create 2.88MB floppy disk image."
|
---|
2985 | fi
|
---|
2986 | fi
|
---|
2987 | else
|
---|
2988 | if ! PrepareBootDiskImage_SYSLINUX $CACHE_LOC 1722 $kernelpath $ramdisk_size ; then
|
---|
2989 | LogIt "Warning - failed to create 1.72MB boot image. Please reduce your kernel's size\n"
|
---|
2990 | LogIt "if you want to make a 1.72MB floppy disk.\n"
|
---|
2991 | if ! PrepareBootDiskImage_SYSLINUX $CACHE_LOC 2880 $kernelpath $ramdisk_size ; then
|
---|
2992 | LogIt "Warning - failed to create 2.88MB floppy disk image.\n"
|
---|
2993 | LogIt "Please reduce your kernel's size\n"
|
---|
2994 | LogIt "if you want to make a 2.88MB floppy disk.\n"
|
---|
2995 | PrepareBootDiskImage_SYSLINUX $CACHE_LOC 5760 $kernelpath $ramdisk_size || Die "Failed to create 5.76MB floppy disk image."
|
---|
2996 | fi
|
---|
2997 | fi
|
---|
2998 | fi
|
---|
2999 |
|
---|
3000 | [ -e "$MINDI_LIB/memtest.img" ] && BOOT_MEDIA_MESSAGE="$BOOT_MEDIA_MESSAGE\n\
|
---|
3001 | ...Or type 'memtest' to test your PC's RAM thoroughly.\n"
|
---|
3002 |
|
---|
3003 | if [ ! "`DidMondoCallMe`" ] ; then
|
---|
3004 | ListImagesForUser $CACHE_LOC
|
---|
3005 | boot_dev=/dev/fd0u1722
|
---|
3006 | [ ! -e "$boot_dev" ] && mknod $boot_dev b 2 60
|
---|
3007 | [ ! -e "$boot_dev" ] && boot_dev=/dev/fd0H1722
|
---|
3008 | [ ! -e "$boot_dev" ] && Die "Will you PLEASE tell your distribution maker to create the 1.72MB devices in /dev?"
|
---|
3009 | if [ "$PROMPT_WRITE_BOOT_FLOPPIES" = "yes" ]; then
|
---|
3010 | OfferToCopyImagesToDisks $CACHEDIR $boot_dev $FDDEVICE
|
---|
3011 | fi
|
---|
3012 | OfferToMakeBootableISO $CACHE_LOC
|
---|
3013 | LogIt "Finished.\n"
|
---|
3014 | elif [ "$TAPEDEV" ] ; then
|
---|
3015 | rm -f $CACHEDIR/{*img,*gz,*iso}
|
---|
3016 | OfferToMakeBootableISO $CACHE_LOC
|
---|
3017 | if [ -e "$CACHE_LOC/all.tar.gz" ] ; then
|
---|
3018 | cp -f $CACHE_LOC/all.tar.gz $MONDOTMP/
|
---|
3019 | else
|
---|
3020 | Die "Cannot find all.tar.gz, to be written to tape"
|
---|
3021 | fi
|
---|
3022 | else
|
---|
3023 | OfferToMakeBootableISO $CACHE_LOC
|
---|
3024 | fi
|
---|
3025 | # cleanup
|
---|
3026 | rm -Rf $MONDOTMP $FDISKLOG
|
---|
3027 | LogIt "$FRIENDLY_OUTSTRING\n"
|
---|
3028 | for mtpt in $FLOPPY_WAS_MOUNTED ; do
|
---|
3029 | mount $mtpt
|
---|
3030 | done
|
---|
3031 | MindiExit 0
|
---|