Changeset 1448


Ignore:
Timestamp:
May 18, 2007, 2:51:49 AM (12 years ago)
Author:
bruno
Message:

Fix #159 (pb with readlink and grub.conf)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.4/mondo/src/restore-scripts/mondo/stabgrub-me

    r1315 r1448  
    88QuitIfNotFound() {
    99    if [ ! -f "$1" ] ; then
    10     LogIt "(stabgrub-me) Where's $1? I cannot continue." 1
    11     exit 1
     10        LogIt "(stabgrub-me) Where's $1? I cannot continue." 1
     11        exit 1
    1212    fi
    1313}
     
    2929        # we run this outside the chroot.
    3030        if [ -L "$old_grubconf" ] ; then
    31             old_grubconf=/mnt/RESTORING/etc/`readlink "$old_grubconf"`
     31            l=`readlink "$old_grubconf"`
     32            if [ _"`echo $l | cut -c1`" = _"/" ]; then
     33                # If readlink gives an absolute path it's related to the chroot
     34                old_grubconf=/mnt/RESTORING/$l
     35            else
     36                # If readlink gives a relative path, it's in the same dir
     37                old_grubconf=/mnt/RESTORING/etc/$l
     38            fi
    3239        fi 
    3340        return 0
     
    4148    where_they_live=""
    4249    for curr_fstab in $fstab_list ; do
    43     curr_dir=`echo $curr_fstab | gawk '{i=index($0,"/fstab");print substr($0,0,i-1);}'`
    44     resA=$?
    45     curr_inetd=`find $curr_dir -name inetd.conf | grep -v "linuxconf"`
    46     resB=$?
    47     if [ "$resA" -eq "0" ] ; then
    48         if [ "$where_they_live" != "" ] ; then
    49         LogIt "Two directories found! One is $where_they_live, the other $curr_dir" 1
    50         LogIt "I don't know which to choose. I'll abort the search." 1
    51         return 1
    52         fi
    53         where_they_live=$curr_dir
    54     fi
     50        curr_dir=`echo $curr_fstab | gawk '{i=index($0,"/fstab");print substr($0,0,i-1);}'`
     51        resA=$?
     52        curr_inetd=`find $curr_dir -name inetd.conf | grep -v "linuxconf"`
     53        resB=$?
     54        if [ "$resA" -eq "0" ] ; then
     55            if [ "$where_they_live" != "" ] ; then
     56                LogIt "Two directories found! One is $where_they_live, the other $curr_dir" 1
     57                LogIt "I don't know which to choose. I'll abort the search." 1
     58                return 1
     59            fi
     60            where_they_live=$curr_dir
     61        fi
    5562    done
    5663    if [ "$where_they_live" = "" ] ; then
    57     LogIt "Cannot find any folder which holds fstab _and_ inetd.conf" 1
    58     return 1
     64        LogIt "Cannot find any folder which holds fstab _and_ inetd.conf" 1
     65        return 1
    5966    fi
    6067    old_grubconf=$where_they_live/grub.conf
     
    7178    LogIt "Backing up original files before modifying them..." 2
    7279    for i in $old_grubconf $old_fstab ; do
    73     LogIt "Backing up $i"
     80        LogIt "Backing up $i"
    7481        [ -e "$i" ] && [ ! -e "$i.$BEFORE" ] && cp -f $i $i.$BEFORE
    7582    done
     
    8289    cp -f $old_fstab /tmp/fstab.ugly
    8390    for i in $old_grubconf $old_fstab ; do
    84     LogIt "Restoring $i"
    85     [ -f "$i.$BEFORE" ] && cp -f $i.$BEFORE $i
     91        LogIt "Restoring $i"
     92        [ -f "$i.$BEFORE" ] && cp -f $i.$BEFORE $i
    8693    done
    8794}
     
    145152    fi
    146153    if [ "$outval" -ne "0" ] ; then
    147     LogIt "Modifications (copying) failed. Restoring from backups." 3
    148     RestoreBackups
     154        LogIt "Modifications (copying) failed. Restoring from backups." 3
     155        RestoreBackups
    149156    else
    150     LogIt "Fstab modified ok." 2
     157        LogIt "Fstab modified ok." 2
    151158    fi
    152159    cd /mnt/RESTORING
     
    159166    if [ "$grub_res" -ne "0" ] ; then
    160167        LogIt "grub-install failed. Running grub-MR..."
    161     chroot /mnt/RESTORING grub-install '(hd0)' >> $LOGFILE 2>> $LOGFILE
     168        chroot /mnt/RESTORING grub-install '(hd0)' >> $LOGFILE 2>> $LOGFILE
    162169        grub_res=$?
    163170    fi
Note: See TracChangeset for help on using the changeset viewer.