Mercurial > prosody-modules
comparison 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 |
comparison
equal
deleted
inserted
replaced
1952:9d0c33ebbcc5 | 1953:0c3ba5ff7a3b |
---|---|
1 #!/bin/sh | |
2 # Copyright (C) 2015 Travis Burtrum | |
3 # This file is MIT/X11 licensed. | |
4 | |
5 # run like ./mod_alias_postfixadmin.sh "mysql -N -upostfixadmin -ppostfixadmin postfixadmin" > /etc/prosody/aliases.cfg.lua | |
6 # then put: | |
7 # Include "aliases.cfg.lua" | |
8 # in prosody.cfg.lua | |
9 | |
10 mysql="$1" | |
11 | |
12 echo "-- alias plugin, generated by mod_alias_postfixadmin.sh" | |
13 echo "aliases = {" | |
14 | |
15 echo "SELECT concat('["'"'"', address, '"'"'"] = "'"'"', goto, '"'"'";') FROM alias WHERE address != goto; | |
16 SELECT concat('["'"'"', address, '"'"'"] = "'"'"', goto, '"'"'";') FROM ( | |
17 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)) | |
18 ) a WHERE a.address != a.goto;" | $mysql | sort | uniq | |
19 | |
20 echo "}" |