/etc/init.d/postfix not stopping postfix

okay I cant figure this out but /etc/init.d/postfix stop is not stopping postfix. Any ideas why?

www-virt 04:24:39 ~ $ cat /etc/init.d/postfix

!/bin/sh -e

Start or stop Postfix

#

LaMont Jones <lamont@debian.org>

based on sendmail's init.d script

BEGIN INIT INFO

Provides: postfix mail-transport-agent

Required-Start: $localfs $remotefs $syslog $named $network $time

Required-Stop: $localfs $remotefs $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

PATH=/bin:/usr/bin:/sbin:/usr/sbin

DAEMON=/usr/sbin/postfix

NAME=Postfix

TZ=

unset TZ

Defaults - don't touch, edit /etc/default/postfix

SYNC_CHROOT="y"

test -f /etc/default/postfix && . /etc/default/postfix

test -x $DAEMON && test -f /etc/postfix/main.cf || exit 0

. /lib/lsb/init-functions

DISTRO=$(lsb_release -is 2>/dev/null || echo Debian)

enabled_instances() {

postmulti -l -a | awk '($3=="y") { print $1}'

}

running() {

INSTANCE="$1"

if [ "X$INSTANCE" = X ]; then

POSTCONF="postconf"

else

POSTCONF="postmulti -i $INSTANCE -x postconf"

fi

queue=$($POSTCONF -h queue_directory 2>/dev/null || echo /var/spool/postfix)

if [ -f ${queue}/pid/master.pid ]; then

pid=$(sed 's/ //g' ${queue}/pid/master.pid)

what directory does the executable live in. stupid prelink systems.

dir=$(ls -l /proc/$pid/exe 2>/dev/null | sed 's/.* -> //; s/\/[^\/]*$//')

if [ "X$dir" = "X/usr/lib/postfix" ]; then

echo y

fi

fi

}

configure_instance() {

INSTANCE="$1"

if [ "X$INSTANCE" = X ]; then

POSTCONF="postconf"

else

POSTCONF="postmulti -i $INSTANCE -x postconf"

fi

if you set myorigin to 'ubuntu.com' or 'debian.org', it's wrong, and annoys the admins of

those domains. See also sendercanonicalmaps.

MYORIGIN=$($POSTCONF -h myorigin | tr 'A-Z' 'a-z')

if [ "X${MYORIGIN#/}" != "X${MYORIGIN}" ]; then

MYORIGIN=$(tr 'A-Z' 'a-z' < $MYORIGIN)

fi

if [ "X$MYORIGIN" = Xubuntu.com ] || [ "X$MYORIGIN" = Xdebian.org ]; then

logfailuremsg "Invalid \$myorigin ($MYORIGIN), refusing to start"

logendmsg 1

exit 1

fi

configdir=$($POSTCONF -h configdirectory)

see if anything is running chrooted.

NEEDCHROOT=$(awk '/^[0-9a-z]/ && ($5 ~ "[-yY]") { print "y"; exit}' ${configdir}/master.cf)

if [ -n "$NEEDCHROOT" ] && [ -n "$SYNCCHROOT" ]; then

Make sure that the chroot environment is set up correctly.

oldumask=$(umask)

umask 022

queuedir=$($POSTCONF -h queuedirectory)

cd "$queue_dir"

copy the CA path if specified

capath=$($POSTCONF -h smtptls_CApath)

case "$ca_path" in

'') :;; # no ca_path

$queue_dir/*) :;; # skip stuff already in chroot, (and to make vim syntax happy: */)

*)

if test -d "$ca_path"; then

destdir="$queuedir/${ca_path#/}"

strip any/all trailing /

while [ "${destdir%/}" != "${destdir}" ]; do

destdir="${destdir%/}"

done

new=0

if test -d "$dest_dir"; then

write to a new directory …

destdir="${destdir}.NEW"

new=1

fi

mkdir --parent ${dest_dir}

handle files in subdirectories

(cd "$capath" && find . -name '*.pem' -print0 | cpio -0pdL --quiet "$destdir") 2>/dev/null ||

(logfailuremsg failure copying certificates; exit 1)

crehash "$destdir" >/dev/null 2>&1

if [ "$new" = 1 ]; then

and replace the old directory

rm -rf "${dest_dir%.NEW}"

mv "$destdir" "${destdir%.NEW}"

fi

fi

;;

esac

if there is a CA file, copy it

cafile=$($POSTCONF -h smtptls_CAfile)

case "$ca_file" in

$queue_dir/*) :;; # skip stuff already in chroot

'') # no ca_file

or copy the bundle to preserve functionality

ca_bundle=/etc/ssl/certs/ca-certificates.crt

if [ -f $ca_bundle ]; then

mkdir –parent "$queuedir/${cabundle%/*}"

cp -L "$cabundle" "$queuedir/${ca_bundle%/*}"

fi

;;

*)

if test -f "$ca_file"; then

destdir="$queuedir/${ca_path#/}"

mkdir --parent "$dest_dir"

cp -L "$cafile" "$destdir"

fi

;;

esac

if we're using unix:passwd.byname, then we need to add etc/passwd.

localmaps=$($POSTCONF -h localrecipient_maps)

if [ "X$localmaps" != "X${localmaps#*unix:passwd.byname}" ]; then

if [ "X$localmaps" = "X${localmaps#*proxy:unix:passwd.byname}" ]; then

sed 's/^([^:]):[^:]/\1:x/' /etc/passwd > etc/passwd

chmod a+r etc/passwd

fi

fi

FILES="etc/localtime etc/services etc/resolv.conf etc/hosts \

etc/nsswitch.conf etc/nss_mdns.config"

for file in $FILES; do

[ -d ${file%/} ] || mkdir -p ${file%/}

if [ -f /${file} ]; then rm -f ${file} && cp /${file} ${file}; fi

if [ -f ${file} ]; then chmod a+rX ${file}; fi

done

ldaps needs this. debian bug 572841

(echo /dev/random; echo /dev/urandom) | cpio -pdL –quiet . 2>/dev/null || true

rm -f usr/lib/zoneinfo/localtime

mkdir -p usr/lib/zoneinfo

ln -sf /etc/localtime usr/lib/zoneinfo/localtime

LIBLIST=$(for name in gcc_s nss resolv; do

for f in /lib//lib${name}.so* /lib/lib${name}.so; do

if [ -f "$f" ]; then echo ${f#/}; fi;

done;

done)

if [ -n "$LIBLIST" ]; then

for f in "$LIBLIST"; do

rm -f "$f"

done

tar cf - -C / $LIBLIST 2>/dev/null |tar xf -

fi

umask $oldumask

fi

}

case "$1" in

start)

logdaemonmsg "Starting Postfix Mail Transport Agent" postfix

RET=0

for all instances that are not already running, handle chroot setup if needed, and start

for INSTANCE in $(enabled_instances); do

RUNNING=$(running $INSTANCE)

if [ "X$RUNNING" = X ]; then

configure_instance $INSTANCE

CMD="/usr/sbin/postmulti – -i $INSTANCE -x ${DAEMON}"

if ! start-stop-daemon --start --exec $CMD quiet-quick-start; then

RET=1

fi

fi

done

logendmsg $RET

;;

stop)

logdaemonmsg "Stopping Postfix Mail Transport Agent" postfix

RET=0

for all instances that are not already running, handle chroot setup if needed, and start

for INSTANCE in $(enabled_instances); do

RUNNING=$(running $INSTANCE)

if [ "X$RUNNING" != X ]; then

CMD="/usr/sbin/postmulti -i $INSTANCE -x ${DAEMON}"

if ! ${CMD} quiet-stop; then

RET=1

fi

fi

done

logendmsg $RET

;;

restart)

$0 stop

$0 start

;;

force-reload|reload)

logactionbegin_msg "Reloading Postfix configuration"

if ${DAEMON} quiet-reload; then

logactionend_msg 0

else

logactionend_msg 1

fi

;;

status)

ALL=1

ANY=0

for all instances that are not already running, handle chroot setup if needed, and start

for INSTANCE in $(enabled_instances); do

RUNNING=$(running $INSTANCE)

if [ "X$RUNNING" != X ]; then

ANY=1

else

ALL=0

fi

done

handle the case when postmulti returns no configured instances

if [ $ANY = 0 ]; then

ALL=0

fi

if [ $ALL = 1 ]; then

logsuccessmsg "postfix is running"

exit 0

elif [ $ANY = 1 ]; then

logsuccessmsg "some postfix instances are running"

exit 0

else

logsuccessmsg "postfix is not running"

exit 3

fi

;;

flush|check|abort)

${DAEMON} $1

;;

*)

logactionmsg "Usage: /etc/init.d/postfix {start|stop|restart|reload|flush|check|abort|force-reload|status}"

exit 1

;;

esac

exit 0

1 Reply

You don't have to post your /etc/init.d/postfix in full unless you modified it yourself (which you should not do anyway).

Instead, you should tell us:

  • OS (Debian or Ubuntu, that's for sure). and version.

  • What happens when you do "/etc/init.d/postfix stop"

  • How do you know that it's not stopped.

  • Any relevant error message (or lack of it) in /var/log/daemon.log when you stop postfix.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct