From c96080697a03bc4a268245725681ef6de6abe7a9 Mon Sep 17 00:00:00 2001 From: "Jer (on server)" Date: Wed, 30 Nov 2016 21:30:17 +0000 Subject: [PATCH] Add Postfix support --- Makefile | 5 ++++- config.local.php | 28 ++++++++++++++++++++++++++++ postfixadmin.conf | 5 +++++ setup-postfix.sh | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 config.local.php create mode 100644 postfixadmin.conf create mode 100755 setup-postfix.sh diff --git a/Makefile b/Makefile index eec301f..6e02f28 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,10 @@ DST := /etc/postfix INPUTS := configuration/* configuration/mysql/* -all: $(INPUTS:configuration/%=$(DST)/%) +all: $(INPUTS:configuration/%=$(DST)/%) postfixadmin + +postfixadmin: + ./setup-postfix.sh $(DST)/%: $(SRC)/% @mkdir -p $(@D) diff --git a/config.local.php b/config.local.php new file mode 100644 index 0000000..6a47fcd --- /dev/null +++ b/config.local.php @@ -0,0 +1,28 @@ + 'abuse@pley.net', + 'hostmaster' => 'hostmaster@pley.net', + 'postmaster' => 'postmaster@pley.net', + 'webmaster' => 'webmaster@pley.net' +); +$CONF['domain_path'] = 'YES'; +$CONF['transport'] = 'YES'; +$CONF['transport_options'] = array ( + 'virtual', // for virtual accounts + 'local', // for system accounts + 'relay' // for backup mx + 'mailman' // for mailing lists +); + +$CONF['user_footer_link'] = "http://mail.pley.net/postfixadmin/main"; +$CONF['show_footer_text'] = 'NO'; diff --git a/postfixadmin.conf b/postfixadmin.conf new file mode 100644 index 0000000..68b439a --- /dev/null +++ b/postfixadmin.conf @@ -0,0 +1,5 @@ +Alias /postfixadmin /usr/local/share/postfixadmin + + +AllowOverride all + diff --git a/setup-postfix.sh b/setup-postfix.sh new file mode 100755 index 0000000..b19e9e2 --- /dev/null +++ b/setup-postfix.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +if [[ -z "$( mysql -u root -e 'SELECT User FROM mysql.user WHERE User = "postfix"' )" ]]; then + echo Creating \"postfix\" user. + mysql -u root -e 'CREATE USER "postfix"@"localhost" IDENTIFIED BY "postfix"' +fi + +if [[ -z "$( mysql -u root -e 'SHOW DATABASES LIKE "postfix"' )" ]]; then + echo Creating \"postfix\" database. + mysql -u root -e 'CREATE DATABASE postfix' + mysql -u root -e 'GRANT ALL PRIVILEGES ON postfix.* TO "postfix"@"localhost"' + mysql -u root -e 'FLUSH PRIVILEGES' +fi + +if [[ ! -d /usr/local/share/postfixadmin ]]; then + echo Installing postfixadmin + if [[ ! -d postfixadmin-code ]]; then + svn checkout svn://svn.code.sf.net/p/postfixadmin/code/tags/postfixadmin-2.3.8 postfixadmin-code + fi + + sudo rsync -av --exclude '.svn' postfixadmin-code/ /usr/local/share/postfixadmin +fi + +if [[ config.local.php -nt /usr/local/share/postfixadmin/config.local.php ]]; then + echo Configuring postfixadmin. + sudo cp config.local.php /usr/local/share/postfixadmin/config.local.php +fi + +if [[ postfixadmin.conf -nt /etc/httpd/conf.d/postfixadmin.conf ]]; then + echo Configuring postfixadmin in Apache. + sudo cp postfixadmin.conf /etc/httpd/conf.d/postfixadmin.conf +fi -- 2.40.1