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

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

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

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