1#!/bin/sh
2#
3# chkconfig: 2345 86 14
4# description: Starts and stops the Avis event router daemon.
5#
6# pidfile: /var/run/avisd.pid
7# config:  /etc/avis/avisd.config
8
9# Source function library.
10if [ -f /etc/init.d/functions ] ; then
11  . /etc/init.d/functions
12elif [ -f /etc/rc.d/init.d/functions ] ; then
13  . /etc/rc.d/init.d/functions
14else
15  exit 0
16fi
17
18# Avoid using root's TMPDIR
19unset TMPDIR
20
21AVISD=__PREFIX__/sbin/avisd
22AVISD_CONFIG=/etc/avis/avisd.config
23AVISD_LOGFILE=/var/log/avisd.log
24AVISD_PIDFILE=/var/run/avisd.pid
25AVISD_OPTIONS="-daemon -c $AVISD_CONFIG -logfile $AVISD_LOGFILE -pidfile $AVISD_PIDFILE"
26
27# Source networking configuration.
28. /etc/sysconfig/network
29
30# Check that networking is up.
31[ ${NETWORKING} = "no" ] && echo "No network" && exit 0
32
33# Check that avisd.config exists.
34[ -f $AVISD_CONFIG ] || ( echo "No config" && exit 0 )
35
36RETVAL=0
37
38start() {
39        KIND="Avis"
40	echo -n $"Starting $KIND service: "
41	daemon $AVISD $AVISD_OPTIONS
42	RETVAL=$?
43	echo
44	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/avisd || \
45	   RETVAL=1
46	return $RETVAL
47}
48
49stop() {
50        KIND="Avis"
51	echo -n $"Shutting down $KIND service: "
52	killproc avisd
53	RETVAL=$?
54	echo
55	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/avisd
56	echo ""
57	return $RETVAL
58}
59
60restart() {
61	stop
62	start
63}
64
65# Check that we can write to it... so non-root users stop here
66[ -w $AVISD_CONFIG ] || exit 0
67
68case "$1" in
69  start)
70  	start
71	;;
72  stop)
73  	stop
74	;;
75  restart)
76  	restart
77	;;
78  condrestart)
79  	[ -f /var/lock/subsys/avisd ] && restart || :
80	;;
81  *)
82	echo $"Usage: $0 {start|stop|restart|condrestart}"
83	exit 1
84esac
85
86exit $?
87