blob: bab656901a04a231af9ebaf894e23783d1d8bf27 (
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
|
#!/bin/sh
if [ "$2" = "PRE-INSTALL" ]; then
if [ -z "${CLAMAVUSER}" ]; then
CLAMAVUSER=clamav
fi
if [ -z "${CLAMAVGROUP}" ]; then
CLAMAVGROUP=clamav
fi
CLAMRUN=/var/run/clamav
CLAMLOG=/var/log/clamav
echo "===> Adding user \"${CLAMAVUSER}\" if necessary."
if ! pw groupshow "${CLAMAVGROUP}" 2>/dev/null 1>&2; then
if pw groupadd ${CLAMAVGROUP}; 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} -g ${CLAMAVGROUP} -h - \
-s "/usr/sbin/nologin" -d "/nonexistent" \
-c "Clam Antivirus"; \
then
echo "===> Added user \"${CLAMAVUSER}\"."
pw groupmod mail -m ${CLAMAVUSER}
else
echo "===> Adding user \"${CLAMAVUSER}\" failed..."
exit 1
fi
fi
echo "===> Setting permissions..."
mkdir -p "${CLAMRUN}"
chown "${CLAMAVUSER}:${CLAMAVGROUP}" "${CLAMRUN}"
mkdir -p "${CLAMLOG}"
chown "${CLAMAVUSER}:${CLAMAVGROUP}" "${CLAMLOG}"
fi
exit 0
|