]> git.pld-linux.org Git - packages/postfix.git/blob - postfix.init
- cleaning
[packages/postfix.git] / postfix.init
1 #!/bin/sh
2 #
3 # postfix       This shell script takes care of starting and stopping
4 #               postfix.
5 #
6 # chkconfig:    345 80 30
7 #
8 # description:  Postfix is a Mail Transport Agent, which is the program
9 #               that moves mail from one machine to another.
10
11
12 # Source function library
13 . /etc/rc.d/init.d/functions
14
15 # Get network config
16 . /etc/sysconfig/network
17
18 # Get service config
19 [ -f /etc/sysconfig/postfix ] && . /etc/sysconfig/postfix
20
21 # Check that networking is up.
22 if is_yes "${NETWORKING}"; then
23         if [ ! -f /var/lock/subsys/network ]; then
24                 msg_network_down Postfix
25                 exit 1
26         fi
27 else
28         exit 0
29 fi
30
31
32 # See how we were called.
33 case "$1" in
34   start)
35         # Check if the service is already running?
36         if [ ! -f /var/lock/subsys/postfix ]; then
37                 msg_starting Postfix
38                 busy
39                 MSG="`/usr/sbin/postfix start 2>&1`"
40                 if [ "$?" = "0" ] ; then
41                         ok
42                         touch /var/lock/subsys/postfix
43                 else
44                         fail
45                         echo "$MSG"
46                 fi
47         else
48                 msg_already_running Postfix
49                 exit 1
50         fi
51         ;;
52   stop)
53         # Stop daemons.
54         if [ -f /var/lock/subsys/postfix ]; then
55                 msg_stopping Postfix
56                 busy
57                 MSG="`/usr/sbin/postfix stop 2>&1`"
58                 RETVAL=$?
59                 if [ $RETVAL -eq 0 ]; then
60                         ok
61                 else
62                         fail
63                         echo "$MSG"
64                 fi
65                 rm -f /var/lock/subsys/postfix
66         else
67                 msg_not_running Postfix
68                 exit 1
69         fi
70         ;;
71   restart)
72         $0 stop
73         $0 start
74         ;;
75   reload)
76         if [ -f /var/lock/subsys/postfix ]; then
77                 msg_reloading Postfix
78                 busy
79                 /usr/sbin/postfix reload
80                 RETVAL=$?
81                 [ $RETVAL -eq 0 ] && ok || died
82         else
83                 msg_not_running Postfix
84                 exit 1
85         fi
86         ;;
87   status)
88         status master
89         exit $?
90         ;;
91   rebuilddb)
92         standard_db="access canonical relocated transport virtual"
93         extra_db=$(ls -1 /etc/mail/*.db 2> /dev/null | grep -v aliases.db | sed -e 's#.db$##')
94         for base in $standard_db $extra_db; do
95                 I=$(basename "$base")
96                 if [ -f /etc/mail/$I ] ; then
97                         /usr/sbin/postmap hash:/etc/mail/$I < /etc/mail/$I
98                 fi
99         done
100         /usr/bin/newaliases
101         ;;
102   *)
103         msg_usage "$0 {start|stop|restart|reload|rebuilddb|status}"
104         exit 1
105 esac
106
107 exit $RETVAL
This page took 0.034211 seconds and 4 git commands to generate.