aboutsummaryrefslogtreecommitdiff
path: root/mail/postfix/files/postfix.init
blob: 27b79aae3edec2c940bd1c0520e4b9e5682020f6 (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
#!/bin/sh /etc/rc.common
# Copyright (C) 2014 OpenWrt.org

START=72
STOP=50
EXTRA_COMMANDS="status abort flush postinst"
EXTRA_HELP="	status	Display the service status
	abort	Stop the service abruptly. Running processes are signaled to stop immediately
	flush	Force delivery: attempt to deliver every message in the deferred mail queue
	postinst Force running a script that checks for users, group, configuration, permissions, etc"


postinst() {
	if [ -z "$(postconf -nh myhostname)" ]; then
		postconf -e "myhostname = $(uci get system.@system[0].hostname)"
	fi
	if [ -z "$(postconf -nh mydomain)" ]; then
		postconf -e "mydomain = $(uci get dhcp.@dnsmasq[0].domain)"
	fi
	if [ -z "$(postconf -nh mynetworks_style)" ]; then
		postconf -e "mynetworks_style = subnet"
	fi
	mail_spool_directory=$(postconf -h mail_spool_directory)
	if [ ! -d $mail_spool_directory ]; then
		mkdir -p -m 0755 $mail_spool_directory
		chown -R postfix $mail_spool_directory
	fi

	postfix set-permissions
	postfix post-install upgrade-source
	postfix upgrade-configuration
	newaliases
	postmap $(postconf -h config_directory)/virtual
	postfix check
}

start() {
	if [ -z "$(postconf -nh myhostname)" ]; then
		postinst
	fi
	postfix start
}

stop() {
	postfix stop
}

reload() {
	postfix reload
}

status() {
	postfix status
}

abort() {
	postfix abort
}

flush() {
	postfix flush
}