Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Ubuntu 12.04 LTS and this system uses primarily upstart jobs. Unfortunately my system also depends on a manually compiled dbmail server, which only has a init script, but no upstart script.

Using update-rc.d dbmail defaults I installed dbmail for all runlevels, but unfortunately it is started before MySQL is up, so the daemon dies again. I also tried moving it to S90 or the like, still MySQL is not available when the script is run.

I attempted to add a dependency to the LSB header of the script, as follows:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          dbmail
# Required-Start:    $local_fs $remote_fs $syslog $network mysql
# Required-Stop:     $local_fs $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start dbmail services
# Description:       Run network services provided by dbmail such as
#                    imap-server, pop3-server, lmtp-server, timsieve-server
### END INIT INFO

Unfortunately the script still seems to be started before MySQL is. I am used to old-fashined init scripts, not to upstart jobs, so I am a little bit confused here. How can I add the dependency or how can I get the mysql job to start before the dbmail init script?

How can I check / see the start order taken for jobs + init scripts during boot? Is there a tool for this?

Launching the script manually from a shell after startup works fine, as MySQL is already running then.

share|improve this question
    
What worked as a ugly work-around was adding a "sleep 3" in the "start()" function of the init script. But there needs to be a cleaner way, this is just abusing a race-condition and I'd really like to fix this the proper way. –  Martin C. Nov 8 '12 at 1:34
add comment

1 Answer

up vote 6 down vote accepted

I think if you run /etc/init.d/dbmail start from /etc/rc.local, it will start after all your upstart jobs/other init scripts.

However, I would probably fix this by adding a new upstart job at /etc/init/dbmail.conf. Usually init.d scripts have a lot of code for checking status, etc., which upstart handles for you. It might be as simple as:

start on started mysql
exec /usr/local/bin/dbmail

Or, you can probably use the existing init script like this:

start on started mysql
pre-start script
  /etc/init.d/dbmail start
end script
post-stop script
  /etc/init.d/dbmail stop
end script
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.