Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have installed postfix on my server using this guide http://www.postfix.org/INSTALL.html#install

Basically creating my own package and installing. Now I want to start postfix automatically when the server reboots.

I have tried adding the symbolic link chkconfig --add postfix but I get this error: error reading information on service postfix: No such file or directory

I have postfix running just fine on the server expect for this. To start/stop postfix now I use

sudo postfix stop
sudo postfix start

Any ideas on how to get it to start on its own?

share|improve this question

4 Answers 4

chkconfig --add postfix require a postfix init script inside init script repositories, commonly /etc/init.d.

chkconfig and update-rc.d (debian) just manipule scripts in /etc/rc#.d/, where # is the startup runrelevel that the default is set on /etc/inittab on line with initdefault term. Im my case is:

id:2:initdefault:

Then the symbolics links on /etc/rc2.d/ will be called. The name of this links have a pattern [S|K]\d{1,}dstname, e.g:

$ ls -l /etc/rc2.d/ | grep postfix
lrwxrwxrwx 1 root root  17 Ago 16 09:04 S22postfix -> ../init.d/postfix

S means /etc/init.d/postfix start K means /etc/init.d/postfix stop

22 is the links execution order.

Then you need check inittab to get default run level (initdefault), check the links on /etc/rcX.d (X is initdefault value), and have the link with a postfix startup script as target ( a script that supportstartfor S prefix links andstop` for K prefix links args).

This is how initsysv system works, but each distro can change a little.

share|improve this answer
    
Thanks for a complete answer here, I will try it out tomorrow. –  enfield Jan 18 '12 at 3:31

I'm very interested why you need to build Postfix from sources. In only very few cases this is worth the trouble. The recommended way is to use the pre-compiled version provided by your distribution. Why? Because you don't have to care about security fixes. Additionally you get the comfort of init scripts and the like. Plus a guarantee that there are no problems combining Postfix with related software from your distribution.

If you now say "but the speed improvement by self-compiling!" then I have to say "is nothing to care about". "But I have to care about every CPU cycle!" Then use a distribution like Gentoo with all the positive aspects from above plus tuning at every screw.

share|improve this answer
    
I built Postfix from the sources so I could include the packages I needed to wrap in. Unfortunately with the rpms used on the server any pre-compilied version would not even install properly / start working. Hence going to a new compile and now I have it working as it should. Of course minus the problems with automation. I am all for using something if it works, I do not just create work for the fun of it. –  enfield Jan 18 '12 at 3:34

The postfix distribution does not come with a sample initscript, but you can simply use the provided "postfix" wrapper program, which is the master control program for postfix.

Just include postfix start anywhere in the boot sequence - rc.local is often a good place for this.

See http://www.postfix.org/PACKAGE_README.html for more details.

share|improve this answer
    
Starting an MTA from rc.local - yeuch! –  symcbean Jan 16 '12 at 9:26
    
And what makes your init script so super superior ? –  adaptr Jan 16 '12 at 17:03
    
@adaptr You're kidding, right? How are you going to make sure that Postfix shuts down cleanly when you reboot the machine? –  Magellan Jan 16 '12 at 19:22
    
I'm not saying an init script should not be used. I said his specific solution is nonsense. –  adaptr Jan 17 '12 at 11:57

Your postfix distro probably came with a start/stop script - indeed the recommendation to use 'postfix start' in section 9 of the document you read implies this is running the start/stop script directly not the binary.

You've not mentioned what Linux distro you're using. Traditionally, Linux uses the SysV init layout, but more recently more distro's are moving to upstart however since the latter is usually set up to be backward compatible with SysV, then it's probably simpler to use that model if you're installing your own postfix from tarball rather than using the package manager.

If you can't find an init script in your tarball then there's lots of examples on the internet e.g. this one. Just add it in your init scripts dir and create appropriately named symlinks in the runlevel dirs as described in the article linked above (or use chkconfig if your system supports it).

share|improve this answer
    
He indicated postfix was built from source, ergo there is no init script. Also, there are no generic init scripts that work for just any distro. –  adaptr Jan 16 '12 at 17:04

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.