Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > media > contrib-release-src > by-pkgid > 5e2b01c56b3fd2d61615feec89b36c2c > files > 3

masqmail-0.2.18-8mdk.src.rpm

#!/bin/sh
#
# Masqmail start/stop script for Mandrake GNU/Linux
# Author: RĂ©mi Denis-Courmont <remi@simphalempin.com>
#
# chkconfig: 345 80 20
# description: Starts and stops the Masqmail daemon \
#	       used to provide SMTP mail service to dialup users.
#
### BEGIN INIT INFO
# Provides: masqmail
# Required-Start: $local_fs $network $named $syslog $time $remote_fs
# Required-Stop: $local_fs $network $syslog
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: start and stop MasqMail
# Description: MasqMail is a light-weight offline SMTP server.
### END INIT INFO
# (This init script is not strictly LSB-compliant).

# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 0
fi

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

LOCK_FILE=/var/lock/subsys/masqmail
CONF_FILE=/etc/masqmail/masqmail.conf
PATH=/sbin:/usr/sbin:/bin:/usr/bin

# Check that masqmail.conf exists.
if [ ! -f $CONF_FILE ]; then
	gprintf "Service not configured\n"
	exit 6 # not configured
fi

# Check that masqmail exists
if [ ! -x /usr/sbin/masqmail ]; then
	gprintf "Service not installed\n"
	exit 5 # not installed
fi

RETVAL=0

start() {
	gprintf "Starting Masqmail services: "
	daemon /usr/sbin/masqmail -bd
	RETVAL=$?
	echo
	if [ $RETVAL -eq 0 ]; then
		touch $LOCK_FILE
	else
		RETVAL=1
	fi
	return $RETVAL
}	
stop() {
	gprintf "Shutting down Masqmail services: "
	killproc /usr/sbin/masqmail
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
	return $RETVAL
}	
restart() {
	stop
	start
}	
reload() {
	gprintf "Reloading masqmail.conf: Not supported\n"
	#RETVAL=$?
	RETVAL=3 # unimplemented feature
	return $RETVAL
}	
mdkstatus() {
	status masqmail
}	

case "$1" in
  start)
  	start
	;;
  stop)
  	stop
	;;
  restart)
  	restart
	;;
  reload)
  	reload
	;;
  force-reload)
	#reload # is not supported
  	restart
	;;
  status)
  	mdkstatus
	;;
  condrestart)
  	[ -f $LOCK_FILE ] && restart || :
	;;
  *)
	gprintf "Usage: %s {start|stop|restart|status|condrestart}\n" "$0"
	exit 3 # unimplemented feature
esac

exit $?