summaryrefslogtreecommitdiff
path: root/mail/qmail-scanner1/pkg-install
blob: e42be90badcbedc58ed90fe5bfa940d1694bddc8 (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
#!/bin/sh

CHMOD=/bin/chmod
CHOWN=/usr/sbin/chown
MKDIR=/bin/mkdir
PW=/usr/sbin/pw

GU_ID=98
GU_NAME=qscand

PREFIX=${PKG_PREFIX}
SPOOLDIR=${PREFIX}/qmailscan

case "$2" in
PRE-INSTALL)
  # User and group
  ${PW} groupshow -n ${GU_NAME} >/dev/null 2>&1 \
    || ${PW} groupadd -n ${GU_NAME} -g ${GU_ID}
  ${PW} usershow -n ${GU_NAME} >/dev/null 2>&1 \
    || ${PW} useradd ${GU_NAME} -g ${GU_NAME} -u ${GU_ID} -s /sbin/nologin
  ${MKDIR} -p ${SPOOLDIR}
  ${MKDIR} -p ${PREFIX}/share/examples/qs2mrtg
  ;;
POST-INSTALL)
  # Directories
  for i in quarantine working archives; do
    for j in tmp cur new; do
      ${MKDIR} -p ${SPOOLDIR}/$i/$j
    done
  done
  ${MKDIR} -p ${SPOOLDIR}/tmp

  # Mod and owner
  ${CHOWN} -R ${GU_NAME}:${GU_NAME} ${SPOOLDIR}
  ${CHOWN} ${GU_NAME}:${GU_NAME} ${PREFIX}/bin/qmail-scanner-queue.pl
  ${CHMOD} 4755 ${PREFIX}/bin/qmail-scanner-queue.pl

  # Initialize
  ${PREFIX}/bin/qmail-scanner-queue.pl -z
  ${PREFIX}/bin/qmail-scanner-queue.pl -g

  # Mod and owner (final)
  ${CHOWN} -R ${GU_NAME}:${GU_NAME} ${SPOOLDIR}
  ;;
esac