aboutsummaryrefslogtreecommitdiff
path: root/mail/relay-ctrl/pkg-install.in
blob: 69884c7829fb5648a8f83274ebb51403443dd245 (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
#!/bin/sh

[ $# != 2 ] && exit 1
PKGNAME=$1
ACTION=$2


CHMOD=/bin/chmod
ECHO_CMD=echo
RM='/bin/rm -rf'
CP='/bin/cp -p'
CMP='/usr/bin/cmp -s'
MKDIR='/bin/mkdir -p'

RELAYCTRL_EXPIRY=600

PREFIX=${PKG_PREFIX}
SPOOLDIR=/var/spool
ETCDIR=${PREFIX}/etc/relay-ctrl
RELAYCLIENT=${ETCDIR}/RELAY_CTRL_RELAYCLIENT
EXPIRY=${ETCDIR}/RELAY_CTRL_EXPIRY

case "$ACTION" in

POST-INSTALL)
	${MKDIR} ${ETCDIR} ${SPOOLDIR}/relay-ctrl/allow
	${CHMOD} 0700 ${SPOOLDIR}/relay-ctrl
	${CHMOD} 0777 ${SPOOLDIR}/relay-ctrl/allow
	${ECHO_CMD} "${SPOOLDIR}/relay-ctrl/allow" > ${ETCDIR}/RELAY_CTRL_DIR
	${ECHO_CMD} "%%EXPIRY%%" > ${EXPIRY}
	if [ -z "%%FIXUP%%" ]; then
		${ECHO_CMD} "===>  RELAY-CTRL: Script do not create RELAY_CTRL_RELAYCLIENT"
	else
		if [ -e "${RELAYCLIENT}" ]; then
			${ECHO_CMD} ":allow,RELAYCLIENT='%%FIXUP%%'" > ${RELAYCLIENT}-sample
		else
			${ECHO_CMD} ":allow,RELAYCLIENT='%%FIXUP%%'" > ${RELAYCLIENT}
			${CP} ${RELAYCLIENT} ${RELAYCLIENT}-dist
		fi
	fi
	;;

DEINSTALL)
	${RM} ${SPOOLDIR}/relay-ctrl
	if ${CMP} ${RELAYCLIENT} ${RELAYCLIENT}-dist; then \
		${RM} ${RELAYCLIENT}
	fi
	if [ -e ${RELAYCLIENT}-dist ]; then
		${RM} ${RELAYCLIENT}-dist
	else
		${RM} ${RELAYCLIENT}-sample
	fi
	;;

PRE-INSTALL|POST-DEINSTALL)
	;;

*)
	exit 1
	;;
esac

exit