#!/bin/sh

help() {
  echo "Usage:"
  echo "  update-ifo.sh <file>.ifo"
}

if [ x$1 = x ]; then
  help
  exit 1
fi

name=$1
name=${name%.ifo}
echo $1
echo $name

if [ $1 = $name ]; then
  echo "Error: file must have .ifo extension."
  exit 1
fi

if [ ! -e $1 ]; then
  echo "Error: file $1 not exist."
fi

date=`date +%Y-%m-%d`

echo "author=Oleksandr Gavenko" >>$1
echo "email=gavenkoa@gmail.com" >>$1
echo "website=http://gavenkoa.blogspot.com" >>$1
echo "date=$date" >>$1
if [ -e $name.descr ]; then
  echo "description="`head -n 1 $name.descr` >>$1
fi