source: branches/stable/mindi/rootfs/sbin/init @ 1842

Last change on this file since 1842 was 1842, checked in by bruno, 12 years ago
  • Fix lack of /etc/raidtab at restore rime in the right place
  • Adds support for nls_utf8 and pata_serverworks Patches from Dirk Husung (husung_at_tu-harburg.de)
  • Add efibootmgr to deplist.txt in order to be able to modify EFI menu at restore time on ia64
  • Usage of the new testver param of pb 0.8.12 to deliver 2.2.5 packages in a test dir.
  • Update pbcl files for upcoming delivery of 2.2.5
  • Fix an issue on parted output (K instead of KB) in parted2fdisk at restore time
  • Adds support for alb/aft types of bonding on Intel cards (Mark Pinkerton <Mark.Pinkerton_at_emageon.com>)
  • Escape variables in a perl script like mindi-bkphw
  • Better Proliant support at restore time now.
  • Fix a label bug where the variable label should also be re-initialized at each loop
  • start-nfs should NOT do exit => kernel panix as init exits
  • some other fixes for init on denymods
  • Adds boot options denymods (for udev) and forcemods (if not udev)
  • kqemu is denied. Probably should also be done for kvm stuff
  • Fix again the bug on modules link at root of the initrd. Hopefully for good.
  • Wait more around the USB CD emulated by iLO as it takes up to 5 seconds to come up
  • Attempt to fix udev support for RHEL 5.1
  • Better support for automatic iLO Virtual Media with udev
  • Some VMWare support improvements (however, it seems that VMWare support won't be possible anytime soon)
  • during init at restore time, copy all static evices availble for udev, as some distro implementation are no

t yet supported correctly for udev. Not very elegant, but should solve our current issues

  • Fedora 8 now supported as a build target for pb
  • svn.log removed.
  • dependencies reviewd for rhel_3
  • Attempt to fix the lack of modules loaded at restore time - especially fs device drivers
  • removes bkphw dir before potential creation
  • render mount command more vebose at restore time
  • Should fix #217
  • Increase BOOT_SIZE and EXTRA_SIZE to support features such as HW recovery
  • Handles udev.files files which could be symlinks
  • Improve udev support for distro with compressed modules (mdv e.g.)
  • Fix modules.dep copy
  • /sbin/pam_console_apply is needed by mdv udev conf
  • Adds support for nohw boot option to avoid re-setuping the HW conf
  • Improved support for Proliant on cpqacuxe
  • RstHW should be called after driver initialization
  • For debian/ubuntu mindi dpends on mindi-busybox
  • Update mindi-busybox pbcl for correct debian changelog generation, and up2date infos
  • Should fix #215
  • Fix #214 (Thanks to xdelaruelle)
  • Fix again svn.log not used anymore with new pb version
  • Adaptation of build process to upcoming 0.8.12 version of pb
  • Remove MONOTONIC clock to continue to support 2.4 kernels (RHEL 3 e.g. or ESX)
  • Attempt to solve ia64 BMC access through the serial port
  • parted2fdisk binary no more generated
  • do not require perl modules (strict.pm) at restore time
  • try to avoid modprobe messages at restore time
  • on ia64 now use the perl script parted2fdisk at retore time also
  • Also modprobe modules for udev after decompressing the additional ones
  • replace gzip -v9 by gzip -c9. Fix a bug at least on ia64
  • For all modules supported, create symlinks under the mountpoint and extract dev files as some are not automat ically created at the moment
  • Support /vmfs/volumes for ESX
  • Finally do not use vdf for ESX. Only creates issues.
  • Avoids continuing hw support if no product name found
  • Improves ia64 support for bootable image build
  • Fix a potential problem with ramdisk_blocksize param
  • MAKEDEV should also be included in deplist.txt
  • More fixes for udev support for Debian
  • Do not mount /boot if it's already mounted - avoids ESX hang
  • Fix NICs renumbering on Debian at least
  • Udev startup improvement to support iLO + NFS so modprobing all modules seems required as of now
  • Update to version 1.7.3 of busybox for pb
  • Load USB earlier in order to support KBD such as with iLO
  • Do busybox ldd first in order to create a potential /lib64 link correctly and then use it later in the image
  • Use variable DF in mindi to be able to support the ESX vdf
  • Fix mindi for Debian x86_64 where /lib64 is a link
  • Fix issue at restore time for ext2fs params not reused (Fix from Klaus Ade Johnstad <klaus_at_skolelinux.no>)
  • Do not copy udev files if they do not exist In udev case do not insert modules at all (udev should do it alone) May avoid the issue with rhel4.5 kernel ? To be tested
  • Update dependencies for rpm base build as well
  • And also perl is a debian/ubuntu dep
  • Better debian/ubuntu dependecies requirements (mtools)
  • Fix modes on mindi-bkphw (Thanks Phil Walker phil.walker_at_hp.com)
  • Complete rev [1771] for upper case RESTORE cli with syslinux as well
  • Update mindi-busybox to 1.7.3
  • Use RESTORE consistently across mondo to restore without interaction (report from Takeshi Shoji t.shoji_at_tripodw.jp)

(merge -r1769:1841 $SVN_M/branches/2.2.5)

  • Property svn:keywords set to Id
File size: 20.9 KB
RevLine 
[1]1#!/bin/sh
2#
[736]3# $Id: init 1842 2007-12-15 01:24:34Z bruno $
[1]4#
[736]5# init script launched during the restore process
[1]6#------------------------------------------------------------
7
8
9CaughtSoftReset() {
[1770]10    trap SIGTERM
11    reboot
[1]12}
13
14
15ConfigureLoggingDaemons() {
[1770]16    echo -en "Running klogd..."
17    klogd -c 2 > /dev/null 2> /dev/null
18    echo -en "Done.\nRunning syslogd..."
19    syslogd > /dev/null 2> /dev/null
20    echo "Done."
21    LogIt "klogd and syslogd have been started."
[1]22}
23
24
25
26CopyBootDevEntry() {
[1770]27    local outfile devfile
28    devfile=/dev/boot_device
29    outfile=`cat /BOOTLOADER.DEVICE 2> /dev/null`
30    [ ! "$outfile" ] && return 0
31    echo -en "Copying boot device to $outfile..."
32    if [ -e "$outfile" ] ; then
[1]33    echo "OK."
34    return 0
[1770]35    fi
36    mkdir -p $outfile
37    rmdir $outfile
38    cp -pRdf $devfile $outfile
39    if [ "$?" -ne "0" ] ; then
[1]40    echo "Failed."
41    return 1
[1770]42    else
[1]43    echo "OK."
44    return 0
[1770]45    fi
[1]46}
47
48
49
50Die() {
[1770]51    LogIt "Fatal error! $1" 1
52    exit 1
[1]53}
54
55
56
57ExtractDevTarballs() {
[1770]58    cd /
59    for fname in ataraid.tgz ida.tgz i2o.tgz rd.tgz raw.tgz cciss.tgz nst.tgz dm.tgz vc.tgz ; do
60        if [ ! -e "/$fname" ] ; then
61            LogIt "/$fname not found; cannot extract to /." 1
62        else
63            echo -en "\rExtracting /$fname...     "
64            tar -zxf /$fname || LogIt "Error occurred while extracting /$fname"
65        fi
66    done
67    echo -en "\r"
68    LogIt "Extracted additional /dev entries OK.     " 1
[1]69}
70
71
72
73LaunchTerminals() {
[1770]74    openvt 2 /bin/sh
75    openvt 3 /bin/sh
76    openvt 4 /bin/sh
77    openvt 5 /bin/sh
78    openvt 6 /bin/sh
79    openvt 7 /bin/sh /sbin/wait-for-petris
[1842]80    openvt 8 /usr/bin/tail -f $LOGFILE
[1]81}
82
83
84LoadKeymap() {
[1770]85    local fname
86    fname=`grep keymap-lives-here /tmp/mondo-restore.cfg | cut -d'=' -f2 2> /dev/null`
87    [ "$fname" = "" ] && return
88    if which loadkeys > /dev/null 2> /dev/null ; then
89        loadkeys $fname
[1]90# loadkmap != loadkeys
91#    elif which loadkmap > /dev/null 2> /dev/null ; then
92#        loadkmap < $fname
[1770]93    else
94        LogIt "Using default keyboard map." 1
95    fi
[1]96}
97
98
99UntarTapeStuff() {
[1770]100    local old_pwd res
101    old_pwd=`pwd`
102    cd $GROOVY
103    [ "$1" != "" ] && tapedev=$1
104    [ ! "$tapedev" ] && tapedev=`grep media-dev /tmp/mondo-restore.cfg | tr -s ' ' ' ' | cut -d' ' -f2`
[1]105#    tar -zxf $tapedev
[1770]106    dd if=$tapedev bs=32k count=1024 | tar -zx
107    res=$?
108    if [ "$res" -eq "0" ] ; then
[241]109    grep -v media-dev /tmp/mondo-restore.cfg > /tmp/mr.cfg
[1158]110    echo "media-dev=$tapedev" >> /tmp/mr.cfg
[1770]111        cp -f /tmp/mr.cfg /tmp/mondo-restore.cfg
112    fi
113    cd $old_pwd
114    return $res
[1]115}
116
117HandleTape() {
[1770]118    local res tapedev
119    tapedev="" ; # will be set by UntarTapeStuff()
120    cd $GROOVY
121    UntarTapeStuff $tapedev || UntarTapeStuff /dev/st0 || UntarTapeStuff /dev/osst0 || UntarTapeStuff /dev/ht0
122    res=$?
123    while [ "$res" -ne "0" ] ; do
124        LogIt "$tapedev failed to act as extended data disk for booting." 1
125        LogIt "Please specify an alternate tape device," 1
126        LogIt "or hit <Enter> to boot from CD/floppies." 1
127        echo -en "---> "
128        read tapedev
129        if [ "$tapedev" ] ; then
130            LogIt "User specified $tapedev instead"
131            UntarTapeStuff $tapedev
132            res=$?
133        else
134            LogIt "User opted not to specify an alternate tapedev"
135            res=1
[1]136        break
[1770]137        fi
138    done
[1]139
[1770]140    if [ "$res" -ne "0" ] ; then
[1581]141        cd /
142        LogIt "Failed to use tape as extended datadisk. Reverting to cd." 1
143        HandleCDROM
144        res=$?
[1770]145    else
[1581]146    #   clear
147        LogIt "Using tape as extended datadisk. Good." 3
148        echo "Using tape as extd ddisk." > /tmp/TAPEDEV-HAS-DATA-DISKS
149        res=0
[1770]150        CD_MOUNTED_OK=yes
151    fi
152    return $res
[1]153}
154
155
156
[1581]157HHandleCDROM() {
[1842]158    # Just in case we have an iLO ensure we will map it correctly
159    echo "$DENY_MODS" | grep -q "usb-storage "
160    if [ $? -eq 0 ]; then
161        return
162    fi
163    echo "Activating a potential USB Storage device"
164    if [ -f usb-storage.ko ] || [ -f usb-storage.ko.gz ]; then
165        if [ -e "/tmp/USE-UDEV" ] ; then
166            modprobe -q usb-storage
167        else
168            insmod usb-storage.ko*
169        fi
170    fi
171    for i in 1 2 3 4 5 6 7 8 9 10 ; do
172        sleep 1
173        echo -en "."
174    done
175
[1770]176    find-and-mount-cdrom
177    res=$?
178    if [ "$res" -ne "0" ] ; then
[898]179        LogIt "First call to find-and-mount-cdrom failed." 1
180        LogIt "Sleeping for 3 seconds and trying again." 1
181        sleep 3
182        find-and-mount-cdrom
183        res=$?
[1770]184    fi
185    if [ "$res" -eq "0" ] ; then
[898]186        LogIt "OK, I am running on a CD-ROM. Good." 3
[1770]187        CD_MOUNTED_OK=yes
188    elif [ "$res" -eq "1" ] ; then
189        LogIt "OK, I am running on floppies. Good." 3
190        CD_MOUNTED_OK=""
191    else
[1842]192        LogIt "OK, I am falling back to floppy mode." 3
193        LogIt "(You may not have the right drivers" 3
194        LogIt "to support the hardware on which we are running)" 3
195        LogIt "That means you'll have to copy the data disk images from" 3
196        LogIt "the CD/hard disk/whatever to physical 1.44MB disks and" 3
197        LogIt "insert them, one after the other. Please see the manual." 3
198        LogIt "The images are in /images on the CD, or /root/images/mindi" 3
199        LogIt "on your hard disk. Your archives are probably fine but" 3
200        LogIt "your tape streamer and/or CD-ROM drive are eccentric. :-)" 3
[898]201        CD_MOUNTED_OK=""
[1770]202    fi
203    return 0
[1]204}
205
206
207HowMuchFreeSpaceOnRamdisk() {
[305]208   df -m -P | grep /dev/ram | head -n1 | tr -s '\t' ' ' | cut -d' ' -f4
[1]209}
210
211
212
213InsertEssentialModules() {
[429]214#   Load the VIA IDE module first thing if it exists (requires ide-core).
215#   This is to ensure that DMA is working for VIA chipsets with 2.6 kernels.
[1842]216    for module in /ide-core.ko* /via82cxxx.ko*; do
[1770]217        [ -f "$module" ] && MyInsmod $module > /dev/null 2> /dev/null
218    done
[429]219#   Then load the remaining modules in normal (i.e. arbitrary) order.
[1770]220    for j in 1 2 3 4 5 ; do
221        for i in `ls /*.*o* 2> /dev/null` ; do
222            [ -f "$i" ] && MyInsmod $i > /dev/null 2> /dev/null
223        done
224    done
[1]225}
226
227
228
229PauseForRaids() {
[1770]230    if [ "`dmesg | grep -i "RAID Controller"`" != "" ] || [ "`dmesg | grep -i "Vendor: 3ware"`" != "" ] ; then
231        LogIt "RAID controller(s) detected. Pausing 10 seconds to let them warm up." 1
232        echo -en "Pausing..."
233        for i in 1 2 3 4 5 6 7 8 9 10 ; do
234            sleep 1
235            echo -en "$(($i*10))%..."
236        done
237        echo "Done."
238    fi
[1]239}
240
241
242# 06/13/2002 --- DuckX's & Hugo's new routine
243# 10/11/2003 --- added a simple devfsd.conf file
244# 01/24/2005 --- cater for arbitrary locations of devfsd.conf by using the
245#                config file path compiled into devfsd
246RunDevfsd() {
[1770]247    loc=`which devfsd 2> /dev/null`
248    if [ "$loc" != "" ] ; then
[1]249    LogIt "Devfs found. Testing kernel support..."
250    if [ ! -e "/dev/.devfsd" ] ; then
[746]251        mount -t devfs devfs /dev 2>> $LOGFILE
[1770]252            if [ "$?" -ne "0" ] ; then
[1]253        LogIt "Error while trying to mount devfs"
254        else
255        LogIt "Devfs mounted OK"
256        fi
257    fi
258    #check if the kernel supports devfs
259    if [ -e "/dev/.devfsd" ] ; then
260        [ -d "/proc/1" ] || mount -n /proc
261        LogIt "Kernel support found. Creating config file and starting devfsd"
[911]262        conffile=`strings $loc | grep -E "devfsd.conf$"`
[1]263        [ "$conffile" ] || conffile="/etc/devfsd.conf"
264        confpath=`echo $conffile | sed "s/\/devfsd\.conf$//"`
265        [ -d "$confpath" ] || mkdir -p $confpath
266        echo -en "REGISTER .* MKOLDCOMPAT\nUNREGISTER .* RMOLDCOMPAT\n" > $conffile
267        devfsd /dev &
268        sleep 5
269    else
270        LogIt "No devfs kernel support."
271    fi
[1770]272    fi
[1]273}
274
[1770]275# Taken from udev management in Mandriva 2008.0. Kudos guys
276make_extra_nodes () {
277    # there are a few things that sysfs does not export for us.
278    # these things are listed in /etc/udev/links.conf
279    grep '^[^#]' /etc/udev-links.conf | \
280    while read type name arg1; do
281        [ "$type" -a "$name" -a ! -e "/dev/$name" -a ! -L "/dev/$name" ] ||continue
282        case "$type" in
283            L) ln -s $arg1 /dev/$name ;;
284            D) mkdir -p /dev/$name ;;
285            M) mknod /dev/$name $arg1 && chmod 600 /dev/$name;;
286            *) echo "udev-links.conf: unparseable line (%s %s %s)\n" "$type" "$name" "$arg1" ;;
287        esac
288    done
289}
[1]290
[1842]291create_dev_makedev() {
292  if [ -e /sbin/MAKEDEV ]; then
293    ln -sf /sbin/MAKEDEV /dev/MAKEDEV
294  else
295    ln -sf /bin/true /dev/MAKEDEV
296  fi
297}
[1]298
[1770]299RunUdevd() {
300    # Inspiration from Mandriva 2008.0 startup script
301    echo "Preparing udev environment..."
302    mv /dev /dev.static
303    mkdir /dev
304    mount -n -o size=5M,mode=0755 -t tmpfs none /dev
305    make_extra_nodes
306    mount -n -t devpts -o mode=620 none /dev/pts
307    mount -n -t tmpfs  none /dev/shm
[1842]308    if [ -e /proc/sys/kernel/hotplug ]; then
309        echo > /proc/sys/kernel/hotplug
310    fi
[1770]311    PKLVL=`cut -f1 /proc/sys/kernel/printk`
312    echo 0 > /proc/sys/kernel/printk
313    if [ -x /sbin/startudev ]; then
314        /sbin/startudev
315    fi
316    # Depending on udevd version it gives back the hand or not :-(
317    /sbin/udevd --daemon &
318    sleep 2
[1842]319    mkdir -p /dev/.udev/queue/
320    if [ -x /sbin/udevtrigger ]; then
321        /sbin/udevtrigger
322    fi
323    create_dev_makedev
[1770]324    # May avoid shell error messages
325    chmod 644 /dev/tty*
[1842]326    if [ -x /sbin/udevsettle ]; then
327        /sbin/udevsettle
328    fi
329    # It seems we need to have more static devs on some distro were
330    # udev as some other requirements to be covered later on.
331    # So in the mean time:
332    for d in `ls /dev.static`; do
333        if [ ! -e /dev/$d ]; then
334            mv /dev.static/$d /dev
335        fi
336    done
337    echo $PKLVL > /proc/sys/kernel/printk
[1770]338}
[1]339
[1770]340RstHW() {
[1]341
[1770]342    # Restore the HW configuration if available (NOT by default)
343    answer="NO"
[1]344
[1842]345    grep -q nohw /proc/cmdline
346    if [ "$?" -eq 0 ]; then
347        return
348    fi
[1770]349    if [ -x ./mindi-rsthw ]; then
350        grep -q RESTORE /proc/cmdline
351        if [ "$?" -ne 0 ]; then
[1842]352            #clear
[1770]353            echo "*********************************************************************"
354            echo "Do you want to restore the HW configuration of the original machine ?"
355            echo "(This may dammage your hardware so be sure to check twice before saying yes)"
356            echo "*********************************************************************"
357            echo "Please confirm by typing YES exactly as written here (NO by default)"
358            echo -n "--> "
359            read answer
360        else
361            answer="YES"
362        fi
363        if [ "$answer" -eq "YES" ] ; then
364            ./mindi-rsthw
365        fi
366    fi
367}
368
369
[1]370#RunDevfsd() {
371#    loc=`which devfsd 2> /dev/null`
372#    if [ "$loc" != "" ] ; then
373#        LogIt "Starting devfsd"
374#        devfsd /dev &
375#        sleep 5
376#    fi
377#}
378
379
380
381SpaceTests() {
[1770]382    [ -e "/tmp/filelist.full" ] && cp /tmp/filelist.full /tmp/FLF
383    if [ "`HowMuchFreeSpaceOnRamdisk`" -le "3" ] ; then
384        LogIt "Ramdisk is a bit smaller than I would like." 1
385        LogIt "Please re-run Mondo/Mindi but edit /usr/local/mindi first" 1
386        LogIt "and set EXTRA_SPACE to something high, e.g. 8000" 1
387        Die "Aborting. Please reboot."
388    fi
389    rm -f /tmp/FLF
[1]390}
391
[1842]392StartUSBKbd() {
393# Prepare minimal USB env in case we have USB kbd such as with iLO
394[ -d /proc/bus/usb ] && ! grep -q /proc/bus/usb /proc/mounts && mount -t usbfs none /proc/bus/usb
395echo "$DENY_MODS" | grep -Eq 'uhcd_hci |usbhid |usbcore '
396if [ $? -eq 0 ]; then
397    return
398fi
399if [ -e "/tmp/USE-UDEV" ] ; then
400    if [ -f uhcd_hci.ko ] || [ -f uhcd_hci.ko.gz ]; then
401        modprobe -q uhcd_hci
402    fi
403    if [ -f usbhid.ko ] || [ -f usbhid.ko.gz ]; then
404        modprobe -q usbhid
405    fi
406else
407    if [ -f uhcd_hci.ko ]; then
408        insmod uhcd_hci.ko
409    fi
410    if [ -f usbhid.ko ]; then
411        insmod usbcore.ko
412        insmod usbhid.ko
413    fi
414fi
415}
[1]416
417
[1842]418
[1]419StartLvms() {
[1770]420    if [ -e "/tmp/i-want-my-lvm" ] ; then
421        LogIt "Scanning LVM's..." 1
[739]422        if which lvm ; then
423            MyInsmod dm-mod
424            MyInsmod dm_mod
425            lvm vgscan --mknodes
426        else
427            vgscan
428        fi
[1770]429        grep -E "^#.*vgchange" /tmp/i-want-my-lvm | sed "s/^#[ ]*//" > /tmp/start-lvm
430        chmod +x /tmp/start-lvm
431        echo -en "Starting LVM's..."
432        /tmp/start-lvm &
433        for i in 1 2 3 4 5 ; do
[1]434        echo -en "."
435        sleep 1
[1770]436        done
437        echo "Done."
438    fi
[1]439# If necessary, cannibalize 'analyze-my-lvm'; copy some of its code here,
440# pipe vgscan's output, strip it, run 'vgchange' on its output, etc.etc.
[1770]441    LogIt "LVM's have been started."
[1]442}
443
444
445StartRaids() {
[1770]446    local raid_devices i
[1272]447
[1770]448    raid_devices=`grep /dev/md /tmp/mountlist.txt | cut -d' ' -f1`
[623]449    if which raidstart > /dev/null 2> /dev/null ; then
[1770]450        for i in $raid_devices ; do
451            if grep `basename $i` /proc/mdstat > /dev/null 2> /dev/null ; then
452                LogIt "$i is started already; no need to run 'raidstart $i'" 1
453            else
[623]454                LogIt "Running 'raidstart $i'" 1
455                raidstart $i
[1770]456            fi
457        done
[623]458    elif which mdrun > /dev/null 2> /dev/null ; then
459        LogIt "Running 'mdrun'" 1
460        mdrun
[1272]461    elif which mdadm > /dev/null 2> /dev/null ; then
462        LogIt "Running 'mdadm'" 1
463        for i in $raid_devices ; do
[1770]464            if grep `basename $i` /proc/mdstat > /dev/null 2> /dev/null ; then
465                LogIt "$i is started already; no need to run 'mdadm $i'" 1
466            else
[1621]467                if [ -f /etc/mdadm.conf ] ; then
468                    LogIt "Running 'mdadm $i' with user supplied /etc/mdadm.conf" 1
469                    mdadm -A $i -c /etc/mdadm.conf
470                elif [ -f /etc/mdadm/mdadm.conf ] ; then
471                    LogIt "Running 'mdadm $i' with user supplied /etc/mdadm/mdadm.conf" 1
472                    mdadm -A $i -c /etc/mdadm/mdadm.conf
473                else
474                    LogIt "Running 'mdadm $i'" 1
475                    mdadm -Ac partitions -m dev $i
476                fi
[1770]477            fi
478        done
[623]479    else
480        LogIt "Warning: Neither 'raidstart' nor 'mdrun''found. RAID devices may not have started." 1
481    fi
482
[1]483}
484
485
486TryAgainToFindCD() {
[1770]487    local res
488    mount | grep /mnt/cdrom && return 0
489    [ "`grep "backup_media_type" /tmp/mondo-restore.cfg | grep "cdstream"`" ] && return
490    LogIt "Trying to mount CD-ROM a 2nd time..."
491    find-and-mount-cdrom --second-try
492    res=$?
493    if [ "$res" -eq "0" ] ; then
494        CD_MOUNTED_OK=yes
495        LogIt "CD-ROM drive mounted successfully." 1
496    else
497        LogIt "I still cannot find or mount the CD-ROM drive, by the way."
498    fi
[1]499}
500
501
502
503UseTmpfs()
504{
[1770]505    local mount_cmd
506    echo -en "Mounting /tmp/tmpfs..."
507    mkdir -p /tmp/tmpfs
[1]508# For technical reasons, some sets are as large as 16MB.
509# I am allowing 32MB because selective restore occupies a lot of space.
[1770]510    for size in 64m 48m 40m 32m ; do
511        mount_cmd="mount /dev/shm -t tmpfs -o size=$size" ; # was 34m until 04/2003
512        LogIt "Trying '$mount_cmd'"
[1675]513        $mount_cmd /tmp/tmpfs 2>> $LOGFILE
514        res=$?
515        [ "$res" -eq "0" ] && break
[1770]516    done
517    if [ "$res" -ne "0" ] ; then
518        LogIt "Failed. I could not run '$mount_cmd /tmp/tmpfs'. Your kernel is BROKEN or you do not have enough RAM." 1
519        umount /tmp/tmpfs > /dev/null 2> /dev/null
[1675]520        rmdir /tmp/tmpfs
[1770]521        ln -sf /mnt/RESTORING/tmp /tmp/tmpfs; # used by mondo-restore
[1675]522        LogIt "Failed to mount /tmp/tmpfs; using ugly softlink instead"
[1770]523    else
524        LogIt "Great. Pivot succeeded w/ size=$size" 1
525        echo -en "Pivoting /tmp..."
526        umount /tmp/tmpfs
527        mkdir -p /tmp.old
528        mv /tmp/* /tmp.old/
529        # Try to Deal with a busybox bug on inexistant links
530        cp /tmp/* /tmp.old/
531        rm -f /tmp/*
532        $mount_cmd /tmp
533        mv /tmp.old/* /tmp/
534        # Try to Deal with a busybox bug on inexistant links
535        cp /tmp.old/* /tmp/
536        rm -rf /tmp.old
537        mkdir -p /tmp/tmpfs
538        mkdir -p $GROOVY
[1]539    echo "Done."
540    LogIt "Successfully mounted dynamic /tmp ramdisk"
541#   mkdir -p /tmp/tmpfs/var
542#        mv -f /var/log /tmp/tmpfs/var/log
543#        ln -sf /tmp/tmpfs/var/log /var/log
[1770]544    fi
[1]545}
546
547
548WelcomeMessage()
549{
[1842]550    export ARCH=`uname -m`
551
[1770]552    echo "********************************************************************"
553    echo "MINDI-LINUX by Mondo Dev Team - web site: http://www.mondorescue.org"
554    echo "Boot disk based on AlfaLinux & Trinux. BusyBox by Erik Andersen."
[1]555which petris > /dev/null 2> /dev/null && echo "Petris was written by Peter Seidler <p.seidler@mail1.stofanet.dk>."
[1770]556    echo "Executables and source code are covered by the GNU GPL. No warranty."
557    echo "running on $ARCH"
558    echo "********************************************************************"
[1]559}
560
561
562EnableCcissIfAppropriate() {
[1770]563    local i fname
564    for i in 0 1 2 3 4 5 6 7 8 9 ; do
[1351]565        fname="/proc/driver/cciss/cciss$i"
566        if [ -e "$fname" ] ; then
567            LogIt "Engaging $fname"
568            echo "engage scsi" > $fname
569            LogIt "...result=$?"
570        fi
[1770]571    done
[1]572}
573
[1842]574ModprobeAllModules() {
[1]575
[1842]576    for m in `find /lib/modules -name '*.ko*'`; do
577        j=`basename $m | sed 's/\.ko.*$//'`
578        echo "$DENY_MODS" | grep -q "$j "
579        if [ $? -eq 0 ]; then
580            echo "Denying $j..."
581            continue
582        fi
583        echo "Probing $j..."
584        modprobe -q $j
585    done
586}
587
[287]588ExtractDataDisksAndLoadModules() {
589    echo "Installing additional tools ..."
590    install-additional-tools
[1770]591    # Keep the kernel silent again
592    PKLVL=`cut -f1 /proc/sys/kernel/printk`
593    echo 0 > /proc/sys/kernel/printk
[1842]594    if [ ! -e "/tmp/USE-UDEV" ] ; then
595        echo "Inserting modules ..."
596        insert-all-my-modules >> $LOGFILE 2>> $LOGFILE
597        for i in $FORCE_MODS; do
598            MyInsmod $i
599        done
600    else
601        ModprobeAllModules
602    fi
[1770]603    echo $PKLVL > /proc/sys/kernel/printk
[287]604}
[1]605
606# ------------------------ main -----------------------
607
[1770]608MINDI_VER=PBVER
609MINDI_REV=PBREV
[1]610trap CaughtSoftReset SIGTERM
[1663]611LOGFILE=/var/log/mondorestore.log
[1061]612PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/mondo:/usr/games
[1]613GROOVY=/tmp/groovy-stuff
614USER=root
[1339]615export PATH GROOVY USER LOGFILE
[1]616
[1675]617echo "Welcome to init (from mindi ${MINDI_VER}-r${MINDI_REV})"
[898]618
[1]619mount -o remount rw /
620[ ! "$GROOVY" ] && Die "I'm not groovy!"
621for i in $GROOVY /mnt/floppy /mnt/cdrom /mnt/isodir /var/local/petris /tmp/isodir; do
[1770]622    mkdir -p $i
[1]623done
624#/bin/update
625mount /proc/ /proc -v -t proc
626mkdir /sys 2> /dev/null
627mount /sys/ /sys -v -t sysfs 2>> $LOGFILE
[1842]628# For ESX 3
629[ -d /proc/vmware ] && ! grep -q /vmfs /proc/mounts && mount -t vmfs /vmfs /vmfs
[1]630rm -f /foozero
631
[1842]632if [ "`grep -i denymods /proc/cmdline`" ]; then
633    export DENY_MODS="`cat /proc/cmdline | sed 's~.*denymods=\"\(.*\)\".*~\1~'` mondonone"
634else
635    export DENY_MODS=" "
636fi
637
638if [ "`grep -i forcemods /proc/cmdline`" ]; then
639    export FORCE_MODS="`cat /proc/cmdline | sed 's~.*forcemods=\"\(.*\)\".*~\1~'` mondonone"
640else
641    export FORCE_MODS=" "
642fi
643
644echo "Activating a potential USB keyboard/mouse"
645StartUSBKbd
646
[1770]647if [ -f /proc/sys/kernel/exec-shield ]; then
648    echo 0 > /proc/sys/kernel/exec-shield 2>> /dev/null
649fi
[1]650
[1770]651if [ -f /proc/modules ]; then
652    echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
653fi
654
655if [ -e "/tmp/USE-UDEV" ] ; then
656    RunUdevd
657fi
[1842]658ExtractDevTarballs
[1]659LaunchTerminals
[1770]660
661# Keeping kernel silent  for module insertion
662PKLVL=`cut -f1 /proc/sys/kernel/printk`
663echo 0 > /proc/sys/kernel/printk
[1842]664if [ ! -e "/tmp/USE-UDEV" ] ; then
665    InsertEssentialModules
666else
667    ModprobeAllModules
668fi
[1770]669echo $PKLVL > /proc/sys/kernel/printk
670
[1]671EnableCcissIfAppropriate
672#-------------------------------
673#WHOLIVESINAPINEAPPLEUNDERTHESEA#;# --- don't touch this :)
674#-------------------------------
675UseTmpfs
676if [ ! -e "/tmp/mondo-restore.cfg" ] ; then
[1770]677    LogIt "Warning - /tmp/mondo-restore.cfg not found"
[1]678fi
679
[1770]680if [ "`grep -i 'tape ' /tmp/mondo-restore.cfg`" ] || [ "`grep -i udev /tmp/mondo-restore.cfg`" ]; then
681    HandleTape
[287]682    ExtractDataDisksAndLoadModules
[737]683elif [ "`grep -i pxe /proc/cmdline`" ]; then
[870]684    # We need to get here exported variables from start-nfs
[1770]685    . /sbin/start-nfs
[737]686
[287]687    # Simulate a local CD
688    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
[1770]689    CD_MOUNTED_OK=yes
[287]690    ExtractDataDisksAndLoadModules
[1770]691elif [ "`grep -i usb= /proc/cmdline`" ] || [ "`grep -i usb /tmp/mondo-restore.cfg | grep media-type`" ]; then
692    # We need to get here exported variables from start-nfs
693    . /sbin/start-usb
694
695    # Simulate a local CD
696    echo "/mnt/cdrom" > /tmp/CDROM-LIVES-HERE
697    CD_MOUNTED_OK=yes
698    ExtractDataDisksAndLoadModules
[1]699else
[1581]700    HandleCDROM
[287]701    ExtractDataDisksAndLoadModules
[870]702    # We need to get here exported variables from start-nfs
[1770]703    . /sbin/start-nfs
[1]704fi
705res=$?
706ConfigureLoggingDaemons
707if [ -e "/tmp/USE-DEVFS" ] ; then
[1770]708    umount /mnt/cdrom 2> /dev/null
709    mv /dev/cdrom /cdrom.lnk 2> /dev/null
710    CD_MOUNTED_OK=""
711    RunDevfsd
[1]712fi
[1842]713LoadKeymap
714WelcomeMessage
715RstHW
[232]716echo "Starting potential Raid/LVMs ..."
[1]717PauseForRaids
718StartRaids
719StartLvms
720CopyBootDevEntry
721mkdir -p /tmp/tmpfs
722sleep 2
723#clear
[241]724if [ -e "/dev/md0" ] && [ ! -e "/dev/md/0" ] && [ "`grep /dev/md/ /tmp/mountlist.txt`" != "" ] ; then
[1770]725    LogIt "Creating /dev/md/* softlinks just in case." 1
726    mkdir -p /dev/md
727    cp -af /dev/md0 /dev/md/0 2> /dev/null
728    cp -af /dev/md1 /dev/md/1 2> /dev/null
729    cp -af /dev/md2 /dev/md/2 2> /dev/null
[1]730fi
731# SpaceTests; # Mandrake Linux 8.1 doesn't like this
732[ -e "/tmp/mountlist.txt" ] && cp -f /tmp/mountlist.txt /tmp/mountlist.original
733
[241]734if ! [ "`grep -i "pxe" /proc/cmdline`" ] ; then
[1]735    res="`cat /mnt/cdrom/archives/THIS-CD-NUMBER 2> /dev/null`"
736    [ "$res" != "1" ] && [ "$res" != "" ] && Die "This is CD #$res in the series. Please insert CD #1."
737    [ -e "/cdrom.lnk" ] && mv -f /cdrom.lnk /dev/cdrom && mount /dev/cdrom /mnt/cdrom && CD_MOUNTED_OK=yes
738    [ "$CD_MOUNTED_OK" != "yes" ] && TryAgainToFindCD
739    #mount | grep cdrom > /dev/null 2> /dev/null || mount /dev/cdrom /mnt/cdrom >> $LOGFILE 2>> $LOGFILE
740fi
741hack-cfg-if-necessary || LogIt "Cannot find hack-cfg-if-necessary"
742
[1408]743# Log some useful info
[1842]744LogIt "init (from mindi v$MINDI_VER-r${MINDI_REV})"
[1414]745LogIt "/proc/cmdline is:"
[1408]746cat /proc/cmdline  >> $LOGFILE
[1414]747LogIt "df result:"
748LogIt "----------"
[1408]749df >> $LOGFILE
[1414]750LogIt "-------------"
751LogIt "mount result:"
752LogIt "-------------"
[1408]753mount >> $LOGFILE
[1414]754LogIt "-------------"
755LogIt "lsmod result:"
756LogIt "-------------"
[1408]757lsmod >> $LOGFILE
[1414]758LogIt "-------------"
[1478]759LogIt "dmesg result:"
760LogIt "-------------"
761dmesg >> $LOGFILE
[1408]762
[1]763#-------------------------------
764#ABSORBENTANDYELLOWANDPOROUSISHE#;# --- don't touch this either :)
765#-------------------------------
766
767#ctrlaltdel soft
768for path in /usr.bin /usr/bin ; do
[1770]769    fname=$path/nano
770    [ -e "$fname" ] && ln -sf $fname /usr/bin/pico
[1]771done
772res=`which nano 2> /dev/null`
773[ "$res" ] && ln -sf /usr/bin/
774for i in null stdout stdin stderr ; do
[1770]775    cp -af /dev/$i /tmp
[1]776done
777if grep "backup-media-type" /tmp/mondo-restore.cfg > /dev/null 2> /dev/null ; then
[1770]778    LogIt "backup-media-type is specified in config file - great."
779    LogIt "Calling post-init $mountlist"
780    post-init
[1]781else
[1770]782    LogIt "backup-media-type is not specified in config file."
783    LogIt "I think this CD/floppy has no archives on it."
[1]784fi
[1621]785if grep "RESTORE" /proc/cmdline > /dev/null 2> /dev/null ; then
786    echo "Rebooting in 10 seconds automatically as per reboot order"
787    echo -en "Press ^C to interrupt if you have to ..."
788    for i in 1 2 3 4 5 6 7 8 9 10 ; do
789        sleep 1
790        echo -en "."
791    done
792    echo "Boom."
793    sleep 1
794else
795    echo -en "Type 'exit' to reboot the PC\n"
796    umount /mnt/cdrom 2> /dev/null
797    mount / -o rw,remount > /dev/null 2> /dev/null
798    LogIt "Launching Shell"
799    sh
800fi
[1]801CaughtSoftReset
802# reboot
Note: See TracBrowser for help on using the repository browser.