aboutsummaryrefslogtreecommitdiffstats
path: root/security/cyrus-sasl/pkg-deinstall
blob: 02d41095c0cfd55c5d15eb72cffd8d8860fd673e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
#
#   $FreeBSD$
#
# Created by: hetzels@westbend.net

#set -vx

PKG_BATCH=${BATCH:=NO}

PKG_PREFIX=${PKG_PREFIX:=/usr/local}

SASLDB_NAME=${PKG_PREFIX}/etc/%%SASLDB%%

CYRUS_USER=${CYRUS_USER:=%%CYRUS_USER%%}
CYRUS_GROUP=${CYRUS_GROUP:=%%CYRUS_GROUP%%}

remove_file()
{
    file=$1

    if cmp -s ${file} ${file}.tmp; then
        rm -f ${file}
    fi
    rm -f ${file}.tmp
}

# delete sasldb database

delete_sasldb() {
    if [ -f ${SASLDB_NAME} ] ; then
        if [ `${PKG_PREFIX}/sbin/sasldblistusers | wc -l` -eq 0 ] ; then
            rm ${SASLDB_NAME}
        else
            echo "WARNING: Users SASL passwords are in ${SASLDB_NAME}, keeping this file"
        fi
    fi
}

delete_user() {
    if pw usershow ${CYRUS_USER} 2>/dev/null 1>&2; then
        echo "To delete Cyrus user permanently, use 'pw userdel ${CYRUS_USER}'"
    fi
    if pw groupshow ${CYRUS_GROUP} 2>/dev/null 1>&2; then
        echo "To delete Cyrus group permanently, use 'pw groupdel ${CYRUS_GROUP}'"
    fi

}

# This should really be uninstalled by Sendmail

sendmail_conf() {
    if [ -f ${PKG_PREFIX}/lib/sasl/Sendmail.conf ]; then
        echo "pwcheck_method: %%PWCHECK_METHOD%%" > ${PKG_PREFIX}/lib/sasl/Sendmail.conf.tmp
        remove_file ${PKG_PREFIX}/lib/sasl/Sendmail.conf
    fi
}

case $2 in
    DEINSTALL)
        delete_sasldb
        sendmail_conf
        ;;
    POST-DEINSTALL)
        delete_user
        ;;

esac