#!/bin/sh


LOGFILE=/tmp/mondo-restore.log



if [ "$#" -ne "1" ] ; then
    echo "make-me-bootable <fname>"
    exit 1
fi

for i in `cat $1 | tr -s '\t' ' ' | cut -d' ' -f1 | grep -v "/dev/fd" | grep -v "none" | grep -v "#"` ; do
    mountpt=`cat $1 | grep "$i " | tr -s '\t' ' ' | cut -d' ' -f2`
    format=`cat $1 | grep "$i " | tr -s '\t' ' ' | cut -d' ' -f3`
    echo "i=$i; mountpt=$mountpt"
    drive=/dev/`basename "$i" | sed s/[0-9]// | sed s/[0-9]//`
    partno=`basename "$i" | tr -s 'a-z' ' ' | cut -d' ' -f2`
    if [ "$mountpt" = "/" ] || [ "$mountpt" = "/boot" ] || [ "$format" = "vfat" ] ; then
        LogIt "Making $i bootable (drive=$drive, partno=$partno)"
        echo -e -n "a\n$partno\nw\n" | fdisk $drive >> $LOGFILE 2>> $LOGFILE
    fi
done
exit 0
