Enabling services

Chris cpollock at embarqmail.com
Sat Jul 19 21:00:40 UTC 2014


I believe I've found the problem with getting Spamassassin to run. If I
run 'service --status-all I see:

[ - ] spamassassin

Which I would believe means that it's not enabled? In my old Mandriva
system all I'd need do is run chkconfig and then enable it from there I
see that instead an application called 'upstart' is used. I have in
my /etc/default folder this file:

# /etc/default/spamassassin
# Duncan Findlay

# WARNING: please read README.spamd before using.
# There may be security risks.

# Change to one to enable spamd
ENABLED=1

# Options
# See man spamd for possible options. The -d option is automatically
added.

# SpamAssassin uses a preforking model, so be careful! You need to
# make sure --max-children is not set to anything higher than 5,
# unless you know what you're doing.

OPTIONS="--create-prefs --max-children 5 --helper-home-dir"

# Pid file
# Where should spamd write its PID to file? If you use the -u or
# --username option above, this needs to be writable by that user.
# Otherwise, the init script will not be able to shut spamd down.
PIDFILE="/var/run/spamd.pid"

# Set nice level of spamd
NICE="--nicelevel 15"

# Cronjob
# Set to anything but 0 to enable the cron job to automatically update
# spamassassin's rules on a nightly basis
CRON=1

And in /etc/init.d this file:

#! /bin/sh

### BEGIN INIT INFO
# Provides:       spamassassin
# Required-Start: $remote_fs
# Required-Stop:  $remote_fs
# Should-Start:   $network $syslog
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
### END INIT INFO

# Spamd init script
# June 2002
# Duncan Findlay

# Based on skeleton by Miquel van Smoorenburg and Ian Murdock

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=/usr/sbin/spamd:/usr/local/bin/spamd
NAME=spamd
SNAME=spamassassin
DESC="SpamAssassin Mail Filter Daemon"
PIDFILE="/var/run/$NAME.pid"
XNAME=/usr/bin/perl

export TMPDIR=/tmp
# Apparently people have trouble if this isn't explicitly set...

# Defaults - don't touch, edit /etc/default/spamassassin
ENABLED=0
OPTIONS=""
NICE=

. /lib/lsb/init-functions

test -f /etc/default/spamassassin && . /etc/default/spamassassin

DOPTIONS="-d --pidfile=$PIDFILE"

check_enabled() {
    if [ "$ENABLED" = "0" ]; then
	echo "$DESC: disabled, see /etc/default/spamassassin"
	exit 0
    fi
}

test -f $DAEMON || exit 0

set -e

case "$1" in
  start)
	check_enabled
	echo -n "Starting $DESC: "
	start-stop-daemon --start --pidfile $PIDFILE --exec $XNAME \
	    $NICE --oknodo --startas $DAEMON -- $OPTIONS $DOPTIONS
	echo "$NAME."
	;;

  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --pidfile $PIDFILE --exec $XNAME --oknodo
	echo "$NAME."
	;;

  reload|force-reload)
	check_enabled
	echo -n "Reloading $DESC: "
	start-stop-daemon --stop --pidfile $PIDFILE --signal HUP --exec $XNAME
	echo "$NAME."
	;;

  restart)
	check_enabled
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --pidfile $PIDFILE --exec $XNAME \
	    --retry 5 --oknodo
	start-stop-daemon --start --pidfile $PIDFILE --exec $XNAME \
	    $NICE --oknodo --startas $DAEMON -- $OPTIONS $DOPTIONS

	echo "$NAME."
	;;
  status)
        status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
        ;;
  *)
	N=/etc/init.d/$SNAME
	echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
	exit 1
	;;
esac

exit 0

Spamd is located in /usr/local/bin as well as sa-update and spamc. I
believe the problem with getting SA to start is that it's not an enabled
service. I notice that clamav is running as well as freshclam and
checking service --status-all I see:

[ + ] clamav-daemon
[ + ] clamav-freshclam

Doing some reading about upstart I ran update-rc.d spamassassin enable S
2 3 4 5 which showed an output of:

Code:

 Enabling system startup links for /etc/init.d/spamassassin ...
 Removing any system startup links for /etc/init.d/spamassassin ...
   /etc/rc0.d/K21spamassassin
   /etc/rc1.d/K21spamassassin
   /etc/rc2.d/S19spamassassin
   /etc/rc3.d/S19spamassassin
   /etc/rc4.d/S19spamassassin
   /etc/rc5.d/S19spamassassin
   /etc/rc6.d/K21spamassassin
 Adding system startup for /etc/init.d/spamassassin ...
   /etc/rc0.d/K21spamassassin -> ../init.d/spamassassin
   /etc/rc1.d/K21spamassassin -> ../init.d/spamassassin
   /etc/rc6.d/K21spamassassin -> ../init.d/spamassassin
   /etc/rc2.d/S19spamassassin -> ../init.d/spamassassin
   /etc/rc3.d/S19spamassassin -> ../init.d/spamassassin
   /etc/rc4.d/S19spamassassin -> ../init.d/spamassassin
   /etc/rc5.d/S19spamassassin -> ../init.d/spamassassin

So now in rc0.d - rc5.d I have links to the spamassassin script
in /etc/init.d however the service still shows a [-] for the
spamassassin service.

I have rebooted the system with no difference 'service --status-all
still shows a [-] for spamassassin. Not sure what I'm failing to do.


Thanks in advance for any advice/assistance.

Chris







More information about the ubuntu-users mailing list