#!/bin/sh -e # Start or stop Postfix # # LaMont Jones # based on sendmail's init.d script ### BEGIN INIT INFO # Provides: postfix mail-transport-agent # Required-Start: $local_fs $remote_fs $syslog $named $network $time # Required-Stop: $local_fs $remote_fs $syslog $named $network # Should-Start: postgresql mysql clamav-daemon postgrey spamassassin saslauthd dovecot # Should-Stop: postgresql mysql clamav-daemon postgrey spamassassin saslauthd dovecot # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: start and stop the Postfix Mail Transport Agent # Description: postfix is a Mail Transport agent ### END INIT INFO global PATH := '/bin:/usr/bin:/sbin:/usr/sbin' global DAEMON := '/usr/sbin/postfix' global NAME := 'Postfix' global TZ := '' unset TZ # Defaults - don't touch, edit /etc/default/postfix global SYNC_CHROOT := '"y'" test -f /etc/default/postfix && source /etc/default/postfix test -x $DAEMON && test -f /etc/postfix/main.cf || exit 0 source /lib/lsb/init-functions #DISTRO=$(lsb_release -is 2>/dev/null || echo Debian) proc enabled_instances { postmulti -l -a | awk '($3=="y") { print $1}' } proc running { global INSTANCE := $1 if test "X$INSTANCE" = X { global POSTCONF := '"postconf'" } else { global POSTCONF := ""postmulti -i $INSTANCE -x postconf"" } global queue := $[$POSTCONF -h queue_directory !2 >/dev/null || echo /var/spool/postfix] if test -f $(queue)/pid/master.pid { global pid := $[sed 's/ //g' $(queue)/pid/master.pid] # what directory does the executable live in. stupid prelink systems. global dir := $[ls -l /proc/$pid/exe !2 >/dev/null | sed 's/.* -> //; s/\/[^\/]*$//] if test "X$dir" = "X/usr/lib/postfix" { echo y } } } proc configure_instance { global INSTANCE := $1 if test "X$INSTANCE" = X { global POSTCONF := '"postconf'" } else { global POSTCONF := ""postmulti -i $INSTANCE -x postconf"" } # if you set myorigin to 'ubuntu.com' or 'debian.org', it's wrong, and annoys the admins of # those domains. See also sender_canonical_maps. global MYORIGIN := $[$POSTCONF -h myorigin | tr 'A-Z' 'a-z] if test "X$(MYORIGIN#/)" != "X$(MYORIGIN)" { global MYORIGIN := $[tr 'A-Z' 'a-z' < $MYORIGIN] } if test "X$MYORIGIN" = Xubuntu.com || test "X$MYORIGIN" = Xdebian.org { log_failure_msg "Invalid \$myorigin ($MYORIGIN), refusing to start" log_end_msg 1 exit 1 } global config_dir := $[$POSTCONF -h config_directory] # see if anything is running chrooted. global NEED_CHROOT := $[awk '/^[0-9a-z]/ && ($5 ~ "[-yY]") { print "y"; exit}' $(config_dir)/master.cf] if test -n $NEED_CHROOT && test -n $SYNC_CHROOT { # Make sure that the chroot environment is set up correctly. global oldumask := $[umask] umask 022 global queue_dir := $[$POSTCONF -h queue_directory] cd $queue_dir # copy the CA path if specified global ca_path := $[$POSTCONF -h smtp_tls_CApath] matchstr $ca_path {