source: MondoRescue/branches/2.2.5/mondo/src/restore-scripts/mondo/stabelilo-me@ 1563

Last change on this file since 1563 was 1563, checked in by Bruno Cornec, 17 years ago

Improve ia64 support for SLES

  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 5.0 KB
RevLine 
[1]1#!/bin/sh
2#
3# 2004-03-08: First draft Bruno Cornec <Bruno.Cornec@hp.com>
4#
5
6QuitIfNotFound() {
7 if [ ! -f "$1" ] ; then
8 LogIt "(stabelilo-me) Where's $1? I cannot continue." 1
9 exit 1
10 fi
11}
12
13
14
15
16FindLiloDir() {
17 list=`find / | grep -name elilo.conf`
18}
19
20
21
[1563]22LocateOldElilo() {
23 old_eliloconf=""
24 if [ -f "/mnt/RESTORING/boot/efi/efi/redhat/elilo.conf" ] ; then
25 LogIt "elilo.conf found at /mnt/RESTORING/boot/efi/efi/redhat/elilo.conf" 2
26 old_eliloconf="/mnt/RESTORING/boot/efi/efi/redhat/elilo.conf"
27 return 0
28 elif [ -f "/mnt/RESTORING/boot/efi/efi/SuSE/elilo.conf" ] ; then
29 LogIt "elilo.conf found at /mnt/RESTORING/boot/efi/efi/SuSE/elilo.conf" 2
30 old_eliloconf="/mnt/RESTORING/boot/efi/efi/SuSE/elilo.conf"
31 return 0
32 else
33 LogIt "Looking for elilo.conf. Please wait." 2
34 elilo_list=`find /mnt/RESTORING/boot -name elilo.conf 2> /dev/null`
35 fi
36 where_they_live=""
37 for curr_elilo in $elilo_list ; do
38 curr_dir=`dirname $curr_elilo`
39 if [ "$?" -eq "0" ] ; then
40 if [ "$where_they_live" != "" ] ; then
41 LogIt "Two directories found! One is $where_they_live, the other $curr_dir" 1
42 LogIt "I don't know which to choose. I'll abort the search." 1
43 return 1
44 fi
45 where_they_live=$curr_dir
46 fi
47 done
48 if [ "$where_they_live" = "" ] ; then
49 LogIt "Cannot find any folder which holds elilo.conf" 1
50 return 1
51 fi
52 old_eliloconf=$where_they_live/elilo.conf
53 LogIt "ELILO found." 2
54 return 0
55}
56
[1]57LocateOldFstab() {
58 old_fstab=""
59 if [ -f "/mnt/RESTORING/etc/fstab" ] ; then
60 LogIt "No need for fstab search." 2
[1563]61 old_fstab=/mnt/RESTORING/etc/fstab
62 return 0
[1]63 elif [ -f "/mnt/cdrom/archives/CUCKOO" ] ; then
64 LogIt "Because I'm cuckoo, I'll stop searching." 2
65 return 1
66 else
67 LogIt "Looking for fstab. Please wait." 2
68 fstab_list=`find /mnt/RESTORING -name fstab 2> /dev/null`
69 fi
70 where_they_live=""
71 for curr_fstab in $fstab_list ; do
[1563]72 curr_dir=`echo $curr_fstab | gawk '{i=index($0,"/fstab");print substr($0,0,i-1);}'`
73 resA=$?
74 curr_inetd=`find $curr_dir -name inetd.conf | grep -v "linuxconf"`
75 resB=$?
76 if [ "$resA" -eq "0" ] ; then
77 if [ "$where_they_live" != "" ] ; then
78 LogIt "Two directories found! One is $where_they_live, the other $curr_dir" 1
79 LogIt "I don't know which to choose. I'll abort the search." 1
80 return 1
81 fi
82 where_they_live=$curr_dir
83 fi
[1]84 done
85 if [ "$where_they_live" = "" ] ; then
[1563]86 LogIt "Cannot find any folder which holds fstab _and_ inetd.conf" 1
87 return 1
[1]88 fi
89 old_fstab=$where_they_live/fstab
[1563]90 LogIt "fstab found." 2
[1]91 return 0
92}
93
94
95MakeBackups() {
96 LogIt "Backing up original files before modifying them..." 2
97 for i in $old_eliloconf $old_fstab ; do
98 LogIt "Backing up $i"
99 [ -f "$i" ] && cp $i $i.prehack -f
100 done
101}
102
103
104RestoreBackups() {
105 LogIt "Restoring original versions of modified files..." 2
106 cp -f $old_eliloconf /tmp/elilo.conf.ugly
107 cp -f $old_fstab /tmp/fstab.ugly
108 for i in $old_eliloconf $old_fstab ; do
109 LogIt "Restoring $i"
110 [ -f "$i.prehack" ] && cp $i.prehack $i -f
111 done
112}
113
114
115WhatIsFirstDriveCalled() {
[275]116 cut -d' ' -f1 /tmp/mountlist.txt \
[1]117| sed s/[0-9]// | sed s/[0-9]// \
[275]118| sort -u | head -n 1
[1]119}
120
121
122# --------------------------------- main -------------------------------
123
124LogIt "stabelilo-me --- starting"
125LocateOldFstab
[1563]126LocateOldElilo
[1]127old_mountlist=/tmp/mountlist.original
128new_mountlist=/tmp/mountlist.txt
129QuitIfNotFound $old_mountlist
130QuitIfNotFound $new_mountlist
131QuitIfNotFound $old_fstab
132QuitIfNotFound $old_eliloconf
133LogIt "OK so far: I've found all the files I need." 2
134
135MakeBackups
136
137new_fstab=/mnt/RESTORING/etc/fstab.NEW
138[ ! -e "$new_fstab" ] && new_fstab=/mnt/RESTORING/etc/fstab
139new_eliloconf=/mnt/RESTORING/etc/elilo.conf.NEW
140[ ! -e "$new_eliloconf" ] && new_eliloconf=/mnt/RESTORING/etc/elilo.conf
141
142LogIt "Modifying fstab..." 2
143outval=0
144hack-fstab $old_mountlist $old_fstab $new_mountlist $new_fstab
145res=$?
146if [ "$res" -ne "0" ] ; then
147 echo "Warning - hack-fstab failed"
148 outval=$(($outval+$res))
149fi
150
151LogIt "Modifying elilo.conf. Please wait..." 2
152hack-elilo $old_mountlist $old_fstab $old_liloconf $new_mountlist $new_fstab $new_liloconf
153res=$?
154outval=$(($outval+$res))
155if [ "$outval" -ne "0" ] ; then
156 LogIt "Fstab and/or elilo modifications failed" 3
157# RestoreBackups
158else
159 LogIt "Modifications succeeded." 2
160 LogIt "Copying over $old_fstab" 2
161 cp -f $new_fstab $old_fstab
162 outval=$(($outval+$?))
163 LogIt "Copying over $old_eliloconf" 2
164 cp -f $new_liloconf $old_eliloconf
165 outval=$(($outval+$?))
166 if [ "$outval" -ne "0" ] ; then
167 LogIt "Modifications (copying) failed. Restoring from backups." 3
168 RestoreBackups
169 else
170 LogIt "Fstab and elilo files modified ok." 2
171 fi
172 cd $where_they_live
173 cd ..
174fi
175
176if [ "$outval" -ne "0" ] ; then
177 LogIt "Error(s) occurred during elilo/fstab processing." 3
178 LogIt "Restoring originals." 3
179 RestoreBackups
180else
181 LogIt "/etc/fstab and /etc/elilo.conf were modified ok." 3
182fi
183LogIt "stabelilo-me --- leaving"
184exit $outval
185
186
Note: See TracBrowser for help on using the repository browser.