[init]dkim-milter

By | 2013年5月25日
#!/bin/bash
#
# /etc/init.d/dkim-milter
#
# chkconfig:   - 79 21
# description: DomainKeys Identified Mail Milter
# processname: dkim-filter
# config:      /etc/mail/dkim-milter/dkim-milter.conf
# config:      /etc/sysconfig/dkim-milter
# pidfile:     /var/run/dkim-milter/dkim-milter.pid

# Source function library.
. /etc/init.d/functions

desc="DomainKeys Identified Mail Milter"
name=dkim-milter
prog=dkim-filter
prog_with_path=/usr/sbin/${prog}
user=${name}
pidfile=/var/run/${name}/${name}.pid
config=/etc/mail/${name}/${prog}.conf

EXTRA_FLAGS=""
[ -r /etc/sysconfig/${name} ] && . /etc/sysconfig/${name}

# versions of the default config file from <= 2.8.3-5 did not set Socket, so make sure it gets set here
if [ -z "${SOCKET}" ] && ! grep -q '^[ 	]*Socket[ 	]' "${config}"; then
   SOCKET=local:/var/run/${name}/${name}.sock
fi

start() {
	echo -n "Starting ${desc} (${prog}): "
        daemon --user ${user} ${prog_with_path} -x ${config} -P ${pidfile} ${SOCKET:+-p ${SOCKET}} ${EXTRA_FLAGS}
        RETVAL=$?
        echo
        if [ ${RETVAL} -eq 0 ]; then
                touch /var/lock/subsys/${name}
                return 0
        else
                return 1
        fi
}

stop() {
	echo -n "Shutting down ${desc}: "
        rm -f /var/lock/subsys/${name}
        killproc ${prog}
        RETVAL=$?
        echo
        if [ ${RETVAL} -eq 0 ]; then
                rm -f ${pidfile}
                return 0
        else
                return 1
        fi
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
        status -p ${pidfile} ${prog}
	;;
    restart|reload)
    	stop
	start
	;;
    condrestart)
	[ -f /var/lock/subsys/${name} ] && stop
        start
	;;
    *)
	echo "Usage: ${name} {start|stop|status|reload|restart}"
	exit 1
	;;
esac
exit $?

发表评论

电子邮件地址不会被公开。 必填项已用*标注