#!/bin/bash

BASE=/opt/www/passport

set -e

case "$1" in
    configure)
        mkdir -p $BASE/etc/conf

        $BASE/conf/configurator --hosts $BASE/conf/hosts --input $BASE/conf/templates/ranges.conf.tt                    --output $BASE/etc/conf/ranges.conf
        $BASE/conf/configurator --hosts $BASE/conf/hosts --input $BASE/conf/templates/push-client.yaml.tt               --output $BASE/etc/conf/push-client.yaml
        $BASE/conf/configurator --hosts $BASE/conf/hosts --input $BASE/conf/templates/push-client-historydb-enc.yaml.tt --output $BASE/etc/conf/push-client-historydb-enc.yaml

        invoke-rc.d statbox-push-client restart
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac
