Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

22.9. The /etc/rc.d/init.d/sendmail script file

Note: Please note that the /etc/rc.d/init.d/sendmail file is for all type of configuration.

To configure your /etc/rc.d/init.d/sendmail script file to start and stop the Sendmail daemon, You have to create the sendmail script file, touch /etc/rc.d/init.d/sendmail and add:

         #!/bin/sh
         #
         # sendmail      This shell script takes care of starting and stopping
         #               sendmail.
         #
         # chkconfig: 2345 80 30
         # description: Sendmail is a Mail Transport Agent, which is the program \
         #              that moves mail from one machine to another.
         # processname: sendmail
         # config: /etc/sendmail.cf
         # pidfile: /var/run/sendmail.pid
         # Source function library.
         . /etc/rc.d/init.d/functions
         # Source networking configuration.
         . /etc/sysconfig/network
         # Source sendmail configuration.
         if [ -f /etc/sysconfig/sendmail ] ; then
         . /etc/sysconfig/sendmail
         else
         DAEMON=yes
         QUEUE=1h
         fi
         # Check that networking is up.
         [ ${NETWORKING} = "no" ] && exit 0
         [ -f /usr/sbin/sendmail ] || exit 0
         RETVAL=0
         # See how we were called.
         case "$1" in
         start)
         # Start daemons.
         echo -n "Starting sendmail: "
         /usr/bin/newaliases > /dev/null 2>&1
         for i in virtusertable access domaintable mailertable ; do
         if [ -f /etc/mail/$i ] ; then
         makemap hash /etc/mail/$i < /etc/mail/$i
         fi
         done
         daemon /usr/sbin/sendmail $([ "$DAEMON" = yes ] && echo -bd) \
         $([ -n "$QUEUE" ] && echo -q$QUEUE)
         RETVAL=$?
         echo
         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sendmail
         ;;
         stop)
         # Stop daemons.
         echo -n "Shutting down sendmail: "
         killproc sendmail
         RETVAL=$?
         echo
         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sendmail
         ;;
         restart|reload)
         $0 stop
         $0 start
         RETVAL=$?
         ;;
         status)
         status sendmail
         RETVAL=$?
         ;;
         *)
         echo "Usage: sendmail {start|stop|restart|status}"
         exit 1
         esac
         exit $RETVAL
         

Now, make this script executable and change its default permissions:
         [[email protected]] /# chmod 700  /etc/rc.d/init.d/sendmail
         
Create the symbolic rc.d links for Sendmail with the command:
         [[email protected]] /# chkconfig --add sendmail
         
Start your Sendmail Server manually with the following command:
         [[email protected]] /# /etc/rc.d/init.d/sendmail start
         

         Starting sendmail:                                         [  OK  ]
         

Please do a cleanup as always later:
         [[email protected]] /# cd /var/tmp
         [[email protected] ]/tmp# rm -rf sendmail-version/ sendmail.version.tar.gz
         
The rm command as used above will remove all the source files we have used to compile and install Sendmail. It will also remove the Sendmail compressed archive from the /var/tmp directory.

 
 
  Published under the terms of the Open Publication License Design by Interspire