post_install()
{
	if ! grep -q '^clamav:' /etc/group ; then
		/usr/sbin/groupadd -g 26 clamav
	fi
	if ! grep -q '^clamav:' /etc/passwd ; then
                /usr/sbin/useradd -u 26 -g 26 -s /bin/false -c "Clam AntiVirus" -d /var/lib/clamav clamav
	fi
}

pre_remove()
{
	/usr/sbin/userdel -r clamav >/dev/null 2>&1
	/usr/sbin/groupdel clamav >/dev/null 2>&1
	rm -fr /var/lib/clamav 2>&1
}


pre_upgrade()
{
	post_install
}

post_upgrade()
{

	## move files to new location
	if [ -e /etc/freshclam.conf ]; then
		if [ -d /etc/clamav ]; then
			/usr/bin/mv /etc/freshclam.conf /etc/clamav/freshclam.conf
		fi
	fi

	if [ -e /etc/clamd.conf ]; then
                if [ -d /etc/clamav ]; then
                        /usr/bin/mv /etc/clamd.conf /etc/clamav/clamd.conf
                fi
        fi

}

op=$1
shift

$op $*
