# arg 1:  the new package version
post_install() {
  if [ ! -d /myth/mythexport ];then
  mkdir /myth/mythexport
  fi
  if [ ! -d /var/run/mythtv ];then
  mkdir /var/run/mythtv
  fi
  if [ ! -d /srv/http/.mythtv ];then
  mkdir /srv/http/.mythtv
  fi
  chown -R mythtv:mythtv /myth/mythexport
	mysql -u root mythconverg < /usr/share/mythtv/mythexport.sql
	ln -s /usr/share/mythtv/mythexport /data/srv/httpd/htdocs
	ln -s /myth/mythexport /usr/share/mythtv/mythexport/video
	ln -s $MYTHHOME/.mythtv/config.xml /srv/http/.mythtv
	chown mythtv:mythtv /var/run/mythtv
	chown -R mythtv:mythtv /etc/mythtv

  gen_light_include.py
  echo "==> Forcing a re-read of lighttpd's configuration file."
  echo ""
    /sbin/sv hup /service/lighttpd

  echo ""
  echo "==> Adding the mythexport service to start the mythexport daemon"
    add_service.sh mythexport
  echo ""
  echo "==> Starting MythExport..."
    /sbin/sv start mythexport

  echo ""
  echo "==> For move information on setup and configuration:"
  echo "==> http://www.linhes.org/bugs/projects/linhes/wiki/HOWTO_Setup_MythExport_for_iPod"
  echo ""

}

post_upgrade() {
  gen_light_include.py
  echo ""
  echo "==> Forcing a re-read of lighttpd's configuration file."
  echo ""
    /sbin/sv hup /service/lighttpd

}

pre_remove() {

  remove_service.sh mythexport

}

post_remove() {
  gen_light_include.py
  echo ""
  echo "==> Forcing re-read of lighttpd's configuration file."
  echo ""
    /sbin/sv hup /service/lighttpd
  rm -fr /data/srv/httpd/htdocs/mythexport
  rm -fr /usr/share/mythtv/mythexport/video
  rm -fr /srv/http/.mythtv/config.xml
}



op=$1
shift
$op $*