blob: 161c37187377777edc2cf81ff8edcf0be8748804 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/bin/sh /etc/rc.common
2# Copyright (C) 2014 OpenWrt.org
3
4START=72
5STOP=50
6
7extra_command "status" "Display the service status"
8extra_command "abort" "Stop the service abruptly. Running processes are signaled to stop immediately"
9extra_command "flush" "Force delivery: attempt to deliver every message in the deferred mail queue"
10extra_command "postinst" "Force running a script that checks for users, group, configuration, permissions, etc"
11
12postinst() {
13 if [ -z "$(postconf -nh myhostname)" ]; then
14 postconf -e "myhostname = $(uci get system.@system[0].hostname)"
15 fi
16 if [ -z "$(postconf -nh mydomain)" ]; then
17 postconf -e "mydomain = $(uci get dhcp.@dnsmasq[0].domain)"
18 fi
19 if [ -z "$(postconf -nh mynetworks_style)" ]; then
20 postconf -e "mynetworks_style = subnet"
21 fi
22 mail_spool_directory=$(postconf -h mail_spool_directory)
23 if [ ! -d $mail_spool_directory ]; then
24 mkdir -p -m 0755 $mail_spool_directory
25 chown -R postfix $mail_spool_directory
26 fi
27
28 postfix set-permissions
29 postfix post-install upgrade-source
30 postfix upgrade-configuration
31 newaliases
32 postmap $(postconf -h config_directory)/virtual
33 postfix check
34}
35
36start() {
37 if [ -z "$(postconf -nh myhostname)" ]; then
38 postinst
39 fi
40 postfix start
41}
42
43stop() {
44 postfix stop
45}
46
47reload() {
48 postfix reload
49}
50
51status() {
52 postfix status
53}
54
55abort() {
56 postfix abort
57}
58
59flush() {
60 postfix flush
61}