source: branches/2.2.5/mindi/rootfs/sbin/init @ 1800

Last change on this file since 1800 was 1800, checked in by bruno, 12 years ago

Also modprobe modules for udev after decompressing the additional ones

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