Repository navigation
Expand file tree
/
Copy pathpostfix.init
More file actions
146 lines (129 loc) · 2.55 KB
/
Copy pathpostfix.init
File metadata and controls
146 lines (129 loc) · 2.55 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/sh
#
# postfix This shell script takes care of starting and stopping
# postfix.
#
# chkconfig: 345 80 20
#
# description: Postfix is a Mail Transport Agent, which is the program \
# that moves mail from one machine to another.
# Source function library
. /etc/rc.d/init.d/functions
# Get network config
. /etc/sysconfig/network
# Get service config
[ -f /etc/sysconfig/postfix ] && . /etc/sysconfig/postfix
# Check that networking is up.
networking_check() {
if is_yes "${NETWORKING}"; then
if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
msg_network_down "Postfix"
exit 1
fi
else
exit 0
fi
}
start() {
if [ -f /var/lock/subsys/postfix ]; then
msg_already_running "Postfix"
return
fi
local msg
msg_starting "Postfix"
busy
_daemon_set_ulimits
msg=$(nice -n ${SERVICE_RUN_NICE_LEVEL:-${DEFAULT_SERVICE_RUN_NICE_LEVEL:-0}} /usr/sbin/postfix start 2>&1)
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
ok
touch /var/lock/subsys/postfix
else
fail
echo >&2 "$msg"
fi
}
stop() {
if [ ! -f /var/lock/subsys/postfix ]; then
msg_not_running "Postfix"
return
fi
local msg
msg_stopping "Postfix"
busy
msg=$(/usr/sbin/postfix stop 2>&1)
if [ $? -eq 0 ]; then
ok
else
fail
echo >&2 "$msg"
fi
rm -f /var/lock/subsys/postfix >/dev/null 2>&1
}
reload() {
if [ ! -f /var/lock/subsys/postfix ]; then
msg_not_running "Postfix"
RETVAL=7
return
fi
local msg
msg_reloading "Postfix"
busy
msg=$(/usr/sbin/postfix reload 2>&1)
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
ok
else
fail
echo >&2 "$msg"
RETVAL=7
fi
}
RETVAL=0
# See how we were called.
case "$1" in
start)
networking_check
start
;;
stop)
stop
;;
restart)
networking_check
stop
start
;;
reload|force-reload)
networking_check
reload
;;
rebuilddb)
standard_db="access canonical relocated transport virtual"
echo -n "Rebuilding databases: "
# /etc/mail is still scanned for maps left there before the config
# directory moved to /etc/postfix
for dir in /etc/postfix /etc/mail; do
extra_db=$(ls -1 $dir/*.db 2> /dev/null | grep -Ev '/(access|canonical|relocated|transport|virtual|aliases)\.db$')
for base in $standard_db $extra_db; do
db=$(basename "$base" .db)
if [ -f $dir/$db ]; then
echo -n "$db "
/usr/sbin/postmap hash:$dir/$db < $dir/$db
fi
done
done
echo "...DONE"
echo -n "Rebuilding aliases database"
/usr/bin/newaliases
echo "...DONE"
;;
status)
status master
exit $?
;;
*)
msg_usage "$0 {start|stop|restart|reload|force-reload|rebuilddb|status}"
exit 3
esac
exit $RETVAL