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

Last change on this file since 1770 was 1770, checked in by bruno, 12 years ago
  • Better output for mindi-busybox revision
  • Remove dummy file created on NFS - report from Arnaud Tiger <arnaud.tiger_at_hp.com>
  • strace useful for debug
  • fix new versions for pb (2.0.0 for mindi and 1.7.2 for mindi-busybox)
  • fix build process for mindi-busybox + options used in that version (dd for label-partitions-as-necessary)
  • fix typo in label-partitions-as-necessary which doesn't seem to work
  • Update to busybox 1.7.2
  • perl is now required at restore time to support uuid swap partitions (and will be used for many other thigs

in the future for sure)

  • next mindi version will be 2.0.0 due to all the changes made in it (udev may break working distros)
  • small optimization in mindi on keyboard handling (one single find instead of multiple)
  • better interaction for USB device when launching mindi manually
  • attempt to automatically guess block disk size for ramdisk
  • fix typos in bkphw
  • Fix the remaining problem with UUID support for swap partitions
  • Updates mondoarchive man page for USB support
  • Adds preliminary Hardware support to mindi (Proliant SSSTK)
  • Tries to add udev support also for rhel4
  • Fix UUID support which was still broken.
  • Be conservative in test for the start-nfs script
  • Update config file for mindi-busybox for 1.7.2 migration
  • Try to run around a busybox bug (1.2.2 pb on inexistant links)
  • Add build content for mindi-busybox in pb
  • Remove distributions content for mindi-busybox
  • Fix a warning on inexistant raidtab
  • Solve problem on tmpfs in restore init (Problem of inexistant symlink and busybox)
  • Create MONDO_CACHE and use it everywhere + creation at start
  • Really never try to eject a USB device
  • Fix a issue with &> usage (replaced with 1> and 2>)
  • Adds magic file to depllist in order to have file working + ldd which helps for debugging issues
  • tty modes correct to avoid sh error messages
  • Use ext3 normally and not ext2 instead
  • USB device should be corrected after reading (take 1st part)
  • Adds a mount_USB_here function derived from mount_CDROM_here
  • usb detection place before /dev detection in device name at restore time
  • Fix when restoring from USB: media is asked in interactive mode
  • Adds USB support for mondorestore
  • mount_cdrom => mount_media
  • elilo.efi is now searched throughout /boot/efi and not in a fixed place as there is no standard
  • untar-and-softlink => untar (+ interface change)
  • suppress useless softlinks creation/removal in boot process
  • avoids udevd messages on groups
  • Increase # of disks to 99 as in mindi at restore time (should be a conf file parameter)
  • skip existing big file creation
  • seems to work correctly for USB mindi boot
  • Adds group and tty link to udev conf
  • Always load usb-torage (even 2.6) to initiate USB bus discovery
  • Better printing of messages
  • Attempt to fix a bug in supporting OpenSusE 10.3 kernel for initramfs (mindi may now use multiple regex for kernel initrd detection)
  • Links were not correctly done as non relative for modules in mindi
  • exclusion of modules denied now works
  • Also create modules in their ordinary place, so that classical modprobe works + copy modules.dep
  • Fix bugs for DENY_MODS handling
  • Add device /dev/console for udev
  • ide-generic should now really be excluded
  • Fix a bug in major number for tty
  • If udev then adds modprobe/insmod to rootfs
  • tty0 is also cretaed with udev
  • ide-generic put rather in DENY_MODS
  • udevd remove from deplist s handled in mindi directly
  • better default for mindi when using --usb
  • Handles dynamically linked busybox (in case we want to use it soon ;-)
  • Adds fixed devices to create for udev
  • ide-generic should not be part of the initrd when using libata v2
  • support a dynamically linked udev (case on Ubuntu 7.10 and Mandriva 2008.0 so should be quite generic) This will give incitation to move to dyn. linked binaries in the initrd which will help for other tasks (ia6 4)
  • Improvement in udev support (do not use cl options not available in busybox)
  • Udev in mindi
    • auto creation of the right links at boot time with udev-links.conf(from Mandriva 2008.0)
    • rework startup of udev as current makes kernel crash (from Mandriva 2008.0)
    • add support for 64 bits udev
  • Try to render MyInsmod? silent at boot time
  • Adds udev support (mandatory for newest distributions to avoid remapping of devices in a different way as on the original system)
  • We also need vaft format support for USB boot
  • Adds libusual support (Ubuntu 7.10 needs it for USB)
  • Improve Ubuntu/Debian? keyboard detection and support
  • pbinit adapted to new pb (0.8.10). Filtering of docs done in it
  • Suppress some mondo warnings and errors on USB again
  • Tries to fix lack of files in deb mindi package
  • Verify should now work for USB devices
  • More log/mesages improvement for USB support
  • - Supress g_erase_tmpdir_and_scratchdir
  • Improve some log messages for USB support
  • Try to improve install in mindi to avoid issues with isolinux.cfg not installed vene if in the pkg :-(
  • Improve mindi-busybox build
  • In conformity with pb 0.8.9
  • Add support for Ubuntu 7.10 in build process
  • Add USB Key button to Menu UI (CD streamer removed)
  • Attempt to fix error messages on tmp/scratch files at the end by removing those dir at the latest possible.
  • Fix a bug linked to the size of the -E param which could be used (Arnaud Tiger/René? Ribaud).
  • Integrate ~/.pbrc content into mondorescue.pb (required project-builder >= 0.8.7)
  • Put mondorescue in conformity with new pb filtering rules
  • Add USB support at restore time (no test done yet). New start-usb script PB varibale added where useful
  • Unmounting USB device before removal of temporary scratchdir
  • Stil refining USB copy back to mondo (one command was not executed)
  • No need to have the image subdor in the csratchdir when USB.
  • umount the USB partition before attempting to use it
  • Remove useless copy from mindi to mondo at end of USB handling

(risky merge, we are raising the limits of 2 diverging branches. The status of stable is not completely sure as such. Will need lots of tests, but it's not yet done :-()
(merge -r1692:1769 $SVN_M/branches/2.2.5)

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