source: branches/3.0/mindi/rootfs/sbin/post-init

Last change on this file was 3319, checked in by Bruno Cornec, 6 years ago
  • Backport most mindi modifications done in the 3.2 branch into 3.0 in order to have soon a 2.1.8 version which is probably Fedora 17+ compatible (all modifications up to 2014-10-16)
  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1#!/bin/sh
2#
3# $Id: post-init 3319 2014-12-01 22:35:39Z bruno $
4#
5#------------------------------------------------------------
6
7if [ -f "/tmp/mountlist.txt" ]; then
8    echo "Here is my /tmp/mountlist.txt" >> $LOGFILE
9    cat /tmp/mountlist.txt >> $LOGFILE
10fi
11
12iso=`grep iso /proc/cmdline`
13nuke=`grep nuke /proc/cmdline`
14if [ "$nuke" = "" ] ; then
15    nuke=`grep -i "RESTORE " /proc/cmdline`
16fi
17expert=`grep expert /proc/cmdline`
18compare=`grep compare /proc/cmdline`
19interactive=`grep interactive /proc/cmdline`
20pxe=`grep pxe /proc/cmdline`
21[ "$interactive" ]  && expert=""; # in case 'expert' crops up somewhere
22if which mondorestore > /dev/null 2> /dev/null ; then
23    LogIt "mondorestore found; cool..."
24else
25    if [ "$iso$nuke$compare$interactive$pxe" != "" ] ; then
26        LogIt "The mondorestore command was not found on your backup media" 1
27        LogIt "It may mean your device is not seen correctly." 1
28        LogIt "Check driver list and error messages." 1
29        exit 0
30    else
31        LogIt "Mindi-Linux has finished booting."
32    fi
33fi
34
35if [ -h "`which mondorestore`" ] ; then
36    LogIt "Turning mondorestore from a hyperlink into an executable"
37    cat `which mondorestore` > /usr/bin/MR
38# in case there's more than one instance :)
39    rm -f `which mondorestore 2> /dev/null`
40    rm -f `which mondorestore 2> /dev/null`
41    rm -f `which mondorestore 2> /dev/null`
42    rm -f `which mondorestore 2> /dev/null`
43    mv /usr/bin/MR /usr/bin/mondorestore
44    chmod +x /usr/bin/mondorestore
45fi
46
47if which bootstrap > /dev/null 2> /dev/null ; then
48    LogIt "Calling bootstrap script" 1
49    bootstrap
50fi
51
52for i in mount-me unmount-me mondorestore ; do
53    if which $i > /dev/null 2> /dev/null ; then
54        LogIt "$i found"
55    else
56        LogIt "Warning - $i not found on ramdisk."
57    fi
58done
59
60mondoopt=""
61if [ "`grep -i 'obdr ' /tmp/mondo-restore.cfg 2> /dev/null`" ]; then
62    mondoopt="$mondoopt -o -d $TAPEDEV"
63fi
64
65if [ "`grep -i 'debug' /proc/cmdline`" ]; then
66    mondoopt="$mondoopt -K 99"
67fi
68
69# Now suppress msg redirection to avoid poluting log file
70exec 2>&4 >&5 4>&- 5>&-
71
72if [ "$compare" ] ; then
73    LogIt "------------------COMPARE MODE-----------------" 1
74    mondorestore $mondoopt -Z compare
75elif [ "$nuke" ] ; then
76    LogIt "-------------------NUKE MODE-------------------" 1
77    mondorestore $mondoopt -Z nuke
78elif [ "$expert" ] ; then
79    if [ "`grep tapedev /tmp/mondo-restore.cfg 2> /dev/null`" ] ; then
80    LogIt "-------------------TAPE MODE-------------------" 1
81    loc=`which mondorestore 2> /dev/null`
82    if [ "$loc" = "" ] ; then
83        LogIt "I presume you backed up with Mindi, not Mondo." 1
84    else
85        LogIt "Tape Mode -- calling mondorestore..."
86            if [ "$nuke" ] ; then
87                mondorestore $mondoopt -Z nuke
88            else
89                mondorestore $mondoopt; # MR will detect & access the tape
90            fi
91    fi
92    elif [ "`grep using-cdstream /tmp/mondo-restore.cfg 2> /dev/null`" ] ; then
93        LogIt "------------------CDSTREAM MODE------------------" 1
94        loc=`which mondorestore 2> /dev/null`
95        if [ "$loc" = "" ] ; then
96            LogIt "I presume you backed up with Mindi, not Mondo." 1
97        else
98            LogIt "Cdstream Mode -- calling mondorestore..."
99            if [ "$nuke" ] ; then
100                mondorestore -Z nuke $mondoopt
101            else
102                mondorestore $mondoopt; # MR will detect & access the cdstream
103            fi
104        fi
105    else
106        LogIt "------------------EXPERT MODE------------------" 1
107        LogIt "You do all the work. :-)" 1
108        if which mondorestore > /dev/null 2> /dev/null ; then
109            LogIt "Type 'mondorestore' to begin the restore/compare process." 1
110        fi
111    fi
112else
113    LogIt "------------------INTERACTIVE------------------" 1
114    mondorestore -Z interactive $mondoopt
115fi
116
117[ -e "/tmp/DO-MBR-PLEASE" ] && LogIt "PLEASE RUN 'mondorestore -Z mbr' NOW TO INITIALIZE YOUR BOOT SECTOR." 1
118
119exit 0
Note: See TracBrowser for help on using the repository browser.