Modification : vm_{host,hosted,remote} -> {host,local,remote}/ .
[lhc/ateliers.git] / etc / sv / postfix / local.sh
diff --git a/etc/sv/postfix/local.sh b/etc/sv/postfix/local.sh
new file mode 100644 (file)
index 0000000..0f5b134
--- /dev/null
@@ -0,0 +1,105 @@
+local hint="run before: ./vm_remote runit_configure postfix"
+assert "sudo test -f /etc/postfix/$vm_domainname/smtpd/x509/key.pem" hint
+#warn "lors de l'installation Debian, ne sélectionner aucune configuration pour postfix"
+sudo debconf-set-selections <<-EOF
+       postfix postfix/main_mailer_type        select  No configuration
+       EOF
+"$tool"/local/apt-get-install postfix procmail postfix-pcre
+"$tool"/local/insserv-remove  postfix
+sudo install -m 640 -o root -g root /dev/stdin /etc/postfix/.gitignore <<-EOF
+       *.db
+       EOF
+sudo install -d -m 771 -o root -g root \
+ /etc/postfix/ \
+ /etc/postfix/$vm_domainname/ \
+ /etc/postfix/$vm_domainname/smtp \
+ /etc/postfix/$vm_domainname/smtp/x509 \
+ /etc/postfix/$vm_domainname/smtp/x509/ca \
+ /etc/postfix/$vm_domainname/smtpd \
+ /etc/postfix/$vm_domainname/smtpd/x509 \
+ /etc/postfix/$vm_domainname/smtpd/x509/ca
+sudo ln -fns \
+ ../crt+crl.self-signed.pem \
+ /etc/postfix/$vm_domainname/smtpd/x509/ca/crt.pem
+sudo install -m 400 -o root -g root \
+ "$tool"/var/pub/x509/smtpd.$vm_domainname/crt+crl.self-signed.pem \
+    /etc/postfix/$vm_domainname/smtpd/x509/crt+crl.self-signed.pem
+sudo install -m 400 -o root -g root \
+ "$tool"/var/pub/x509/smtpd.$vm_domainname/crt.pem \
+    /etc/postfix/$vm_domainname/smtpd/x509/crt.pem
+sudo install -m 400 -o root -g root \
+ "$tool"/var/pub/x509/smtpd.$vm_domainname/crt+ca.pem \
+    /etc/postfix/$vm_domainname/smtpd/x509/crt+ca.pem
+sudo install -m 400 -o root -g root \
+ "$tool"/var/pub/x509/smtpd.$vm_domainname/crt+crl.self-signed.pem \
+    /etc/postfix/$vm_domainname/smtpd/x509/crt+crl.self-signed.pem
+sudo install -m 640 -o root -g root \
+ "$tool"/etc/postfix/$vm_domainname/header_checks \
+        /etc/postfix/$vm_domainname/header_checks
+m4 \
+ --define=VM_DOMAINNAME="$vm_domainname" \
+ <"$tool"/etc/postfix/aliases.m4 |
+sudo install -m 644 -o root -g root /dev/stdin \
+ /etc/postfix/aliases
+sudo newaliases -oA/etc/postfix/aliases
+sudo ln -fns \
+ /etc/postfix/aliases \
+ /etc/aliases
+cat /dev/stdin "$tool"/etc/postfix/main.cf <<-EOF |
+       mydomain      = $vm_domainname
+       myorigin      = \$mydomain
+       myhostname    = $vm_hostname.\$mydomain
+       mail_name     = \$myhostname
+       mydestination = $vm_hostname \$myhostname \$myorigin
+       EOF
+sudo install -m 644 -o root -g root /dev/stdin \
+ /etc/postfix/main.cf
+sudo install -m 640 -o root -g root \
+ "$tool"/etc/postfix/master.cf \
+        /etc/postfix/master.cf
+sudo install -m 640 -o root -g root \
+ "$tool"/etc/postfix/$vm_domainname/smtp/x509/policy \
+        /etc/postfix/$vm_domainname/smtp/x509/policy
+sudo postmap hash:/etc/postfix/$vm_domainname/smtp/x509/policy
+sudo install -m 640 -o root -g root \
+ "$tool"/etc/postfix/$vm_domainname/smtp/header_checks \
+        /etc/postfix/$vm_domainname/smtp/header_checks
+sudo install -m 640 -o root -g root \
+ "$tool"/etc/postfix/$vm_domainname/smtpd/sender_access \
+        /etc/postfix/$vm_domainname/smtpd/sender_access
+sudo postmap hash:/etc/postfix/$vm_domainname/smtpd/sender_access
+sudo install -m 640 -o root -g root \
+ "$tool"/etc/postfix/$vm_domainname/smtpd/client_blacklist \
+        /etc/postfix/$vm_domainname/smtpd/client_blacklist
+sudo postmap hash:/etc/postfix/$vm_domainname/smtpd/client_blacklist
+sudo install -m 640 -o root -g root \
+ "$tool"/etc/postfix/$vm_domainname/smtpd/relay_clientcerts \
+        /etc/postfix/$vm_domainname/smtpd/relay_clientcerts
+sudo postmap hash:/etc/postfix/$vm_domainname/smtpd/relay_clientcerts
+sudo install -m 640 -o root -g root \
+ "$tool"/etc/postfix/$vm_domainname/transport \
+        /etc/postfix/$vm_domainname/transport
+sudo postmap hash:/etc/postfix/$vm_domainname/transport
+sudo install -m 640 -o root -g root \
+ "$tool"/etc/postfix/$vm_domainname/virtual_alias \
+        /etc/postfix/$vm_domainname/virtual_alias
+sudo postmap hash:/etc/postfix/$vm_domainname/virtual_alias
+sudo install -d -m 770 -o root -g root \
+ /etc/skel/etc/mail \
+ /etc/skel/var/cache/mail \
+ /etc/skel/var/log/mail \
+ /etc/skel/var/mail
+sudo install -m 660 -o root -g root \
+ "$tool"/etc/skel/etc/mail/delivery.procmailrc \
+        /etc/skel/etc/mail/delivery.procmailrc
+#-- SYMPA begin
+sudo install -d -m 755 -o root -g root \
+ /etc/sympa
+#sudo -u sympa newaliases -oA/etc/mail/sympa/aliases
+sudo install -m 640 -o "$sv" -g sympa \
+ "$tool"/etc/sympa/transport \
+        /etc/sympa/transport
+sudo install -m 640 -o "$sv" -g sympa \
+ "$tool"/etc/sympa/virtual_alias \
+        /etc/sympa/virtual_alias
+#-- SYMPA end