SliTaz Packages

Community Doc Forum Pro Shop Bugs Hg
.

Receipt for package "cyrus-imapd"

# SliTaz package receipt.

PACKAGE="cyrus-imapd"
VERSION="3.4.3"
CATEGORY="network"
SHORT_DESC="IMAP server."
MAINTAINER="pascal.bellard@slitaz.org"
LICENSE="BSD"
WEB_SITE="https://cyrusimap.org/"

TARBALL="$PACKAGE-$VERSION.tar.gz"
WGET_URL="https://github.com/cyrusimap/$PACKAGE/releases/download/$PACKAGE-$VERSION/$TARBALL"

DEPENDS="cyrus-sasl db gcc83-lib-base jansson libcomerr libwrap net-snmp openssl
    perl slitaz-base-files"
BUILD_DEPENDS="cyrus-sasl-dev db-dev gcc83 icu-dev jansson-dev libcomerr-dev
    openssl-dev perl util-linux-uuid-dev"

CONFIG_FILES="/etc/imapd.conf /etc/cyrus.conf"

# What is the latest version available today?
current_version()
{
    wget -O - https://github.com/cyrusimap/cyrus-imapd/releases 2>/dev/null | \
    sed '/archive.*tar/!d;s|.*/[a-z-]*\(.*\).tar.*|\1|;q'
}

# Rules to configure and make the package.
compile_rules()
{
    export LDFLAGS="$LDFLAGS -lpthread"

    # 3.4.3 unrecognised
#        --with-service-path=/usr/lib/cyrus
#        --with-cyrus-prefix=/usr/lib/cyrus

    ./configure                    \
        CC=gcc-83                \
        CXX=g++-83                \
        --prefix=/usr                \
        --infodir=/usr/share/info        \
        --libexecdir=/usr/libexec/cyrus        \
        --with-com_err=yes            \
        --enable-murder                \
        --enable-replication            \
        --mandir=/usr/share/man            \
        $CONFIGURE_ARGS &&
    make &&
    make install DESTDIR=$DESTDIR
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
    mkdir -p $fs/usr/lib/cyrus
    mkdir -p $fs/usr/libexec
    mkdir -p $fs/var/imap
    mkdir -p $fs/var/spool/imap/stage.

    cp -a $install/usr/bin            $fs/usr
    cp -a $install/usr/lib/libcyrus*.so*    $fs/usr/lib
    cp -a $install/usr/lib/perl5        $fs/usr/lib
    strip -s                $fs/usr/lib/lib*
    cp -a $install/usr/libexec/cyrus    $fs/usr/libexec
    cp -a $install/usr/sbin            $fs/usr

    cp $src/tools/mkimap            $fs/usr/lib/cyrus
    cp -a $stuff/etc            $fs
    cp $src/doc/examples/cyrus_conf/small.conf \
                        $fs/etc/cyrus.conf
    for i in proc db socket log msg ptclient
      do
        mkdir -m 755 $fs/var/imap/$i
      done
}

# Pre and post install commands for Tazpkg.
post_install()
{
        # adduser cyrus if needed
    if ! grep -q cyrus "$1/etc/passwd"
      then
        echo
        echo -n "Adding user cyrus..."
        chroot "$1/" adduser cyrus -D -H -S -h /tmp
        chroot "$1/" sh -c 'echo "cyrus:cyrus" | chpasswd -m > /dev/null'
        status
    fi

    # addgroup mail if needed
    if ! grep -q mail "$1/etc/group"
      then
        echo
        echo -n "Adding group mail..."
        chroot "$1/" sh -c 'addgroup mail && addgroup cyrus mail'
        status
    fi

    chroot "$1/" chown -R cyrus.mail /var/spool/imap /var/imap
    while read name port end
      do
        grep -q $port "$1/etc/services" || \
            echo "$name        $port    $end" >> "$1/etc/services"
      done <<EOF
pop3 110/tcp pop-3
nntp 119/tcp readnews untp
imap 143/tcp imap2 imap4
imsp 406/tcp 
nntps 563/tcp snntp
acap 674/tcp
imaps 993/tcp
pop3s 995/tcp
kpop 1109/tcp
sieve 2000/tcp
lmtp 2003/tcp
fud 4201/udp
EOF

    [ "$1" ] || /etc/init.d/$PACKAGE start
    if [ -f "$1/etc/init.d/postfix" ]
      then
        if ! grep -v ^# "$1/etc/postfix/main.cf" | grep -q lmtp:unix
          then
            echo
            echo "Append to /etc/postfix/main.cf:"
            echo -n "    "
            echo "mailbox_transport = lmtp:unix:/var/imap/socket/lmtp" | \
                tee -a "$1/etc/postfix/main.cf"
            if [ -z "$1" ]
              then
                /etc/init.d/postfix start || /etc/init.d/postfix reload
            fi
        fi
    fi

    msg="\\nCreating mailbox for"
    for i in root $(awk -F: '{ if ($3 >= 1000) print $1 }' < "$1/etc/passwd")
      do
        echo -en "$msg $i"
        msg=","
      done
    echo ""

    for i in root $(awk -F: '{ if ($3 >= 1000) print $1 }' < "$1/etc/passwd")
      do
        echo "createmailbox user.$i"
      done | chroot "$1/" cyradm -u cyrus -w cyrus 127.0.0.1 >/dev/null 2>&1
    chroot "$1/" su -c "/usr/sbin/reconstruct" cyrus >/dev/null 2>&1

    cat <<EOF
----
Users must have a password to access the mailbox.
To start $PACKAGE server you can run :

    /etc/init.d/$PACKAGE start

Or add $PACKAGE to RUN_DAEMONS in /etc/rcS.conf
----
EOF

    # A security hole with ssh...
    [ -f "$1/etc/ssh/sshd_config" ] &&
    ! grep -q cyrus "$1/etc/ssh/sshd_config" &&
    echo "DenyUsers cyrus" >> "$1/etc/ssh/sshd_config"
}

post_remove()
{
    deluser cyrus
    delgroup mail
}
6025 packages and 203154 files in current database (Thu Apr 25 06:17:47 2024)