#!/bin/sh

set -e

WANTDIR="$1/postfix.service.wants"
SERVICEFILE="/lib/systemd/system/postfix@.service"

mkdir -p "$WANTDIR"

if [ -f main.cf ]; then
    for NAME in $(postmulti -l -a | awk '{ print $1}'); do
        ln -s "$SERVICEFILE" "$WANTDIR/postfix@$NAME.service"
    done
else
    ln -s "$SERVICEFILE" "$WANTDIR/postfix@-.service"
fi

exit 0
