#!/bin/sh

. /usr/bin/pcb_common.sh

name="dyndns_plugin"
start_options="-c /usr/lib/dyndns/dyndns.odl"
datamodel="DynDNS"
trace_zones="dyndns"
component="sah_services_dyndns"

case $1 in
    start)
        pcb_start $name $start_options
        ;;
    stop)
        pcb_stop $name
        ;;
    restart)
        $0 stop
        while pcb_is_running $name; do
            sleep 1
        done
        $0 start
        ;;
    backup)
        if pcb_is_running $name; then
            pcb_cli "DynDNS.export($2)"
        else
            echo "dyndns plug-in not running, unable to backup settings"
        fi
        ;;
    restore)
        mkdir -p /var/lib/dyndns
        touch /var/lib/dyndns/restore
        ;;
    debuginfo)
        pcb_debug_info $name $component $datamodel
        ;;
    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|restart|backup|restore|debuginfo|log]"
        ;;
esac
