#!/bin/sh
#
# $Id: hack-cfg-if-necessary 2603 2010-03-22 12:56:30Z bruno $
#

if ! mount | grep cdrom ; then 
    LogIt "CD-ROM is not mounted. Darn."
    exit 0
fi

if ! ls /mnt/cdrom/archives/* > /dev/null 2> /dev/null ; then
    LogIt "Can't find /mnt/cdrom/archives; darn."
    exit 0
fi

LogIt "OK, we've found /mnt/cdrom/archives/*; great."

if [ -f $MINDI_CACHE/mondorestore.cfg ]; then
	grep -q "backup-media-type iso" $MINDI_CACHE/mondorestore.cfg 2> /dev/null
	if [ $? -ne 0 ] ; then
    	LogIt "Config file is fine, BTW."
    	exit 0
	fi
	LogIt "Re-jigging mondorestore.cfg because you backed up to ISOs and then burned them to CDs" 1
	sed -i 's/backup-media-type iso/backup-media-type cdr/' $MINDI_CACHE/mondorestore.cfg
	LogIt "Done re-jigging. Yay."
fi
exit 0
