| 1 | #!/bin/sh |
| 2 | ###################################################################### |
| 3 | # postfix: starts/stops postfix daemon |
| 4 | # description: Postfix is a Mail Transport Agent, which is the program |
| 5 | # that moves mail from one machine to another. |
| 6 | ###################################################################### |
| 7 | |
| 8 | daemon="/usr/sbin/postfix" |
| 9 | config="/etc/postfix" |
| 10 | |
| 11 | ###################################################################### |
| 12 | # Sanity Check |
| 13 | ###################################################################### |
| 14 | [ -x $daemon ] || exit 1 |
| 15 | |
| 16 | ###################################################################### |
| 17 | # Uncomment these if you want to rebuild aliases on restart |
| 18 | ###################################################################### |
| 19 | #/usr/sbin/postalias hash:$config/aliases |
| 20 | #/usr/sbin/postmap hash:$config/{access,canonical,relocated,transport,virtual} |
| 21 | #/usr/sbin/postmap hash:$config/access.{client,helo,sender,recpnt} |
| 22 | |
| 23 | ###################################################################### |
| 24 | # Start/Stop/Reload/Status Functions |
| 25 | ###################################################################### |
| 26 | status() { |
| 27 | base=${daemon##*/} |
| 28 | dpid=`pidof -o $$ -o $PPID -o %PPID -x ${base}` |
| 29 | if [ "$dpid" != "" ]; then |
| 30 | echo "${base} (pid $dpid) is running..." |
| 31 | elif [ -s /var/run/${base}.pid ]; then |
| 32 | echo "${base} is dead but pid file exists..." |
| 33 | else |
| 34 | echo "${base} is stopped." |
| 35 | fi |
| 36 | return |
| 37 | } |
| 38 | ###################################################################### |
| 39 | # See how we were called |
| 40 | ###################################################################### |
| 41 | case "$1" in |
| 42 | start) $daemon start ;; |
| 43 | stop) $daemon stop ;; |
| 44 | reload) $daemon reload ;; |
| 45 | restart) $daemon reload ;; |
| 46 | status) status ;; |
| 47 | abort) $daemon abort ;; |
| 48 | flush) $daemon flush ;; |
| 49 | check) $daemon check ;; |
| 50 | *) echo "Usage: $0 {start|stop|reload|restart|status|abort|flush|check}" ; exit 1 ;; |
| 51 | esac |
| 52 | exit $? |