| 1 | #!/bin/sh
|
|---|
| 2 | #
|
|---|
| 3 | # $Id: post-init 273 2006-01-03 15:09:12Z bcornec $
|
|---|
| 4 | #
|
|---|
| 5 | #------------------------------------------------------------
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | call_multifunc_cd() {
|
|---|
| 9 | echo "Hooray! I'm a multi-function CD. Oo! Oo!"
|
|---|
| 10 | mount | grep cdrom > /dev/null 2> /dev/null || mount /dev/cdrom /mnt/cdrom >> $LOGFILE 2>> $LOGFILE
|
|---|
| 11 | for i in bin lib usr sbin ; do
|
|---|
| 12 | echo -en "\rNormalizing $i ... "
|
|---|
| 13 | if [ -d "/mnt/cdrom/$i" ] ; then
|
|---|
| 14 | for j in `find /mnt/cdrom/$i` ; do
|
|---|
| 15 | k=`echo "$j" | awk -F '/' '{for(i=4; i<=NF;i++) {printf("/%s",$i);};printf "\n"; }'`
|
|---|
| 16 | mkdir -p $k
|
|---|
| 17 | rmdir $k 2> /dev/null
|
|---|
| 18 | ln -sf $j $k
|
|---|
| 19 | done
|
|---|
| 20 | fi
|
|---|
| 21 | done
|
|---|
| 22 | echo -en "\rNormalized softlinks OK.\n"
|
|---|
| 23 | echo -en "Shall I run a CPU burn-in test in the background (y/n) ?"
|
|---|
| 24 | read line
|
|---|
| 25 | if [ "$line" = "y" ] || [ "$line" = "Y" ] || [ "$line" = "yes" ] || [ "$line" = "YES" ] ; then
|
|---|
| 26 | for i in `find /usr/local/sbin/burn*` ; do basename $i ; done
|
|---|
| 27 | echo -en "...Which one ?"
|
|---|
| 28 | read line
|
|---|
| 29 | $i || echo $? &
|
|---|
| 30 | fi
|
|---|
| 31 | for i in lucifer mprime ; do
|
|---|
| 32 | # tiobench ide-smart
|
|---|
| 33 | if which $i > /dev/null > /dev/null ; then
|
|---|
| 34 | echo -en "Shall I run $i (y/n) ?"
|
|---|
| 35 | read line
|
|---|
| 36 | if [ "$line" = "y" ] || [ "$line" = "Y" ] || [ "$line" = "yes" ] || [ "$line" = "YES" ] ; then
|
|---|
| 37 | echo "Running $i ..."
|
|---|
| 38 | $i || echo "Warning - $i returned an error"
|
|---|
| 39 | fi
|
|---|
| 40 | fi
|
|---|
| 41 | done
|
|---|
| 42 |
|
|---|
| 43 | # echo "Running bash."
|
|---|
| 44 | # busybox sh
|
|---|
| 45 | echo "Exiting multi-function CD thingy. Please reboot immediately."
|
|---|
| 46 | exit 0
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 | # ---------------------------- main ----------------------------
|
|---|
| 51 |
|
|---|
| 52 | sleep 1
|
|---|
| 53 |
|
|---|
| 54 | if [ -e "/MULTIFUNC" ] ; then
|
|---|
| 55 | LogIt "I think this is a multifunc CD but I'm not going there today."
|
|---|
| 56 | # call_multifunc_cd
|
|---|
| 57 | fi
|
|---|
| 58 |
|
|---|
| 59 | cat /tmp/mountlist.txt >> /tmp/mondo-restore.log
|
|---|
| 60 |
|
|---|
| 61 | iso=`grep iso /proc/cmdline`
|
|---|
| 62 | nuke=`grep nuke /proc/cmdline`
|
|---|
| 63 | if [ "$nuke" = "" ] ; then
|
|---|
| 64 | nuke=`grep -i "RESTORE " /proc/cmdline`
|
|---|
| 65 | fi
|
|---|
| 66 | expert=`grep expert /proc/cmdline`
|
|---|
| 67 | compare=`grep compare /proc/cmdline`
|
|---|
| 68 | interactive=`grep interactive /proc/cmdline`
|
|---|
| 69 | [ "$interactive" ] && expert=""; # in case 'expert' crops up somewhere
|
|---|
| 70 | if which mondorestore > /dev/null 2> /dev/null ; then
|
|---|
| 71 | LogIt "mondorestore found; cool..."
|
|---|
| 72 | else
|
|---|
| 73 | if [ "$iso$nuke$compare$interactive" != "" ] ; then
|
|---|
| 74 | LogIt "FYI, this CD was made by Mindi, not Mondo." 1
|
|---|
| 75 | exit 0
|
|---|
| 76 |
|
|---|
| 77 | else
|
|---|
| 78 | LogIt "Mindi-Linux has finished booting."
|
|---|
| 79 | fi
|
|---|
| 80 | fi
|
|---|
| 81 |
|
|---|
| 82 | if [ -h "`which mondorestore`" ] ; then
|
|---|
| 83 | LogIt "Turning mondorestore from a hyperlink into an executable"
|
|---|
| 84 | cat `which mondorestore` > /usr/bin/MR
|
|---|
| 85 | # in case there's more than one instance :)
|
|---|
| 86 | rm -f `which mondorestore 2> /dev/null`
|
|---|
| 87 | rm -f `which mondorestore 2> /dev/null`
|
|---|
| 88 | rm -f `which mondorestore 2> /dev/null`
|
|---|
| 89 | rm -f `which mondorestore 2> /dev/null`
|
|---|
| 90 | mv /usr/bin/MR /usr/bin/mondorestore
|
|---|
| 91 | chmod +x /usr/bin/mondorestore
|
|---|
| 92 | fi
|
|---|
| 93 |
|
|---|
| 94 | if which bootstrap > /dev/null 2> /dev/null ; then
|
|---|
| 95 | LogIt "Calling bootstrap script" 1
|
|---|
| 96 | bootstrap
|
|---|
| 97 | fi
|
|---|
| 98 |
|
|---|
| 99 | for i in mount-me unmount-me mondorestore ; do
|
|---|
| 100 | if which $i > /dev/null 2> /dev/null ; then
|
|---|
| 101 | LogIt "$i found"
|
|---|
| 102 | else
|
|---|
| 103 | LogIt "Warning - $i not found on ramdisk."
|
|---|
| 104 | fi
|
|---|
| 105 | done
|
|---|
| 106 |
|
|---|
| 107 | if [ "$compare" ] ; then
|
|---|
| 108 | LogIt "------------------COMPARE MODE-----------------" 1
|
|---|
| 109 | mondorestore --compare
|
|---|
| 110 | elif [ "$nuke" ] ; then
|
|---|
| 111 | LogIt "-------------------NUKE MODE-------------------" 1
|
|---|
| 112 | mondorestore --nuke
|
|---|
| 113 | elif [ "$expert" ] ; then
|
|---|
| 114 | if [ "`grep tapedev /tmp/mondo-restore.cfg`" ] ; then
|
|---|
| 115 | LogIt "-------------------TAPE MODE-------------------" 1
|
|---|
| 116 | loc=`which mondorestore 2> /dev/null`
|
|---|
| 117 | if [ "$loc" = "" ] ; then
|
|---|
| 118 | LogIt "I presume you backed up with Mindi, not Mondo." 1
|
|---|
| 119 | else
|
|---|
| 120 | LogIt "Tape Mode -- calling mondorestore..."
|
|---|
| 121 | if [ "$nuke" ] ; then
|
|---|
| 122 | mondorestore --nuke
|
|---|
| 123 | else
|
|---|
| 124 | mondorestore; # MR will detect & access the tape
|
|---|
| 125 | fi
|
|---|
| 126 | fi
|
|---|
| 127 | elif [ "`grep using-cdstream /tmp/mondo-restore.cfg`" ] ; then
|
|---|
| 128 | LogIt "------------------CDSTREAM MODE------------------" 1
|
|---|
| 129 | loc=`which mondorestore 2> /dev/null`
|
|---|
| 130 | if [ "$loc" = "" ] ; then
|
|---|
| 131 | LogIt "I presume you backed up with Mindi, not Mondo." 1
|
|---|
| 132 | else
|
|---|
| 133 | LogIt "Cdstream Mode -- calling mondorestore..."
|
|---|
| 134 | if [ "$nuke" ] ; then
|
|---|
| 135 | mondorestore --nuke
|
|---|
| 136 | else
|
|---|
| 137 | mondorestore; # MR will detect & access the cdstream
|
|---|
| 138 | fi
|
|---|
| 139 | fi
|
|---|
| 140 | else
|
|---|
| 141 | LogIt "------------------EXPERT MODE------------------" 1
|
|---|
| 142 | LogIt "You do all the work. :-)" 1
|
|---|
| 143 | if which mondorestore > /dev/null 2> /dev/null ; then
|
|---|
| 144 | LogIt "Type 'mondorestore' to begin the restore/compare process." 1
|
|---|
| 145 | loc=`which ISO 2> /dev/null`
|
|---|
| 146 | fi
|
|---|
| 147 | fi
|
|---|
| 148 | else
|
|---|
| 149 | LogIt "------------------INTERACTIVE------------------" 1
|
|---|
| 150 | mondorestore --interactive
|
|---|
| 151 | fi
|
|---|
| 152 |
|
|---|
| 153 | [ -e "/tmp/DO-MBR-PLEASE" ] && LogIt "PLEASE RUN 'mondorestore --mbr' NOW TO INITIALIZE YOUR BOOT SECTOR." 1
|
|---|
| 154 |
|
|---|
| 155 | exit 0
|
|---|