#!/bin/sh
set -e

if [ "$1" = "configure" ]; then
	if [ -d /usr/doc -a ! -e /usr/doc/wxd -a -d /usr/share/doc/wxd ]; then
		ln -sf ../share/doc/wxd /usr/doc/wxd
	fi
fi

# Should check for arguments here
grep weatherd /etc/passwd > /dev/null ||\
adduser --system --ingroup dialout --home /var/spool/wxd \
	--gecos "Weather Deamon" weatherd

chown weatherd /usr/share/doc/wxd/examples/ports /etc/wxd/ports
chown weatherd /usr/share/doc/wxd/examples/filter /etc/wxd/filter
chown weatherd /var/log/wxd
chown weatherd /var/spool/wxd
chown weatherd /var/lib/wxd

update-rc.d wxd defaults >/dev/null
/etc/init.d/wxd start
