#!/bin/bash
#
# conntrackd    Start conntrackd using /etc/conntrackd.conf
#
#               Written by Max Kellermann <max@duempel.org>
#
### BEGIN INIT INFO
# Provides:          conntrackd
# Required-Start:    $network
# Required-Stop:     $network
# Default-Start:     2 3 5 
# Default-Stop:	     0 6 
# Description: Starts conntrackd
# short-description: Starts conntrackd
### END INIT INFO

#includes lsb functions 
source /lib/lsb/init-functions

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/conntrackd

test -x $DAEMON || exit 0

CONFIG=/etc/conntrackd.conf
OPTIONS=""

test -f /etc/default/conntrackd && source /etc/default/conntrackd

test -f $CONFIG || exit 0

case "$1" in
    start)
        log_begin_msg "Starting conntrackd"
        start-stop-daemon --start --quiet \
            --exec $DAEMON \
            -- \
            -d \
            -C "$CONFIG" \
            $OPTIONS
        log_end_msg $?
        ;;
    stop)
        log_begin_msg "Stopping conntrackd"
        $DAEMON \
            -C "$CONFIG" \
            -k
        log_end_msg $?
        ;;
    restart|force-reload)
        $0 stop
        sleep 1
        $0 start
        ;;
    *)
        log_action_msg "Usage: /etc/init.d/conntrackd {start|stop|restart|force-reload}"
        exit 1
        ;;
esac

exit 0