--- /dev/null
+## !/bin/bash
+#raw
+
+#-----------------------------------------------------------
+install_postfix() {
+
+ echo
+ echo "${HASH_LINE}"
+ echo "Calling install_postfix() ..."
+ echo
+ echo
+ log "Installing and configuring Postfix (local MTA) ..."
+ echo
+
+ local -a main_options_remove=(
+ 'address_verify_map'
+ 'address_verify_relay_transport'
+ 'broken_sasl_auth_clients'
+ 'command_directory'
+ 'daemon_directory'
+ 'data_directory'
+ 'debug_peer_level'
+ 'debugger_command'
+ 'hash_queue_depth'
+ 'html_directory'
+ 'lmtp_tls_loglevel'
+ 'mail_owner'
+ 'manpage_directory'
+ 'masquerade_domains'
+ 'master_service_disable'
+ 'maximal_queue_lifetime'
+ 'queue_directory'
+ 'readme_directory'
+ 'recipient_canonical_maps'
+ 'recipient_delimiter'
+ 'relay_domains'
+ 'sample_directory'
+ 'sender_dependent_default_transport_maps'
+ 'sender_dependent_relayhost_maps'
+ 'setgid_group'
+ 'smtp_sasl_auth_enable'
+ 'smtp_tls_cert_file'
+ 'smtp_tls_enforce_peername'
+ 'smtp_tls_key_file'
+ 'smtp_tls_loglevel'
+ 'smtp_tls_per_site'
+ 'smtp_tls_policy_maps'
+ 'smtp_tls_session_cache_database'
+ 'smtp_use_tls'
+ 'smtpd_client_restrictions'
+ 'smtpd_helo_restrictions'
+ 'smtpd_recipient_restrictions'
+ 'smtpd_relay_restrictions'
+ 'smtpd_sasl_auth_enable'
+ 'smtpd_sasl_authenticated_header'
+ 'smtpd_sasl_local_domain'
+ 'smtpd_sender_restrictions'
+ 'smtpd_tls_auth_only'
+ 'smtpd_tls_CAfile'
+ 'smtpd_tls_cert_file'
+ 'smtpd_tls_key_file'
+ 'smtpd_tls_loglevel'
+ 'smtpd_tls_received_header'
+ 'smtpd_tls_session_cache_database'
+ 'smtpd_use_tls'
+ 'tls_random_prng_update_period'
+ 'tls_random_source'
+ 'transport_maps'
+ 'unknown_local_recipient_reject_code'
+ 'unverified_recipient_reject_code'
+ )
+
+ local -a main_options_set=(
+ 'alias_database = ${default_database_type}:/etc/aliases'
+ 'alias_maps ='
+ 'append_dot_mydomain = no'
+ 'biff = no'
+ 'default_database_type = hash'
+ 'inet_protocols = all'
+ 'local_recipient_maps ='
+ 'local_transport = error:5.1.1 Mailbox unavailable'
+ 'mailbox_size_limit = 0'
+ 'message_size_limit = 358400000'
+ 'mydestination ='
+ "mydomain = ${POSTFIX_MYDOMAIN}"
+ "myhostname = ${hostname}"
+ 'mynetworks = 127.0.0.0/8'
+ "relayhost = ${POSTFIX_RELAYHOST}"
+ 'smtp_generic_maps = ${default_database_type}:/etc/postfix/generic'
+ 'smtp_tls_note_starttls_offer = yes'
+ 'smtp_tls_security_level = none'
+ 'smtpd_banner = $myhostname ESMTP $mail_name $mail_version'
+ 'smtpd_tls_security_level = none'
+ 'virtual_alias_maps = ${default_database_type}:/etc/postfix/virtual'
+ )
+
+
+ if yum install -y postfix mailx ; then
+ :
+ else
+ echo "[$(date)]: Could not install postfix and mailx." | tee -a "${ERROR_POINTER}"
+ fi
+
+ cat <<-EOF >"/etc/postfix/generic"
+
+ apache webmaster+${hostname}
+ apache@localhost webmaster+${hostname}
+ httpd webmaster+${hostname}
+ httpd@localhost webmaster+${hostname}
+ icinga icinga+${hostname}
+ icinga@localhost icinga+${hostname}
+ mysql dba+${hostname}
+ mysql@localhost dba+${hostname}
+ nagios nagios+${hostname}
+ nagios@localhost nagios+${hostname}
+ nginx webmaster+${hostname}
+ nginx@localhost webmaster+${hostname}
+ postgres dba+${hostname}
+ postgres@localhost dba+${hostname}
+ root root+${hostname}
+ root@localhost root+${hostname}
+ xymon xymon+${hostname}
+ xymon@localhost xymon+${hostname}
+
+ # vim: list ts=8
+ EOF
+
+ postmap hash:/etc/postfix/generic
+
+ echo "Backup Postfix configuration ..."
+ cp -pv "/etc/postfix/main.cf" \
+ "/etc/postfix/main.cf.$( date -r /etc/postfix/main.cf +'%Y-%m-%d_%H:%M:%S' ).bak"
+ cp -pv "/etc/postfix/master.cf" \
+ "/etc/postfix/master.cf.$( date -r /etc/postfix/master.cf +'%Y-%m-%d_%H:%M:%S' ).bak"
+ if [[ -f "/etc/postfix/virtual" ]] ; then
+ cp -pv "/etc/postfix/virtual" \
+ "/etc/postfix/virtual.$( date -r /etc/postfix/virtual +'%Y-%m-%d_%H:%M:%S' ).bak"
+ fi
+
+ local option=
+ for option in "${main_options_remove[@]}" ; do
+ echo "Removing postfix option '${option}' ..."
+ postconf -X "${option}"
+ done
+
+ for option in "${main_options_set[@]}" ; do
+ echo "Setting postfix option: '${option}' ..."
+ postconf -e "${option}"
+ done
+
+ local url=
+ local tmp_file=
+
+ echo
+ echo "Getting new master.cf ..."
+ url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/postfix/master.cf"
+ tmp_file=$( mktemp )
+ wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true
+ if [[ -s "${tmp_file}" ]] ; then
+ mv -v "${tmp_file}" /etc/postfix/master.cf
+ fi
+
+ echo
+ echo "Getting new virtuals ..."
+ cp /dev/null "${tmp_file}"
+ url="${COBBLER_URL}/${ws_rel_filesdir}/${system_status}/postfix/virtual"
+ wget -O "${tmp_file}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}" || true
+ if [[ -s "${tmp_file}" ]] ; then
+ mv -v "${tmp_file}" /etc/postfix/virtual
+ fi
+ postmap hash:/etc/postfix/virtual
+
+ rm -fv "${tmp_file}"
+
+ echo
+ echo "${HASH_LINE}"
+ echo "Generated main postfix configuration:"
+ echo
+ postconf -n
+ echo
+ echo "${HASH_LINE}"
+ echo "Generated master postfix configuration:"
+ echo
+ postconf -M
+ echo
+
+}
+
+install_postfix
+
+#end raw
+## vim: ts=4 et list