#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=50 

DEST=
DEFAULT=$DEST/etc/default/asterisk
OPTIONS=""

start() {
	[ -f $DEFAULT ] && . $DEFAULT
	[ -d $DEST/var/run ] || mkdir -p $DEST/var/run
	[ -d $DEST/var/log/asterisk ] || mkdir -p $DEST/var/log/asterisk
	[ -d $DEST/var/spool/asterisk ] || mkdir -p $DEST/var/spool/asterisk
        [ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
        [ -h $DEST/usr/lib/asterisk/astdb ] || ln -sf /var/spool/asterisk/astdb $DEST/usr/lib/asterisk/astdb
	$DEST/usr/sbin/asterisk $OPTIONS
}

stop() {
	[ -f $DEST/var/run/asterisk.pid ] && kill $(cat $DEST/var/run/asterisk.pid) >/dev/null 2>&1
}
