[milters] Archive

Lists Index Date Thread Search

Article: 342
From: Mike Kercher
Date: 2005-02-17 13:00:15 -0500
Subject: Re: Errors

Removal...........: milters-request@milter.info?subject=remove
More information..: http://www.milter.info/#Support
--------------------------------------------------------

Ismael Perin wrote:
> Removal...........: milters-request@milter.info?subject=remove
> More information..: http://www.milter.info/#Support
> --------------------------------------------------------
> 
> Good Morning
> 
> 1) I has downloaded milter-sender 0.62 and this only show the
> configuration file and not start. What I do?
> 
> 2) This error is occurred too:
> 
> [root@x dir]# service milter-sender start
> /etc/init.d/milter-sender: line 48: unalias: announce: not found
> /etc/init.d/milter-sender: line 58: unalias: pass: not found
> /etc/init.d/milter-sender: line 71: unalias: fail: not found
> /etc/init.d/milter-sender: line 84: unalias: getpid: not found
> /etc/init.d/milter-sender: line 112: unalias: start: not found
> /etc/init.d/milter-sender: line 128: syntax error near unexpected
> token `"Starting $NAME"' /etc/init.d/milter-sender: line 128: `      
> announce("Starting $NAME")' 
> 
> Thanks, Ismael Perin.

Try this as your init-script:

#!/bin/sh
#
# milter-sender.sh.  Generated from milter-sender.sh.in by configure.
#
# Copyright 2002, 2004 by Anthony Howe. All rights reserved.
#
# chkconfig: 345 87 12
# description: Validate the sender address for invalid characters.
#              If a DNS server is specified, then check their MX
#              accepts a connection, the <> address, and their
#              email address.
#

# REQUIRE: syslogd
# BEFORE:  mail
# KEYWORD: FreeBSD NetBSD

prefix="/usr/local"
exec_prefix="${prefix}"
PROGRAM="${exec_prefix}/sbin/milter-sender"
#OPTIONS="unix:/var/state/milter-sender/socket"
STATE_DIR="/var/state/milter-sender"

FG_RED='\033[1;31m'
FG_GREEN='\033[1;32m'
FG_WHITE='\033[0;37m'
FG_BLACK='\033[0;30m'
FG_NORMAL=${FG_WHITE}

##########################################################################
#       Nothing to be configured below this point.
##########################################################################

# Program present?
if [ ! -f "$PROGRAM" ]; then
        echo "$PROGRAM" not found.
        exit 0;
fi

if [ ! -d $STATE_DIR ]; then
        echo $STATE_DIR not found.
        exit 0;
fi

os=`uname -s`         

getpid()
{
        sleep 1              
        case $os in
        Linux*)
                NAME=`basename $1`
ps acxj | grep "$NAME" | sed -n -e '/^  *1 /{
s/^ *[^ ][^ ]*  *\([0-9][0-9]*\).*/\1/
p
}'                 
                ;;     
        SunOS)
ps -ef | grep "$1" | sed -n -e '/^ *[^ ][^ ]*  *[0-9][0-9]*  *1 /{
s/^ *[^ ][^ ]*  *\([0-9][0-9]*\).*/\1/
p
}'                 
                ;;   
        *BSD*)       
                NAME=`basename $1`
ps -acxj | grep "$NAME" | sed -n -e '/^ *[^ ][^ ]*  *[0-9][0-9]*  *1 /{
s/^ *[^ ][^ ]*  *\([0-9][0-9]*\).*/\1/
p
}'
                ;;
        esac
}                 

start()
{              
        if [ -s "$STATE_DIR/mutex" ]; then
                case $os in
                Linux*)   
                        ipcrm sem `cat $STATE_DIR/mutex`
                        ;;
                *BSD*|SunOS)
                        ipcrm -s `cat $STATE_DIR/mutex`
                        ;;
                esac
        fi
        rm -f $STATE_DIR/mutex

        NAME=`basename "$PROGRAM"`
        printf "Starting %s" $NAME

        pid=`getpid "$PROGRAM"`              
        if [ X"$pid" != X ]; then     
                printf '\r\033[71C['${FG_RED}'FAILED'${FG_NORMAL}']\n'
                return
        fi             

        # Make sure the old socket has been removed, especially for FreeBSD.
        rm -f ${STATE_DIR}/socket     

        # Start the program in the background from a sub-shell
        # so that process will appear in the ps output immediately.
        sh -c "$PROGRAM $OPTIONS &"

        pid=`getpid "$PROGRAM"`
        if [ X"$pid" = X ]; then
                printf '\r\033[71C['${FG_RED}'FAILED'${FG_NORMAL}']\n'
                return
        fi

        printf '\r\033[71C['${FG_GREEN}'  OK  '${FG_NORMAL}']\n'
}                 

stop() 
{              
        NAME=`basename "$PROGRAM"`
        printf "Stopping %s" $NAME

        pid=`getpid "$PROGRAM"`              
        if [ X"$pid" != X ]; then     
                # The libmilter documentation specifies that only     
                # uncatchable signals can kill the milter, so no
                # point in trying a clean shutdown. HUP, TERM, and
                # INT are slow, in that they wait for connections
                # to complete or for the next request by Sendmail.          
                kill -QUIT $pid       

                pid=`getpid "$PROGRAM"`
                if [ X"$pid" != X ]; then
                        kill -KILL $pid

                        pid=`getpid "$PROGRAM"`
                        if [ X"$pid" != X ]; then
                                printf
'\r\033[71C['${FG_RED}'FAILED'${FG_NORMAL}']\n'
                                return
                        fi

                        if [ -s "$STATE_DIR/mutex" ]; then      
                                case $os in
                                Linux*)
                                        ipcrm sem `cat $STATE_DIR/mutex`
                                        ;;
                                *BSD*|SunOS)
                                        ipcrm -s `cat $STATE_DIR/mutex`
                                        ;;
                                esac
                        fi

                        rm -f $STATE_DIR/mutex
                fi
        fi

        printf '\r\033[71C['${FG_GREEN}'  OK  '${FG_NORMAL}']\n'
}

case "$1" in
reset)
        if [ -s "$STATE_DIR/mutex" ]; then
                case $os in
                Linux*)
                        ipcrm sem `cat $STATE_DIR/mutex`          
                        ;;
                *BSD*|SunOS)
                        ipcrm -s `cat $STATE_DIR/mutex`
                        ;;
                esac
        fi

        rm -f $STATE_DIR/mutex
        ;;
restart)
        stop
        start
        ;;                
start)
        start
        ;;
stop)
        stop
        ;;
status)
        pid=`getpid "$PROGRAM"`
        if [ X"$pid" != X ]; then         
                printf '\r\033[72C['${FG_GREEN}${pid}${FG_NORMAL}']\n'
        else              
                printf '\r\033[70C['${FG_RED}'STOPPED'${FG_NORMAL}']\n'
        fi
        ;;        
*)        
        printf 'Usage: %s {start|stop|reset|restart|status}\n' $0
        exit 1
esac

exit $?     


Lists Index Date Thread Search