source: MondoRescue/trunk/mondo/mondo/restore-scripts/mondo/make-me-bootable@ 588

Last change on this file since 588 was 588, checked in by bcornec, 18 years ago

merge -r 560:587 $SVN_M/branches/stable

  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 1.5 KB
Line 
1#!/bin/sh
2
3
4LOGFILE=/tmp/mondo-restore.log
5
6
7
8if [ "$#" -ne "1" ] && [ "$#" -ne "2" ] ; then
9 echo "make-me-bootable <fname> (dummy)"
10 exit 1
11fi
12
13dummy=$2
14boot_drv=""
15boot_part=""
16root_drv=""
17root_part=""
18
19HAVE_ACTIVE="false"
20for i in `cat $1 | tr -s '\t' ' ' | cut -d' ' -f1 | grep -v "/dev/fd" | grep -v "none" | grep -v "#"` ; do
21 mountpt=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f2`
22 format=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f3`
23 drive=`echo $i | sed -e 's/[0-9]*$//' -e 's/\([0-9]\)p$/\1/'`
24 partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
25
26 if [ "$HAVE_ACTIVE" = "false" ] && [ "`parted2fdisk -l $drive | tr -s '\t' ' ' | grep "$i " | grep -v "*"`" ] ; then
27 if [ "$mountpt" = "/" ] ; then
28 root_drv=$drive
29 root_part=$partno
30 elif [ "$mountpt" = "/boot" ] ; then
31 boot_drv=$drive
32 boot_part=$partno
33 fi
34 fi
35done
36
37if [ "$boot_drv" ] ; then
38 drive=$boot_drv
39 partno=$boot_part
40elif [ "$root_drv" ] ; then
41 drive=$root_drv
42 partno=$root_part
43else
44 driveline=`grep -w /boot $1`
45 [ ! "$driveline" ] && driveline=`grep -w / $1`
46 partno=`echo "$driveline" | cut -d' ' -f1 | awk -F "[a-z]" '{print $NF;}'`
47# echo "driveline=$driveline --> partno=$partno"
48fi
49
50if [ "$drive" ] ; then
51 if [ "$dummy" != "" ] ; then
52 if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
53 partno="1"
54 fi
55 echo "$partno"
56 else
57 echo -en "a\n$partno\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
58 fi
59fi
60exit 0
Note: See TracBrowser for help on using the repository browser.