summaryrefslogtreecommitdiff
path: root/mail/qmail/INSTALL
blob: f5f40a74965e5278e74e938216c433c81e0eeab5 (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# $NetBSD: INSTALL,v 1.17 2019/08/29 22:04:21 schmonz Exp $

DOCDIR=@DOCDIR@
EGDIR=@EGDIR@
PKGMANDIR=@PKGMANDIR@
QMAILDIR=@QMAILDIR@
QMAIL_QUEUE_DIR=@QMAIL_QUEUE_DIR@

VAR_QMAIL_DIRS="alias bin boot control doc man queue users"

error_qmaildir() {
	local _qmaildir
	_qmaildir="$1"

	${CAT} <<EOF
===========================================================================

ERROR: ${_qmaildir} exists and is non-empty.

Please remove or rename it, then try again.

===========================================================================
EOF
	exit 1
}

error_instchown() {
	local _exitcode
	_exitcode="$1"

	${CAT} <<EOF
===========================================================================

ERROR: instchown exited ${_exitcode}.

Permissions are likely wrong, and/or the queue may be uninitialized.

===========================================================================
EOF
	exit 1
}

error_instcheck() {
	local _output
	_output="$1"

	${CAT} <<EOF
===========================================================================

ERROR: instcheck issued warnings:

${_output}

Permissions are likely wrong, and/or the queue may be uninitialized.

===========================================================================
EOF
	exit 1
}

warning_fqdn() {
	local _command _name
	_command="$1"
	_name="$2"

	${CAT} <<EOF
===========================================================================

WARNING: "${_name}" is not a fully qualified name.

To configure basic qmail control files, run this command as root:

# ${_command} ${_name}.yourdomain.tld

===========================================================================
EOF
}

case "${STAGE}" in

PRE-INSTALL)
	for dir in $VAR_QMAIL_DIRS; do
		if [ -e ${QMAILDIR}/$dir ]; then
			error_qmaildir ${QMAILDIR}
		fi
	done

	# keep in sync with Makefile:pre-install
	${LN} -s ${PKG_SYSCONFDIR}/alias	${QMAILDIR}/alias
	${LN} -s ${PREFIX}/bin			${QMAILDIR}/bin
	${LN} -s ${EGDIR}/boot			${QMAILDIR}/boot
	${LN} -s ${PKG_SYSCONFDIR}/control	${QMAILDIR}/control
	${LN} -s ${DOCDIR}			${QMAILDIR}/doc
	${LN} -s ${PREFIX}/${PKGMANDIR}		${QMAILDIR}/man
	${LN} -s ${QMAIL_QUEUE_DIR}		${QMAILDIR}/queue
	${LN} -s ${PKG_SYSCONFDIR}/users	${QMAILDIR}/users

	;;

POST-INSTALL)
	# create the queue
	${PREFIX}/share/qmail/setup/instpackage >/dev/null 2>&1
	${PREFIX}/share/qmail/setup/instchown
	QMAIL_SETUP_EXITCODE=$?
	if [ ${QMAIL_SETUP_EXITCODE} -ne 0 ]; then
		error_instchown ${QMAIL_SETUP_EXITCODE}
	fi

	QMAIL_CHECK_OUTPUT=$(${PREFIX}/share/qmail/setup/instcheck 2>&1)
	if [ -n "${QMAIL_CHECK_OUTPUT}" ]; then
		error_instcheck "${QMAIL_CHECK_OUTPUT}"
	fi

	QMAIL_CONFIG_CMD="${PREFIX}/share/qmail/setup/config-fast-pkgsrc"
	QMAIL_FQDN=$(${PREFIX}/share/qmail/setup/hostname)
	case "${QMAIL_FQDN}" in
	*.*)
		${QMAIL_CONFIG_CMD} "${QMAIL_FQDN}"
		;;
	*)
		warning_fqdn "${QMAIL_CONFIG_CMD}" "${QMAIL_FQDN}"
		;;
	esac

	;;

esac