installing archivesmtp on Debian Squeeze

Discussion in 'Server Operation' started by Ovidiu, May 7, 2012.

  1. Ovidiu

    Ovidiu Active Member

    archivesmtp: http://www.dancingfortune.com/projects/archivesmtp/download.php

    compiled and installed as explained on that page but when I try to get the script to start at boot-up I get these errors:

    Code:
    h1870666:~# [B]insserv archivesmtp[/B]
    insserv: warning: script 'K02jailkit' missing LSB tags and overrides
    insserv: warning: script 'archivesmtp' missing LSB tags and overrides
    insserv: warning: script 'jailkit' missing LSB tags and overrides
    [B]insserv: There is a loop between service munin-node and archivesmtp if stopped
    insserv:  loop involving service archivesmtp at depth 2
    insserv:  loop involving service munin-node at depth 1
    insserv: Stopping archivesmtp depends on munin-node and therefore on system facility `$all' which can not be true!
    insserv: exiting now without changing boot order!
    [/B]h1870666:~# 
    any ideas how to fix this?
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Can you post the munin and archivesmtp init scripts?
     
  3. Ovidiu

    Ovidiu Active Member

    Sure I can do.

    Here is the munin rc script, quite long and the original that comes with the Debian munin version...:
    Code:
    #! /bin/bash
    
    ### BEGIN INIT INFO
    # Provides:          munin-node
    # Required-Start:    $local_fs $remote_fs
    # Required-Stop:     $local_fs $remote_fs
    # Should-Start:      $all
    # Should-Stop:       $all
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Start/stop Munin-Node
    # Description:       Start/stop Munin-Node
    ### END INIT INFO
    
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/sbin/munin-node
    PIDFILE=/var/run/munin/munin-node.pid
    CONFFILE=/etc/munin/munin-node.conf
    
    # log_daemon_msg() and log_progress_msg() isn't present in present in Sarge.
    # Below is a copy of them from lsb-base 3.0-5, for the convenience of back-
    # porters.  If the installed version of lsb-base provides these functions,
    # they will be used instead.
    
    log_daemon_msg () {
       if [ -z "$1" ]; then
           return 1
       fi
    
       if [ -z "$2" ]; then
           echo -n "$1:"
           return
       fi
    
       echo -n "$1: $2"
    }
    
    log_progress_msg () {
       if [ -z "$1" ]; then
           return 1
       fi
       echo -n " $@"
    }
    
    . /lib/lsb/init-functions
    [ -r /etc/default/munin-node ] && . /etc/default/munin-node
    
    if [ ! -x $DAEMON ]; then
           log_failure_msg "Munin-Node appears to be uninstalled."
           exit 5
    elif [ ! -e $CONFFILE ]; then
           log_failure_msg "Munin-Node appears to be unconfigured."
           exit 6
    fi
    
    # Figure out if the pid file is in a non-standard location
    while read line; do
           line=${line%%\#*} # get rid of comments
           set -f
           line=$(echo $line) # get rid of extraneous blanks
           set +f
           if [ "$line" != "${line#pid_file }" ]; then
                   PIDFILE=${line#pid_file }
           fi
    done < $CONFFILE
    
    verify_superuser() {
           action=$1
           [ $EUID -eq 0 ] && return
           log_failure_msg "Superuser privileges required for the" \
                           "\"$action\" action."
           exit 4
    }
    
    start() {
           log_daemon_msg "Starting Munin-Node"
           mkdir -p /var/run/munin
           chown munin:root /var/run/munin
           chmod 0755 /var/run/munin
           if pidofproc -p $PIDFILE $DAEMON >/dev/null; then
                   log_progress_msg "started beforehand"
                   log_end_msg 0
                   exit 0
           fi
           start_daemon -p $PIDFILE $DAEMON $DAEMON_ARGS
           ret=$?
           # start_daemon() isn't thorough enough, ensure the daemon has been
           # started manually
           attempts=0
           until pidofproc -p $PIDFILE $DAEMON >/dev/null; do
                   attempts=$(( $attempts + 1 ))
                   sleep 0.05
                   [ $attempts -lt 20 ] && continue
                   log_end_msg 1
                   return 1
           done
           [ $ret -eq 0 ] && log_progress_msg "done"
           log_end_msg $ret
           return $ret
    }
    
    stop() {
           log_daemon_msg "Stopping Munin-Node"
           # killproc() doesn't try hard enough if the pid file is missing,
           # so create it is gone and the daemon is still running
           if [ ! -r $PIDFILE ]; then
                   pid=$(pidofproc -p $PIDFILE $DAEMON)
                   if [ -z "$pid" ]; then
                           log_progress_msg "stopped beforehand"
                           log_end_msg 0
                           return 0
                   fi
                   echo $pid 2>/dev/null > $PIDFILE
                   if [ $? -ne 0 ]; then
                           log_end_msg 1
                           return 1
                   fi
           fi
           killproc -p $PIDFILE /usr/bin/munin-node
           ret=$?
           # killproc() isn't thorough enough, ensure the daemon has been
           # stopped manually
           attempts=0
           until ! pidofproc -p $PIDFILE $DAEMON >/dev/null; do
                   attempts=$(( $attempts + 1 ))
                   sleep 0.05
                   [ $attempts -lt 20 ] && continue
                   log_end_msg 1
                   return 1
           done
           [ $ret -eq 0 ] && log_progress_msg "done"
           log_end_msg $ret
           return $ret
    }
    
    if [ "$#" -ne 1 ]; then
           log_failure_msg "Usage: /etc/init.d/munin-node" \
                           "{start|stop|restart|force-reload|try-restart}"
           exit 2
    fi
    
    case "$1" in
     start)
           verify_superuser $1
           start
           exit $?
           ;;
     stop)
           verify_superuser $1
           stop
           exit $?
           ;;
     restart|force-reload)
           verify_superuser $1
           stop || exit $?
           start
           exit $?
           ;;
     try-restart)
           verify_superuser $1
           pidofproc -p $PIDFILE $DAEMON >/dev/null
           if [ $? -eq 0 ]; then
                   stop || exit $?
                   start
                   exit $?
           fi
           log_success_msg "Munin-Node was stopped beforehand and thus not" \
                           "restarted."
           exit 0
           ;;
     reload)
           log_failure_msg "The \"reload\" action is not implemented."
           exit 3
           ;;
     status)
           pid=$(pidofproc -p $PIDFILE $DAEMON)
           ret=$?
           pid=${pid% } # pidofproc() supplies a trailing space, strip it
           if [ $ret -eq 0 ]; then
                   log_success_msg "Munin-Node is running (PID: $pid)"
                   exit 0
           # the LSB specifies that I in this case (daemon dead + pid file exists)
           # should return 1, however lsb-base returned 2 in this case up to and
           # including version 3.1-10 (cf. #381684).  Since that bug is present
           # in Sarge, Ubuntu Dapper, and (at the time of writing) Ubuntu Etch,
           # and taking into account that later versions of pidofproc() do not
           # under any circumstance return 2, I'll keep understanding invalid
           # return code for the time being, even though the LSB specifies it is
           # to be used for the situation where the "program is dead and /var/lock
           # lock file exists".
           elif [ $ret -eq 1 ] || [ $ret -eq 2 ]; then
                   log_failure_msg "Munin-Node is dead, although $PIDFILE exists."
                   exit 1
           elif [ $ret -eq 3 ]; then
                   log_warning_msg "Munin-Node is not running."
                   exit 3
           fi
           log_warning_msg "Munin-Node status unknown."
           exit 4
           ;;
     *)
           log_failure_msg "Usage: /etc/init.d/munin-node" \
                           "{start|stop|restart|force-reload|try-restart}"
           exit 2
           ;;
    esac
    
    log_failure_msg "Unexpected failure, please file a bug."
    exit 1
    Here is the original archivesmtp rc script:

    Code:
    #!/bin/sh
    #
    # Start up RC script for archivesmtp milter
    #
    
    # Please set these values to match your installation
    ARCHIVESMTP="/usr/local/sbin/archivesmtp"
    CONFIG_FILE="/usr/local/etc/archivesmtp.conf"
    PID_FILE="/var/run/archivesmtp/run.pid"
    SOCKET="unix:/var/run/archivesmtp/mta.sock"
    CHUSER="nobody"
    FLAGS=""
    
    case "$1" in
            start)
                    echo -n "Starting ArchiveSMTP"
                    $ARCHIVESMTP $FLAGS -p $SOCKET -f $CONFIG_FILE -u $CHUSER -r $PID_FILE &
                    echo
                    ;;
            stop)
                    echo -n "Stopping ArchiveSMTP" 
                    kill `cat $PID_FILE`
                    echo
                    ;;
            *)
                    echo "Usage: $0 {start|stop}"
                    ;;
    esac
    
    exit
    Here is an alternative archivesmtp rc script I got from tis author but it seems not to be Debian compatible either, at least not entirely:
    Code:
    #!/bin/bash
    #
    # Start up RC script for archivesmtp milter
    #
    # chkconfig: - 77 23
    # description: archivesmtp is a daemon which hooks into sendmail \
    #              and copies email messages in to a mailbox.
    # processname: archivesmtp
    # pidfile: /var/run/archivesmtp/run.pid
    # config: /etc/archivesmtp.conf
     
    . /etc/rc.d/init.d/functions
     
    RETVAL=0
    ARCHIVESMTP="/usr/sbin/archivesmtp"
    CONFIG_FILE="/etc/archivesmtp.conf"
    PID_FILE="/var/run/archivesmtp/run.pid"
    SOCKET="unix:/var/run/archivesmtp/archivesmtp.sock"
    CHUSER="archivesmtp"
    FLAGS="-b -a"
     
    start() {
        echo -n $"Starting ArchiveSMTP: "
        daemon --check archivesmtp $ARCHIVESMTP $FLAGS -p $SOCKET -f $CONFIG_FILE -u $CHUSER -r $PID_FILE
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/archivesmtp
        return $RETVAL
    }
     
    stop() {
        echo -n $"Shutting down ArchiveSMTP: "
        killproc archivesmtp
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/archivesmtp
        return $RETVAL
    }
     
    # See how we were called.
    case "$1" in
      start)
           start
           ;;
      stop)
           stop
           ;;
      restart|reload)
           stop
           start
           RETVAL=$?
           ;;
      condrestart)
           if [ -f /var/lock/subsys/archivesmtp ]; then
               stop
               start
               RETVAL=$?
           fi
           ;;
        status)
           status archivesmtp
           RETVAL=$?
           ;;
        *)
           echo $"Usage: $0 {start|stop|restart|condrestart|status}"
           exit 1
    esac
     
    exit $RETVAL
    Don't worry about the PATHs inside the scripts, I had adapted them but it was easier to post the original scripts here...
     
    Last edited: May 9, 2012
  4. falko

    falko Super Moderator Howtoforge Staff

    I suggest you try something like

    Code:
    ### BEGIN INIT INFO
    # Provides:          archivesmtp
    # Required-Start:    $local_fs $remote_fs
    # Required-Stop:     $local_fs $remote_fs
    # Should-Start:      $all
    # Should-Stop:       $all
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Start/stop archivesmtp
    # Description:       Start/stop archivesmtp
    ### END INIT INFO
    in the original archivesmtp init script.
     

Share This Page