Mercurial > prosody-modules
diff mod_alias/mod_alias_postfixadmin.sh @ 1953:0c3ba5ff7a3b
mod_alias: New alias module
author | moparisthebest <admin@moparisthebest.com> |
---|---|
date | Sat, 21 Nov 2015 00:10:08 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_alias/mod_alias_postfixadmin.sh Sat Nov 21 00:10:08 2015 -0500 @@ -0,0 +1,20 @@ +#!/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 "}"