source: bearmail/debian/bearmail.postinst @ 454

Last change on this file since 454 was 454, checked in by ben, 11 years ago

cleaning

File size: 2.6 KB
Line 
1#!/bin/bash
2set -e
3
4if [ "$1" = "configure" ]; then
5 
6  # create the bearmail user
7  if [ -z "`id -u bearmail 2> /dev/null`" ]; then
8    adduser --system --shell /usr/sbin/nologin --group --home /var/spool/bearmail \
9            --gecos "Bearmail - virtual users" --disabled-password \
10            --disabled-login --quiet bearmail || true
11    chown -R bearmail:bearmail /var/spool/bearmail
12    chmod -R 770 /var/spool/bearmail
13  fi
14 
15  # Generate new SSL certs if needed
16  if [ "$1" = configure ] && [ "$2" = "" ]; then
17    # Make self-signed certificate
18    if [ ! -f /etc/ssl/private/bearmail.pem ]; then
19        make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/private/bearmail.pem
20        cp -a /etc/ssl/private/bearmail.pem /etc/ssl/certs/
21    fi
22  fi
23
24  # If it's a new installation of bearmail :
25  if [ ! -f /etc/bearmail/mailmap ] ; then
26    HOSTNAME=`cat /etc/mailname`
27    BEARMAIL_UID=`id -u bearmail`
28    BEARMAIL_GID=`id -g bearmail`
29
30    # set global conf file for sieve
31    touch /etc/bearmail/dovecot/bearmail-sieve/global.conf
32    chown -R bearmail:bearmail /etc/bearmail/dovecot/bearmail-sieve
33
34    # set hostname in conf files
35    for conffile in postfix/main.cf postfix/master.cf dovecot/dovecot.conf; do
36      sed -e "s/bearmail.tld/$HOSTNAME/g" -i /etc/bearmail/$conffile
37      sed -e "s/bearmail_uid/$BEARMAIL_UID/g" -i /etc/bearmail/$conffile
38      sed -e "s/bearmail_gid/$BEARMAIL_GID/g" -i /etc/bearmail/$conffile     
39    done
40
41    # Create mailmap and Setting default domain
42    #echo "Warning: setting $HOSTNAME to virtual domains in bearmail. \
43#Please RTFM."
44    # generate random passwd foor root
45 #   MY_PASSWD=`perl -e '@c=("A".."Z","a".."z",0..9);\
46 #                       print join("",@c[map{rand @c}(1..8)])'`
47 #   MY_PLAIN_MD5=`echo -n "$MY_PASSWD" | md5sum | sed -e "s/  -$//"`
48
49    cat > /etc/bearmail/mailmap << EOF
50# /etc/bearmail/mailmap - Sample mail account configuration
51#
52# Examples :
53## creating a regular_account :
54#bob@company.com:9a8ad92c50cae39aa2c5604fd0ab6d8c:local
55#
56## creating an alias :
57#info@company.com::bob@company.com,alice@people.net
58#
59## use an external_program (regular)
60#fortune@company.com::|/bin/fortune
61#
62## a catchall :
63#*@company.com::info@company.com,alice@helpdesk.net
64#
65## a domain_alias :
66#*@other.com::*@spam.com
67#
68# Read the fine manual for more informations
69
70EOF
71
72    #  echo "Adding $HOSTNAME domain .. done"
73#    echo "Your password for root@$HOSTNAME"
74#    echo "    will be : $MY_PASSWD"
75
76#    echo "$HOSTNAME" > /etc/mailname
77    echo "$HOSTNAME REJECT You are not me!" >> /etc/bearmail/postfix/bearmail-helo_access
78  fi
79fi
80
81# a mettre dans le switch off : faire des postmap de client_access helo_access etc
82
83
84#DEBHELPER#
Note: See TracBrowser for help on using the repository browser.