view mod_alias/mod_alias_postfixadmin.sh @ 4542:fb4a50bf60f1

mod_prometheus: Invoke stats collection if in 'manual' mode Since 10d13e0554f9 a special value for statistics_interval "manual" exists, where a module is expected to invoke processing in connection to collection of stats. This makes internal collection and exporting to Prometheus happens at the same time with no chance of timers getting out of sync.
author Kim Alvefur <zash@zash.se>
date Tue, 13 Apr 2021 23:53:53 +0200
parents 0c3ba5ff7a3b
children
line wrap: on
line source

#!/bin/sh
# Copyright (C) 2015 Travis Burtrum
# This file is MIT/X11 licensed.

# run like ./mod_alias_postfixadmin.sh "mysql -N -upostfixadmin -ppostfixadmin postfixadmin" > /etc/prosody/aliases.cfg.lua
# then put:
# Include "aliases.cfg.lua"
# in prosody.cfg.lua

mysql="$1"

echo "-- alias plugin, generated by mod_alias_postfixadmin.sh"
echo "aliases = {"

echo "SELECT concat('["'"'"', address, '"'"'"] = "'"'"', goto, '"'"'";') FROM alias WHERE address != goto;
SELECT concat('["'"'"', address, '"'"'"] = "'"'"', goto, '"'"'";') FROM (
	select replace(address, concat('@', target_domain), concat('@', alias_domain)) as address, goto FROM alias JOIN alias_domain ON alias_domain.target_domain = SUBSTRING(alias.address, locate('@',alias.address) + 1, length(alias.address))
) a WHERE a.address != a.goto;" | $mysql | sort | uniq

echo "}"