#!/bin/sh
#
# Once we've installed the package explicitly flush the queue,
# to cover cases when the format changes.
#
# If we're running @Bytemark restart the worker processes
#

set -e


#
# Skip, if we are not in "configure" state
#
if [ "$1" != "configure" ]; then
        echo "I: Skipping configuration"
        exit 0
fi


#
# 1.  Flush the queue, if present.
#
custodian-queue --flush || true

#
# 2.  If we have agents then restart them.
#
for i in /etc/service/custodian-agent* /etc/service/cust-dequeue ; do
    if [ -d $i ] ; then
        echo "Restarting service: $i"
        sv force-restart $i || true
    fi
done

#DEBHELPER#
exit 0