Dodan /usr/sbin/newaliases-gecos u conffiles
[postfix-cn.git] / newaliases-gecos
1 #!/bin/sh
2
3 set -e
4
5 PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
6
7 [ -x /usr/sbin/postalias ] || exit 0
8 [ -f /etc/postfix/main.cf ] || exit 0
9 gecos="/var/lib/postfix-cn/aliases_gecos"
10 grep -q "hash:$gecos" /etc/postfix/main.cf || exit 0
11
12 [ -d /var/lib/postfix-cn/ ] || exit 0
13
14 # Load CARNet Tools
15 . /usr/share/carnet-tools/functions.sh
16
17 getent passwd | awk -F: '
18         $3 >= 100 && $1 != "nobody" && $5 \
19         {
20                 split($5, g, ",");
21                 if (g[1]=="") {next};
22                 gsub(/ /, ".", g[1]);
23                 print tolower(g[1]) ": " $1;
24         }' > $gecos.dpkg-tmp.$$
25
26
27 if ! cmp -s $gecos.dpkg-tmp.$$ $gecos > /dev/null; then
28   cp_mv $gecos.dpkg-tmp.$$ $gecos
29   postalias hash:$gecos
30 else
31   rm -f $gecos.dpkg-tmp.$$
32 fi