aboutsummaryrefslogtreecommitdiffstats
path: root/security/clamav-devel/pkg-install
blob: efa21d86a171f1c74035f04028842ec3ad829927 (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
69
70
71
#!/bin/sh
# $FreeBSD: /tmp/pcvs/ports/security/clamav-devel/Attic/pkg-install,v 1.19 2005-01-12 18:22:56 yar Exp $

PREFIX=${PKG_PREFIX:-%%PREFIX%%}
DESTDIR=${PKG_DESTDIR:-}

CLAMAVUSER=%%CLAMAVUSER%%
CLAMAVGROUP=%%CLAMAVGROUP%%
UID=106
GID=$UID

CLAMLOG=$DESTDIR/var/log/clamav
DBDIR=$DESTDIR%%DBDIR%%
RUNDIR=$DESTDIR%%RUNDIR%%

if [ "$2" = "PRE-INSTALL" ]; then

    if ! pw groupshow "$CLAMAVGROUP" 2>/dev/null 1>&2; then
        if pw groupadd $CLAMAVGROUP -g $GID; then
            echo "=> Added group \"$CLAMAVGROUP\"."
        else
            echo "=> Adding group \"$CLAMAVGROUP\" failed..."
            exit 1
        fi
    fi

    if ! pw usershow "$CLAMAVUSER" 2>/dev/null 1>&2; then
        if pw useradd $CLAMAVUSER -u $UID -g $CLAMAVGROUP -h - \
            -s "/sbin/nologin" -d "/nonexistent" \
            -c "Clam Antivirus"; \
        then
            pw groupmod mail -m $CLAMAVUSER
            echo "=> Added user \"$CLAMAVUSER\"."
        else
            echo "=> Adding user \"$CLAMAVUSER\" failed..."
            exit 1
        fi
    fi

elif [ "$2" = "POST-INSTALL" ]; then

    if [ ! -d "$CLAMLOG" ]; then
        mkdir -p "$CLAMLOG" || exit 1
        chown "$CLAMAVUSER:$CLAMAVGROUP" "$CLAMLOG" || exit 1
    fi

    if [ ! -d "$DBDIR" ]; then
        mkdir -p "$DBDIR" || exit 1
        chown "$CLAMAVUSER:$CLAMAVGROUP" "$DBDIR" || exit 1
    fi

    if [ ! -d "$RUNDIR" ]; then
        mkdir -p "$RUNDIR" || exit 1
        chown "$CLAMAVUSER:$CLAMAVGROUP" "$RUNDIR" || exit 1
    fi

    if [ -f "$DESTDIR$PREFIX/etc/clamav.conf" ]; then
        echo
        echo "**************** WARNING ****************"
        echo "*                                       *"
        echo "*  The configuration file has changed:  *"
        echo "* Please edit $PREFIX/etc/clamd.conf *"
        echo "* and remove $PREFIX/etc/clamav.conf *"
        echo "*                                       *"
        echo "**************** WARNING ****************"
        echo
    fi

fi

exit 0