b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/bin/sh /etc/rc.common |
| 2 | # Copyright (C) 2014 OpenWrt.org |
| 3 | |
| 4 | START=72 |
| 5 | STOP=50 |
| 6 | |
| 7 | extra_command "status" "Display the service status" |
| 8 | extra_command "abort" "Stop the service abruptly. Running processes are signaled to stop immediately" |
| 9 | extra_command "flush" "Force delivery: attempt to deliver every message in the deferred mail queue" |
| 10 | extra_command "postinst" "Force running a script that checks for users, group, configuration, permissions, etc" |
| 11 | |
| 12 | postinst() { |
| 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 | |
| 36 | start() { |
| 37 | if [ -z "$(postconf -nh myhostname)" ]; then |
| 38 | postinst |
| 39 | fi |
| 40 | postfix start |
| 41 | } |
| 42 | |
| 43 | stop() { |
| 44 | postfix stop |
| 45 | } |
| 46 | |
| 47 | reload() { |
| 48 | postfix reload |
| 49 | } |
| 50 | |
| 51 | status() { |
| 52 | postfix status |
| 53 | } |
| 54 | |
| 55 | abort() { |
| 56 | postfix abort |
| 57 | } |
| 58 | |
| 59 | flush() { |
| 60 | postfix flush |
| 61 | } |