#!/bin/bash
doit() {
    [[ $tpl =~ /etc/omix/([^/]+)/tpl ]] && vars=/etc/omix/vars/${BASH_REMATCH[1]} || return
    ([ -f "$vars" ] || return
    set -a; . $vars; set +a
    envsubst <$tpl >${tpl/tpl/conf}
)}
for tpl in $(find /etc/omix -path '/etc/omix/*/tpl/*'); do doit; done
