LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-17-2009, 07:49 PM   #1
dbj
LQ Newbie
 
Registered: Sep 2009
Posts: 23

Rep: Reputation: 16
bash script (qmail) won't boot but starts from console (debian lenny)


In /etc/rc2.d/ I have a link to
/etc/init.d/qmail

It will not start when I boot (xmalloc error : ../bash/subst.c cannot allocate ...),
but I can on the command line do

/etc/init.d/qmail start

and

sh /etc/init.d/qmail start

but not
. /etc/init.d/qmail start

The latter gives the same error as during boot

How can I work around it?
Other scripts work.
 
Old 11-17-2009, 09:14 PM   #2
dbj
LQ Newbie
 
Registered: Sep 2009
Posts: 23

Original Poster
Rep: Reputation: 16
Not so nice workaround

I killed the S20qmail in /etc/rc2.d and instead,
I added the following to /etc/rc.local

export SHELL=/bin/bash
sh /etc/init.d/qmail start
exit 0

That helped. I have also tried to write "export SHELL=/bin/bash" at the beginning of /etc/init.d/qmail but somehow I couldn't get it to work
 
Old 11-18-2009, 01:01 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Intriguing. Can you post your /etc/init.d/qmail?
 
Old 11-18-2009, 01:40 AM   #4
dbj
LQ Newbie
 
Registered: Sep 2009
Posts: 23

Original Poster
Rep: Reputation: 16
qmai

It successfully starts qmail-start but afterwards something goes wrong

Code:
#!/bin/bash
#
# /etc/init.d/qmail : start or stop the qmail mail subsystem.
#
# Written by Christian Hudon <chrish@debian.org>
# Currently maintained by Jon Marler <jmarler@debian.org>
#
# Configuration
#


# set default delivery method

alias_empty="|/usr/sbin/qmail-procmail"  # procmail delivery to /var/spool/mail
#alias_empty="./Maildir/"       # This uses qmail prefered ~/Maildir/ directory
				# You may want to maildirmake /etc/skel/Maildir
#alias_empty="./Mailbox"        # This uses Mailbox file in users $HOME

logger="splogger qmail 2"	# facility mail == 2
#logger="|accustamp >>/var/log/qmail.log"   # If you have accustamp installed.
#logger=">>/var/log/qmail.log"              # Does not give timing info.

# If you uncommented one of the lines that appends to /var/log/qmail.log, you
# need to uncomment the following two lines.
#touch /var/log/qmail.log
#chown qmaill /var/log/qmail.log

# If you want to use one or more of the Relay Black Lists, uncomment
# the appropriate lines.

rblmsg=
rblsmtpd=
#rblmsg=" (with rblsmtpd)" 
#rblsmtpd="/usr/bin/rblsmtpd -r list.dsbl.org -r relays.ordb.org"

#
# End of configuration
#

test -x /usr/sbin/qmail-start || exit 0
test -x /usr/sbin/qmail-send || exit 0

case "$1" in
    start)
	echo -n "Starting mail-transfer agent: qmail" $rblmsg
	sh -c "start-stop-daemon --start --quiet --user qmails \
		 --exec /usr/sbin/qmail-send \
		 --startas /usr/sbin/qmail-start -- \"$alias_empty\" $logger &"
	# prevent denial-of-service attacks, with ulimit
	ulimit -v 16384
         sh -c "start-stop-daemon --start --quiet --user qmaild \
	    --pidfile /var/run/tcpserver_smtpd.pid --make-pidfile \
            --exec /usr/bin/tcpserver -- -R -H \
            -u `id -u qmaild` -g `id -g nobody` -x /etc/tcp.smtp.cdb 0 smtp \
            $rblsmtpd /usr/sbin/qmail-smtpd 2>&1 \
            | $logger &"

	# Uncomment the following lines to automatically start the pop3 server
	#sh -c "start-stop-daemon --start --quiet --user root \
	#    --pidfile /var/run/tcpserver_pop3d.pid --make-pidfile \
	#    --exec /usr/bin/tcpserver -- -R -H \
	#    0 pop-3 /usr/sbin/qmail-popup `hostname`.`dnsdomainname` \
	#    /usr/bin/checkpassword /usr/sbin/qmail-pop3d Maildir &"
	
	echo "."
	;;
    stop)
	echo -n "Stopping mail-transfer agent: qmail" $rblmsg
	if [ "`pidof /usr/sbin/qmail-send`" ] ; then
	    start-stop-daemon --user qmails --stop --quiet --oknodo --exec /usr/sbin/qmail-send
	    start-stop-daemon --user qmaild --stop --quiet --oknodo --pidfile /var/run/tcpserver_smtpd.pid --exec /usr/bin/tcpserver 
	    # Uncomment the following line if you have enabled the pop3 server
	    #start-stop-daemon --user root --stop --quiet --oknodo --pidfile /var/run/tcpserver_pop3d.pid --exec /usr/bin/tcpserver

	    # Wait until the timeout for qmail processes to die.
	    count=120
	    numdots=0
	    while ([ $count != 0 ]) do
		let count=$count-1
		if [ "`pidof /usr/sbin/qmail-send`" ] ; then
		    echo -n .
		    let numdots=$numdots+1
		    sleep 1
		else
		    count=0
		fi
	    done

	    # If it's not dead yet, kill it.
#	    if [ "`pidof /usr/sbin/qmail-send`" ] ; then
#		echo -n " TIMEOUT!"
#		kill -KILL `pidof /usr/sbin/qmail-send`
#	    else
		case $numdots in
		  0) echo "." ;;
		  1) echo ;;
		  *) echo " done." ;;
		esac
#	    fi
	else
	    echo " not running.";
	fi

	;;
    restart)
	$0 stop
	$0 start
	;;
    cdb)
	echo "Rebuilding tcp.smtp.cdb."
	cd /etc
	tcprules tcp.smtp.cdb tcp.smtp.temp < tcp.smtp
	;;
    flush)
        /usr/sbin/qmail-tcpok
        start-stop-daemon --stop --quiet --oknodo --signal ALRM --exec /usr/sbin/qmail-send
        echo "Queue flushed."
        ;;
    stat)
        /usr/sbin/qmail-qread
        /usr/sbin/qmail-qstat
        ;;
    reload|force-reload)
	echo "Reloading 'locals' and 'virtualdomains' control files."
	start-stop-daemon --stop --quiet --oknodo --signal HUP --exec /usr/sbin/qmail-send
	;;
    *)
	echo 'Usage: /etc/init.d/qmail {start|stop|stat|cdb|restart|reload}'
	exit 1
esac

exit 0
 
Old 11-18-2009, 08:19 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Try adding an echo above and below the ulimit command so you can see which of the three significant commands in the start section it is barfing on; probably the ulimit but let's make sure before going further.
 
Old 11-18-2009, 09:03 AM   #6
dbj
LQ Newbie
 
Registered: Sep 2009
Posts: 23

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by catkin View Post
Try adding an echo above and below the ulimit command so you can see which of the three significant commands in the start section it is barfing on; probably the ulimit but let's make sure before going further.
Tried that and it is not ulimit. It happens when the start-stop-daemon tries to start the tcpserver.
I have reason to believe that start-stop-daemon might be buggy or not compatible with lenny.
 
Old 11-18-2009, 10:37 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by dbj View Post
I have reason to believe that start-stop-daemon might be buggy or not compatible with lenny.
Care to share the reason with us?
 
Old 11-18-2009, 11:31 AM   #8
dbj
LQ Newbie
 
Registered: Sep 2009
Posts: 23

Original Poster
Rep: Reputation: 16
tcpserver start-stop-daemon lenny 5.0.3 AMD64

Quote:
Originally Posted by catkin View Post
Care to share the reason with us?
Alright, it is a little bit complicated. It is not fair to say that start-stop-daemon is buggy, but we have a conflict.
I have also tried to set it up using spamdyke like

Code:
...
         rblsmtpd="/usr/local/bin/spamdyke -l -f /etc/spamdyke.conf"
...
...
         sh -c "start-stop-daemon --start --quiet --user qmaild \
            --pidfile /var/run/tcpserver_smtpd.pid --make-pidfile \
            --exec /usr/bin/tcpserver -- -R -H \
            -u `id -u qmaild` -g 1004 -x /etc/tcp.smtp.cdb 0 smtp \
             $rblsmtpd /usr/sbin/qmail-smtpd 2>&1 \
            | $logger &"
It works I can send emails (if I use my rc.local hack), but every time a mail is sent I get in /var/log/mail.err

server1 spamdyke[2200]: ERROR: unable to find protocol number with getprotobyname()

That is ridiculous. The code in spamdyke is very simple it just call
getprotobyname("udp"), and if the returned pointer is null it logs the error message. My guess is that getprotobyname for some reason hasn't been able to read the /etc/protocols.
I have made a small testprogram using getprotobyname and it works fine. I even let start-stop-daemon start my test program.
The testprogram was build with the same settings as spamdyke. Afterwards I made a clean and make spamdyke, and a reinstallation but it changed nothing.
I have

server1:~# dpkg -l | grep ucspi
ii ucspi-tcp 1:0.88-2 command-line tools for building TCP client-server applications

ucspi was installed twice first 0.88-15 then the above.

I tried to run tcpserver from the command line ie. not as a daemon and suddenly I got no getprotobyname error

In other words tcpserver likes my console enviroment, but not when it is invoked by something else.
I must add that I have used the above configuration on an etch without problems.
It is possible that it is caused by two different errors, but I think it is start-stop-daemon/tcpserver/lenny conflict. Maybe I should add that I use AMD64 and have a raid filesystem.
 
Old 11-18-2009, 11:40 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by dbj View Post
Alright, it is a little bit complicated.
Can't argue with that!

Not my area of expertise (haven't even heard of spamdyke) so I can't help much (worth another thread with a more specific subject?) but what is the connection between the error message in the OP (xmalloc error : ../bash/subst.c cannot allocate ...) which looks like a bash problem and what you described in the last post which seems unrelated?! An incompatible library somewhere triggering both seemingly unrelated errors?
 
Old 11-21-2009, 07:03 AM   #10
dbj
LQ Newbie
 
Registered: Sep 2009
Posts: 23

Original Poster
Rep: Reputation: 16
Solved

ulimit is simply too low
 
  


Reply

Tags
boot, debian, qmail



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trigger bash script when screen saver starts of desktop gets locked BinWondrin Programming 4 08-01-2008 03:40 AM
LXer: How to fix the Debian Lenny bug in which Epiphany always starts in "working off LXer Syndicated Linux News 0 03-29-2008 10:00 PM
Is there a way to make slack boot to console before kdm starts? M$ISBS Linux - General 11 03-24-2006 08:25 PM
wpasupplicant boot script starts to late cccc Linux - Networking 4 03-12-2006 06:08 PM
change console title in bash script? TLV Linux - Software 18 10-08-2004 11:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration