#!/bin/sh -e 

if [ ! -d /var/lib/dhelp ]; then
  mkdir -p /var/lib/dhelp
  chown www-data.www-data /var/lib/dhelp
fi

if [ -f /var/lib/dhelp/dbase ]; then
  rm -f /var/lib/dhelp/dbase
fi

if [ -x /usr/sbin/dhelp_parse ]; then
  echo -n "Building HTML tree ..."
  /usr/sbin/dhelp_parse -r
  echo " done"
fi

if [ -x /etc/cron.weekly/dhelp -a -x /usr/bin/glimpseindex ]; then
  echo "Starting glimpseindex ..."
  /etc/cron.weekly/dhelp 2>/dev/null >/dev/null &
fi

echo "run dhelp to read documentation or browse "
echo "http://localhost/doc/HTML/index.html"
