source: MondoRescue/branches/2.2.10/mindi/rootfs/sbin/init@ 2508

Last change on this file since 2508 was 2508, checked in by Bruno Cornec, 14 years ago

r3287@localhost (orig r2285): bruno | 2009-07-20 11:36:47 +0200

r3285@localhost: bruno | 2009-07-20 11:17:35 +0200
Apply fix in 2.2.10 around multi USB device handling to 2.2.9 as well


r3291@localhost (orig r2288): bruno | 2009-07-21 16:48:31 +0200
Copy 2.2.10 test script in to 2.2.9 for memory problm analysis


r3293@localhost (orig r2290): bruno | 2009-07-22 14:03:44 +0200

  • Fix a printing error in mindi for the tar command
  • Fix all mr_asprintf which had no second param as a string


r3295@localhost (orig r2292): bruno | 2009-07-22 16:55:00 +0200

  • Fix #160 and #346 by rewriting the message.txt file with more valid information gathered in mindi


r3300@localhost (orig r2294): bruno | 2009-07-23 01:58:08 +0200

Man pages patch from Joe Ross (joe.ross_at_gmail.com)


r3303@localhost (orig r2297): bruno | 2009-07-23 17:43:49 +0200
Fix a remaining display error for 2.2.9. That version has been tested OK in a lab.


r3304@localhost (orig r2298): bruno | 2009-07-23 18:18:27 +0200

  • Remove memory leak for the last modification


r3308@localhost (orig r2302): bruno | 2009-07-24 21:18:50 +0200
Improve logging of mountlist.txt


r3310@localhost (orig r2304): bruno | 2009-07-27 19:45:10 +0200

  • popup_and_get_string needs an allocated buffer for the moment so fixing the calls with dyn. ones
  • Fix a bug in mem.c for mr_strcat, which wasn't modifying the right pointer level


r3311@localhost (orig r2305): bruno | 2009-07-27 19:49:35 +0200
Avoid a memory leak in the previous patch


r3314@localhost (orig r2308): bruno | 2009-07-27 20:59:06 +0200
Fix a bug in mr_strcat backported from 2.2.10. Should solve our seg faults.


r3315@localhost (orig r2309): bruno | 2009-07-28 02:14:23 +0200
Cosmetic changes to allow for quality to not giv false positive


r3343@localhost (orig r2311): bruno | 2009-08-18 02:13:43 +0200
Fix for initramfs detection with 2.6.30 (Hugo Vanwoerkom hvw59601_at_care2.com)


r3367@localhost (orig r2333): bruno | 2009-08-18 16:26:26 +0200
Adds a precision for -U option in man page on raw device usage and not partition name


r3373@localhost (orig r2336): bruno | 2009-08-20 17:37:41 +0200

  • Precise the combined usage of -E and -I in mondoarchive (Case 4601017223)


r3379@localhost (orig r2342): bruno | 2009-08-21 16:27:10 +0200


r3383@localhost (orig r2344): bruno | 2009-08-24 13:37:09 +0200

r3382@localhost: bruno | 2009-08-24 13:30:25 +0200
In NFS mode also propose access to expert, interactive, ... entry at boot prompt


r3388@localhost (orig r2346): bruno | 2009-08-27 11:41:16 +0200
Adds fdisk -l result in Log File at restore time


r3389@localhost (orig r2347): bruno | 2009-08-27 13:51:00 +0200

  • Solve tmp dir creation which sometimes was trying to create /%xx dirs. Should fix #293 for good


r3390@localhost (orig r2348): bruno | 2009-08-27 13:54:25 +0200
Improve logging (minor)


r3394@localhost (orig r2350): bruno | 2009-08-28 02:24:19 +0200
Change inerface of evaluate_mountlist and spread_flaws_across_three_lines in order to solve bugs linked to strings management in these functions. May fix a restoration crash seen by some customers


r3397@localhost (orig r2353): bruno | 2009-08-28 19:03:45 +0200

  • Addition of a nomd option to avoid starting mdadm
  • mpath is now already started if there was a mpath entry in mountlist


r3399@localhost (orig r2355): bruno | 2009-08-29 00:56:50 +0200
Remove function spread_flaws_across_three_lines and expand it at the single place where it was useful, and fix memory allocation issues in it.


r3402@localhost (orig r2358): bruno | 2009-09-01 19:02:35 +0200
P2V doc updated (Lester Wade lester.wade_at_hp.com)


r3404@localhost (orig r2360): bruno | 2009-09-01 19:26:53 +0200
Website update to refer to new P2V document


r3405@localhost (orig r2361): bruno | 2009-09-03 13:54:25 +0200

  • Fix a case where the NFS dir in restore mode was mounted rw (linked to bug #291 could create a huge problem)


r3407@localhost (orig r2363): bruno | 2009-09-03 14:46:46 +0200
More verbose at installation of additional tools


r3409@localhost (orig r2365): bruno | 2009-09-03 18:08:32 +0200

  • New update from Lester Wade (lester.wade_at_hp.com) for P2V doc


r3410@localhost (orig r2366): bruno | 2009-09-05 01:28:18 +0200
place the code of mondo_makefilelist before its call



r3411@localhost (orig r2367): bruno | 2009-09-06 01:51:26 +0200

  • Advertising for project-builder on the website added


r3412@localhost (orig r2368): bruno | 2009-09-07 15:36:23 +0200
Fix compilation issue


r3413@localhost (orig r2369): bruno | 2009-09-07 18:03:40 +0200
Another compilation issue fixed.


r3415@localhost (orig r2371): bruno | 2009-09-08 13:40:25 +0200

  • Fix a problem a error detection in evaluate_mountlist which casued nuke mode to abort. Error string should also be better now.


r3417@localhost (orig r2373): bruno | 2009-09-08 13:55:31 +0200
Avoid asking the Prefix name in NFS mode twice


r3418@localhost (orig r2374): bruno | 2009-09-08 20:04:07 +0200

  • Try to fix garbled screen progression in text mode based on 2.2.10 modifications which are working


r3424@localhost (orig r2380): bruno | 2009-09-09 20:30:47 +0200

  • Change NFS support into a NetFS support to allow for multiple protocol in addition to NFS (NEEDS TESTING)
  • Better logging to detect a potential nuke issue


r3425@localhost (orig r2381): bruno | 2009-09-10 02:05:55 +0200
Fix a missing param for sshfs call


r3428@localhost (orig r2384): bruno | 2009-09-10 13:02:56 +0200

  • Remove separate function look_for_duplicate_mountpoints used only once and whose interface created problems with caller


r3430@localhost (orig r2386): bruno | 2009-09-10 16:06:52 +0200
Be compatible on backup type by making old nfs recognized as netfs and proto forced


r3431@localhost (orig r2387): bruno | 2009-09-10 18:40:47 +0200
Fix a problem in netfs analysis in mondoarchive


r3432@localhost (orig r2388): bruno | 2009-09-10 20:25:13 +0200
Fix mondoarchive CLI analysis for NETFS type of requests


r3434@localhost (orig r2390): bruno | 2009-09-11 03:05:20 +0200

  • Adds ext3 initrd support for 2.6.30


r3437@localhost (orig r2393): bruno | 2009-09-11 11:56:52 +0200

  • Tries to add support for bzip2 and lzma initramfs (preliminary, not tested) for 2.6.30


r3438@localhost (orig r2394): bruno | 2009-09-12 02:53:02 +0200
Fix interface of evaluate_mountlist (remove 2nd param useless) and fix nuke mode which wasn't working.


r3441@localhost (orig r2397): bruno | 2009-09-14 18:54:34 +0200
Fix a format issue in text mode on percentage


r3452@localhost (orig r2398): bruno | 2009-09-15 16:00:13 +0200

  • Fix a bug where flaws_str could be NULL and wasn't tested correctly.


r3453@localhost (orig r2399): bruno | 2009-09-15 19:28:39 +0200

  • Use protocol name when displaying restore progress instead of netfs
  • Ask for network protocol name at restore time


r3455@localhost (orig r2401): bruno | 2009-09-15 19:34:19 +0200
Wrong structure member name was used


r3456@localhost (orig r2402): bruno | 2009-09-16 13:04:17 +0200
Use dir for shell related commands and dir1 for C related actions in open_and_list_dir to avoid missing some files with { in names e.g.


r3457@localhost (orig r2403): bruno | 2009-09-16 16:32:03 +0200

  • At restore time read the netfs protocol in the conf file


r3462@localhost (orig r2408): bruno | 2009-09-18 15:17:08 +0200
Remove useless script


r3463@localhost (orig r2409): bruno | 2009-09-18 15:25:35 +0200

  • Split deplist.txt into multiple conf files under deplist.d in the conf dir. This will allow to have a minimal.conf file for initrd content to analyze to improve support of new embedded feature in the future (sshfs, live install). The other conf files contain the additional commands to put in the all.tar.gz. For the moment, mindi is still working the same. THis infra will allow that support in a near future. deplist.txt is now reserved for the admin additional commands.


r3465@localhost (orig r2410): bruno | 2009-09-18 19:10:54 +0200

  • Better list of mandatory tools
  • Adds fuse and sshfs support in initrd


r3466@localhost (orig r2411): bruno | 2009-09-18 20:32:47 +0200
sshfs also needs ssh at restore time in initrd


r3478@localhost (orig r2418): bruno | 2009-09-23 23:22:39 +0200
Modify getfattr call to have all extended attributes, including non user ones. (patch from Kevin Ritzenthaler Kevin.Ritzenthaler_at_hp.com) and fix #357


r3479@localhost (orig r2419): bruno | 2009-09-23 23:50:34 +0200
star only supports ACL when used with exustar mode. Fix #356.


r3482@localhost (orig r2422): bruno | 2009-09-24 16:53:24 +0200

  • Adds support for bnx2x (BL 460 G6) and auth_rpcgss (Debian 2.6.31)


r3485@localhost (orig r2423): bruno | 2009-09-25 16:38:40 +0200
Fix an issue in is_this_device_mounted (string freed before last usage)


r3486@localhost (orig r2424): bruno | 2009-09-25 18:44:01 +0200

  • analyze-my-lvm now removes excluded devices from list coming from mondoarchive
  • new mr_make_devlist_from_pathlist which handle the new bkpinfo->exclude_devs field containing the excluded devices and remove corresponding code from libmondo-cli.c
  • Move DSF code into libmondo-devices.c for coherency, and only the previous function is made externally available
  • Remove dev_to_exclude in libmondo-archive.c which wasn't working correctly and replace it with bkpinfo->exclude_devs


r3487@localhost (orig r2425): bruno | 2009-09-25 18:58:23 +0200

  • Improving ssh support at restore time by providing a shadow file


r3489@localhost (orig r2426): bruno | 2009-09-25 19:42:09 +0200

  • Attempt to stay backward compatible without protocol for -n option


r3490@localhost (orig r2427): bruno | 2009-09-28 02:08:06 +0200
Avoids null param for excludes_devs for mindi call


r3492@localhost (orig r2429): bruno | 2009-09-28 11:46:16 +0200

  • Simplify GetInitrdFilesystemToUse which doesn't need to detect everything, but just know if it's initramfs (new mode) or a compressed FS ext2/3 (older mode) as initrd is anyway re-made by mindi. Should fix #353


r3494@localhost (orig r2431): bruno | 2009-09-28 13:16:18 +0200

  • Use only the AWK veriable everywhere and not the awk command


r3495@localhost (orig r2432): bruno | 2009-09-28 14:16:31 +0200
Warning emited in case of duplicate mountpoints or devices in fstab found


r3496@localhost (orig r2433): bruno | 2009-09-28 15:55:17 +0200
ssh in the restore env needs some dlopened libs (libnss_compat|files)


r3497@localhost (orig r2434): bruno | 2009-09-28 16:33:14 +0200
Compiler warning fixed


r3498@localhost (orig r2435): bruno | 2009-09-28 17:55:26 +0200
Improve user management for NetFS cases


r3499@localhost (orig r2436): bruno | 2009-09-29 01:48:32 +0200

  • Improve deplist.d/* files
  • adds libnss for ssh support in boot disk
  • Solve a memory management issue in DSF module (strtok => mr_strtok)
  • DSF now also supports partitions in addition to full disks
  • Adds debug in open_and_list_dir


r3500@localhost (orig r2437): bruno | 2009-09-29 10:41:56 +0200

  • Fix udev support in init for Mandriva 2009.1 (udevadm settle is blocking)


r3501@localhost (orig r2438): bruno | 2009-09-29 14:41:36 +0200

  • Improvements on sshfs/ssh management in restore mode
  • Include now all minimal requirements for sshfs


r3502@localhost (orig r2439): bruno | 2009-09-29 18:46:08 +0200

  • Avoids error message if some ssh conf files do not exist


r3503@localhost (orig r2440): bruno | 2009-09-29 18:57:13 +0200

  • Avoids comment analysis in the new code handling deplist.d


r3504@localhost (orig r2441): bruno | 2009-09-29 19:34:34 +0200

  • fuse device is needed at restore time for sshfs


r3505@localhost (orig r2442): bruno | 2009-09-29 20:02:36 +0200

  • Improves udev timeout handling


r3506@localhost (orig r2443): bruno | 2009-09-29 20:43:38 +0200

  • priority given to env var for tmpdir
  • fuse FS excluded from tmpdir computation


r3518@localhost (orig r2447): bruno | 2009-10-04 01:58:08 +0200

  • Iprove USB log in case of error by adding the conf file


r3519@localhost (orig r2448): bruno | 2009-10-05 11:06:13 +0200


r3520@localhost (orig r2449): bruno | 2009-10-06 01:10:35 +0200

  • Adds support for grub2 conf file grub.cfg in addition to menu.lst


r3521@localhost (orig r2450): bruno | 2009-10-06 01:24:02 +0200

  • Fix a mr_asprintf usage without & causing a seg fault.


r3523@localhost (orig r2452): bruno | 2009-10-06 12:47:56 +0200
CIFS mounts shouldn't be part of the mountlist analysis (should help solving #288)


r3524@localhost (orig r2453): bruno | 2009-10-07 10:17:03 +0200

  • Fix a bug in handling of -E option with real devices (bad report in function mr_make_devlist_from_pathlist of the test between -E and -I)


r3525@localhost (orig r2454): bruno | 2009-10-07 10:19:02 +0200

  • Fix an error in the test for grub conf files (or used instead of and)


r3526@localhost (orig r2455): bruno | 2009-10-07 16:14:59 +0200
afio is under /bin on Debian


r3527@localhost (orig r2456): bruno | 2009-10-07 17:31:26 +0200

  • Adds support for libcrc32c (needed by bnx2x)


r3532@localhost (orig r2457): bruno | 2009-10-09 13:33:44 +0200

  • Apply path from Matthew Cline (matt_at_nightrealms.com) in order to fix #359


r3533@localhost (orig r2458): bruno | 2009-10-09 13:41:02 +0200
Adds a conf file example for mindi and fix #360


r3535@localhost (orig r2459): bruno | 2009-10-09 15:13:01 +0200
MOde of conf file


r3546@localhost (orig r2461): bruno | 2009-10-14 01:12:24 +0200

  • umount freshly created VFAT partition on USB key as Ubunu has an automounter mounting it as soon as created (Steffen Neumann sneumann_at_ipb-halle.de)


r3566@localhost (orig r2463): bruno | 2009-10-26 01:34:16 +0100

  • Reset an error counter before blanking a DVD to avoid always returning an error (Vincent Raman vincent.raman_at_macqel.eu)


r3567@localhost (orig r2464): bruno | 2009-10-26 13:57:14 +0100
bzip2 is under /bin on Debian


r3568@localhost (orig r2465): bruno | 2009-10-28 01:46:30 +0100
some distro hold lvm commands under /usr/sbin


r3595@localhost (orig r2469): bruno | 2009-11-10 12:22:10 +0100
/dev/shm is now part of the default exclude list


r3596@localhost (orig r2470): bruno | 2009-11-10 12:32:40 +0100
Remove useless pb_log and MONDO_TRACEFILE


r3597@localhost (orig r2471): bruno | 2009-11-10 12:57:58 +0100
Improve analysis of kernel modules by printing whether it's a live or extra module which has not been found (Matthew Cline) as reported in #362


r3598@localhost (orig r2472): bruno | 2009-11-10 13:21:46 +0100

  • Default to DVD size when in iso or netfs mode


r3599@localhost (orig r2473): bruno | 2009-11-10 14:13:10 +0100

  • Fix #363 where exclude_paths was extended up to memory limit dumping core


r3600@localhost (orig r2474): bruno | 2009-11-10 14:31:14 +0100

  • Update deplist for Debian support


r3602@localhost (orig r2476): bruno | 2009-11-11 02:44:42 +0100

  • small improvement for loging in USB case


r3603@localhost (orig r2477): bruno | 2009-11-11 13:29:27 +0100

  • Adds a nolvm boot option at restore time


r3604@localhost (orig r2478): bruno | 2009-11-11 19:54:51 +0100

  • Fix #367 - the for loop doesn't make any test now, as it was computed before entering the loop, leading to an error, and was also made inside the loop anyway.


r3605@localhost (orig r2479): bruno | 2009-11-12 00:32:45 +0100

  • Add support for diskdumplib driver useful for RHEL 3 and IBM xseries 336


r3606@localhost (orig r2480): bruno | 2009-11-12 01:09:40 +0100

  • If using nolvm, mondorestore should also not nalyze and handle i-want-my-lvm


r3608@localhost (orig r2482): bruno | 2009-11-14 12:54:11 +0100
Fix bunzip2 on debian as well


r3610@localhost (orig r2484): bruno | 2009-11-15 00:44:19 +0100

  • Adds support for variable serial port console, with defalut to /dev/ttyS0, and a boot param to change it with serial=/dev/ttySx


r3615@localhost (orig r2485): bruno | 2009-11-15 01:34:33 +0100

r3614@localhost: bruno | 2009-11-15 01:34:12 +0100
Adds a space in exclude paths


r3623@localhost (orig r2487): bruno | 2009-11-18 20:41:40 +0100

r3620@localhost: bruno | 2009-11-18 10:31:36 +0100

  • Only link /dev/tty to serial port when there is indeed a serial port. If not breaks mondorestore on normal console


r3631@localhost (orig r2490): bruno | 2009-11-24 01:48:29 +0100
Put news below in the main page to make it more readable


r3648@localhost (orig r2492): bruno | 2009-11-25 23:50:13 +0100

r3647@localhost: bruno | 2009-11-25 23:49:11 +0100

  • Add warning for -f and SW Raid as in 2.2.10


r3650@localhost (orig r2493): bruno | 2009-11-26 00:19:52 +0100

r3649@localhost: bruno | 2009-11-26 00:18:27 +0100

  • Addition of the german translation made by Magnus Rasche (Magnus.rasche_at_gmx.de) and Website inclusion


r3652@localhost (orig r2495): bruno | 2009-11-27 15:55:55 +0100
cosmetic display fix
r3659@localhost (orig r2498): bruno | 2009-12-05 17:53:03 +0100
nfsopt restore boot time option added to support custom mount options for network restore


r3684@localhost (orig r2501): bruno | 2009-12-17 00:35:08 +0100
Fix #375 mondo will segfault if the partition in sensibly_set_tmpdir_and_scratchdir() is read-only (cylau)


r3685@localhost (orig r2502): bruno | 2009-12-17 01:02:47 +0100

  • Fix an issue in the function listing kernel modules when not found


r3686@localhost (orig r2503): bruno | 2009-12-17 01:15:01 +0100
Adds scsi_dump_register to mindi SCSI_MODS for RHEL3 + IBM servers


r3701@localhost (orig r2504): bruno | 2009-12-23 02:24:33 +0100

  • Addition of the Lab for Mondorescue


r3702@localhost (orig r2505): bruno | 2009-12-23 02:41:17 +0100
Web site update for Lab MondoRescue delivery


r3706@localhost (orig r2506): bruno | 2010-01-04 11:31:53 +0100

  • Fix a bug when isodir is / only when splitting it in iso_path and iso_mnt


r3707@localhost (orig r2507): bruno | 2010-01-04 13:22:49 +0100

  • Fix #377: Segfault in pause_and_ask_for_cdr() (ggeens)


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