Linux Online Advertisement
[ Register ]

[ Applications ]
[ Documentation ]
[ Distributions ]
[ Download Info ]
[ General Info ]
[ Book Store ]

Advertisement

[ Courses ]
[ News ]
[ People ]
[ Hardware ]
[ Vendors ]
[ Projects ]
[ Events ]
[ User Groups ]
[ User Area ]

Automating Unix and Linux Administration

[ About Us ]
[ Home Page ]
[ Advertise ]

Advanced Linux Course

Providing Services at Boot Time

You will need to make sure that the machine starts all of these services at boot time. First, well need to create a script to start Postfix. The following will do nicely:

#!/bin/sh
# chkconfig: 345 40 60
# description: Postfix mail transfer agent (MTA) 

case "$1" in
        start)
                echo -n "Starting Postfix"
                /usr/sbin/postfix start
                ;;

        stop)
                echo -n "Halting Postfix"
                /usr/sbin/postfix stop
                ;;

        reload)
                echo -n "Postfix reload"
                /usr/sbin/postfix reload
                ;;
        restart)
                $0 stop
                /usr/bin/sleep 1
                $0 start

  status)
                echo -n "Checking..."
                /usr/sbin/postfix check
                ;;
        *)
                echo "Usage: $0 {start|stop|reload|restart|status}"
                exit 1
        ;;
esac

Make this script executable and place it in /etc/init.d/

Here is a simple script for starting the Courier Authdaemon. If you need something more complicated, feel free to add to it.

#!/bin/sh

# chkconfig:            345 80 20
# description:          IMAP Auth Daemon

case "$1" in
'start')
        if [ -f /usr/local/courier/libexec/authlib/authdaemond ]; then
                /usr/local/courier/libexec/authlib/authdaemond start
                echo "Starting Courier authdaemon"
        fi
        ;;

'stop')
        if [ -f /usr/local/courier/libexec/authlib/authdaemond ]; then
                /usr/local/courier/libexec/authlib/authdaemond stop
        fi
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac

exit 0

Again, make this script executable and place it in /etc/init.d/

Courier IMAP comes with startup scripts for providing the authentication service for mail pickup. Courier also comes with a POP3 daemon, so there are two scripts that we'll need to copy to /etc/init.d/. These are /usr/local/courier/libexec/imapd.rc and /usr/local/courier/libexec/pop3d.rc. It's a good idea to rename them to just imapd and pop3d. Once you have copied those files to /etc/init.d/, we need to add two lines to each so that they'll be compatible with our Fedora setup. If you're not using Fedora, you'll need to consult how your system handles its start-up scripts. Add the following lines to the 'imapd' script after the '#!/bin/sh' part:

# chkconfig: 345 80 20 # description: Courier IMAP Daemon

Do the same for the 'pop3d' script, changing 'Courier IMAP' to 'Courier POP3'

Now we're ready to add these services to the appropriate rcX.d directories. This is done with the chkconfig --add script command. In our case, we do the following:

chkconfig --add postfix

and do the same for the other three scripts. The next time you boot the machine, these services will start automatically.



Comments: feedback (at) linux.org
Advertising: banners (at) linux.org
Copyright Linux Online Inc.
Compilation ©1994-2008 Linux Online, Inc.
All rights reserved.