#!/bin/sh

. /usr/bin/pcb_common.sh

name="dnsplugin"
start_options="-c /usr/lib/${name}/${name}.odl"
datamodel="DNS"
trace_zones="dnsplugin"
component="sah_services_dnsplugin"

mkdir -p /var/etc/dnsplugin

case $1 in 
	start)
		pcb_start $name $start_options
	;;
	stop)
		pcb_stop $name
	;;
	backup)
		if pcb_is_running $name; then
			pcb_cli "DNS.export($2)"
		else 
			echo "$name plugin is not running, impossible to make a backup"
		fi
	;;
	restore)
		mkdir -p /var/lib/dnsplugin
		touch /var/lib/dnsplugin/restore
	;;
	debuginfo)
		pcb_debug_info $name $component $datamodel
		show_cmd cat /var/etc/dnsplugin/dnsmasq-hosts
		show_cmd cat /var/etc/dnsplugin/dnsmasq-config
	;;
	log)
		action=$2
		if [ -n "$action" ]; then
			pcb_log $name $action $trace_zones
		else
			pcb_log $name enable $trace_zones
		fi
	;;
	*)
 		echo "Usage : $0 [start|stop|backup|restore|debuginfo]"
	;;
esac
