#!/bin/sh
#
# kTm port by Juzer
#
#       regards to hns & psych
#

# local config:
BUILD="1"
PACKAGE="amavisd-new"

check() {
# Checking for configuration
# Downloading sources lists
INSTALLED="`ls -1 $PACKAGES/packages/|grep $PACKAGE|cut -d "-" -f 1,2,3`"
$WGET -q http://www.ijs.si/software/amavisd/
NEW=`grep $PACKAGE index.html |grep .tar.gz|cut -d '/' -f 2|cut -d '"' -f 1|sed -e s/.tar.gz//| \
sed -e s/.md5//|sort -n|tail -1`
#Checking for new version
    checkpkg
# clean
rm index.html
}

download() {
# Downloading version from "${VERFILE}"
$WGET -P $DOWNL http://www.ijs.si/software/amavisd/$SRC.tar.gz
}

build() {
# Creating new
tar zxvf $DOWNL/$SRC.tar.gz
cd $SRC
mkdir -p $PKG/usr/sbin
mkdir -p $PKG/etc/rc.d
mkdir -p $PKG/var/amavis
mkdir -p $PKG/var/virusmails
cp amavisd $PKG/usr/sbin
cp amavisd.conf $PKG/etc
chmod 644 $PKG/etc/amavisd.conf
chown mks.mks $PKG/var/amavis
chmod 770 $PKG/var/amavis
chmod 770 $PKG/var/virusmails
chown root.mks $PKG/var/virusmails
cp $CWD/rc.amavis $PKG/etc/rc.d/
if [ -r /etc/rc.d/rc.amavis ];then
mv $PKG/etc/rc.d/rc.amavis $PKG/etc/rc.d/rc.amavis.new
fi
if [ -r /etc/amavisd.conf ];then
mv $PKG/etc/amavisd.conf $PKG/etc/amavisd.conf.new
fi
    postbuild
}

source "${DATA:-/usr/lib/ktm}/ktm.ports.sh"

