]> git.pld-linux.org Git - packages/postfix.git/blame - postfix.init
- up to 3.6.15
[packages/postfix.git] / postfix.init
CommitLineData
a281e397
AM
1#!/bin/sh
2#
4f3faccd 3# postfix This shell script takes care of starting and stopping
4# postfix.
a281e397 5#
3fdf27ec 6# chkconfig: 345 80 20
563bd3a0 7#
f2a36c02 8# description: Postfix is a Mail Transport Agent, which is the program \
563bd3a0 9# that moves mail from one machine to another.
10
a281e397 11
563bd3a0 12# Source function library
a281e397
AM
13. /etc/rc.d/init.d/functions
14
563bd3a0 15# Get network config
a281e397
AM
16. /etc/sysconfig/network
17
563bd3a0 18# Get service config
19[ -f /etc/sysconfig/postfix ] && . /etc/sysconfig/postfix
20
d2efe7d5 21# Check that networking is up.
8f7a8ac9
PG
22networking_check() {
23 if is_yes "${NETWORKING}"; then
24 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
3fdf27ec 25 msg_network_down "Postfix"
8f7a8ac9
PG
26 exit 1
27 fi
28 else
29 exit 0
4f3faccd 30 fi
8f7a8ac9 31}
d2efe7d5 32
8f7a8ac9 33start() {
f3d8af28
ER
34 if [ -f /var/lock/subsys/postfix ]; then
35 msg_already_running "Postfix"
36 return
37 fi
3fdf27ec 38
f3d8af28
ER
39 local msg
40 msg_starting "Postfix"
41 busy
42 _daemon_set_ulimits
43 msg=$(nice -n ${SERVICE_RUN_NICE_LEVEL:-${DEFAULT_SERVICE_RUN_NICE_LEVEL:-0}} /usr/sbin/postfix start 2>&1)
44 RETVAL=$?
45 if [ $RETVAL -eq 0 ]; then
46 ok
47 touch /var/lock/subsys/postfix
a281e397 48 else
f3d8af28
ER
49 fail
50 echo >&2 "$msg"
a281e397 51 fi
8f7a8ac9
PG
52}
53
54stop() {
f3d8af28
ER
55 if [ ! -f /var/lock/subsys/postfix ]; then
56 msg_not_running "Postfix"
57 return
58 fi
59
3fdf27ec 60 local msg
f3d8af28
ER
61 msg_stopping "Postfix"
62 busy
63 msg=$(/usr/sbin/postfix stop 2>&1)
64 if [ $? -eq 0 ]; then
65 ok
4f3faccd 66 else
f3d8af28
ER
67 fail
68 echo >&2 "$msg"
3fdf27ec 69 fi
79f286bf 70 rm -f /var/lock/subsys/postfix >/dev/null 2>&1
3fdf27ec
ER
71}
72
73reload() {
f3d8af28
ER
74 if [ ! -f /var/lock/subsys/postfix ]; then
75 msg_not_running "Postfix"
76 RETVAL=7
77 return
78 fi
79
3fdf27ec 80 local msg
f3d8af28
ER
81 msg_reloading "Postfix"
82 busy
83 msg=$(/usr/sbin/postfix reload 2>&1)
84 RETVAL=$?
85 if [ $RETVAL -eq 0 ]; then
86 ok
3fdf27ec 87 else
f3d8af28
ER
88 fail
89 echo >&2 "$msg"
3fdf27ec 90 RETVAL=7
a281e397 91 fi
8f7a8ac9
PG
92}
93
94RETVAL=0
95# See how we were called.
96case "$1" in
97 start)
98 networking_check
99 start
100 ;;
101 stop)
102 stop
a281e397
AM
103 ;;
104 restart)
8f7a8ac9
PG
105 networking_check
106 stop
107 start
a281e397 108 ;;
13f423a4 109 reload|force-reload)
8f7a8ac9 110 networking_check
3fdf27ec 111 reload
a281e397
AM
112 ;;
113 rebuilddb)
4f3faccd 114 standard_db="access canonical relocated transport virtual"
30477b9f 115 extra_db=$(ls -1 /etc/mail/*.db 2> /dev/null | grep -Ev '/(access|canonical|relocated|transport|virtual|aliases)\.db$')
3fdf27ec
ER
116
117 echo -n "Rebuilding databases: "
2479a467 118 for base in $standard_db $extra_db; do
3fdf27ec
ER
119 db=$(basename "$base" .db)
120
121 if [ -f /etc/mail/$db ]; then
122 echo -n "$db "
123 /usr/sbin/postmap hash:/etc/mail/$db < /etc/mail/$db
563bd3a0 124 fi
a281e397 125 done
3fdf27ec
ER
126 echo "...DONE"
127
128 echo -n "Rebuilding aliases database"
603402cb 129 /usr/bin/newaliases
3fdf27ec
ER
130 echo "...DONE"
131 ;;
132 status)
133 status master
134 exit $?
4f3faccd 135 ;;
a281e397 136 *)
13f423a4 137 msg_usage "$0 {start|stop|restart|reload|force-reload|rebuilddb|status}"
138 exit 3
a281e397
AM
139esac
140
00063a89 141exit $RETVAL
This page took 0.327494 seconds and 4 git commands to generate.