#!/bin/sh
ISOLX_DIR="isolinux"
INST_DIR="/_config/backup"
cd $INST_DIR

if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
   echo "Syntax: vdrbkp.sh [-i] [file]"
   echo "               -i   : Create universal install image (not machine specific)"
   echo "               file : Name of image (Default: /mnt/hda5/vdr.iso)"
   echo "                      -n for no image file creation"
   exit
fi
if [ "$1" = "-i" ] ; then
   ISO=$2
else
   ISO=$1
fi
rm -rf /mnt/hda5/g2v*tar.bz2

VERSION=$(head -n 1 README | cut -f 1,2 -d "/")
DATE=$(date +"%d.%B %Y")

sed -i $ISOLX_DIR/message.txt -e "s#Gen2VDR.*#$VERSION/ $DATE#"
sed -i $ISOLX_DIR/README -e "s#Gen2VDR / .*#$VERSION/ $DATE#"


sh $INST_DIR/mkbase.sh  2>&1 | tee /tmp/mkbase.log
sh $INST_DIR/mkadd.sh  2>&1 | tee /tmp/mkadd.log
sh $INST_DIR/mkkrnl.sh  2>&1 | tee /tmp/mkkrnl.log
sh $INST_DIR/mkcfg.sh $1 2>&1 | tee /tmp/mkcfg.log

DT=$(date +%m%d)
$(touch -t ${DT}1200 $ISOLX_DIR/README $ISOLX_DIR/HISTORY setup.sh autorun /mnt/hda5/g2v*)

if [ "$ISO" != "-n" ] ; then
   sh $INST_DIR/mkiso.sh $ISO 2>&1 | tee /tmp/mkiso.log
fi

svdrpsend.pl "MESG Backup ist fertig ! ( /mnt/hda5/vdr.iso )"
