]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Starting with installing postfix
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 10 Apr 2018 16:34:33 +0000 (18:34 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 10 Apr 2018 16:34:33 +0000 (18:34 +0200)
bin/postinst

index 0d0b121a408e878f924adfb00f0c4abbbc6a710f..6114ca6d2fa1cd24736b5ba0775641db69d98055 100644 (file)
@@ -16,6 +16,12 @@ SIMPLE_HOSTNAME=$( echo "${hostname}" | cut -d. -f1 )
 
 ROOT_PW_CRYPTED="\$6\$I0yXrNsT\$YU3ekjNLy1KTWLRVNww8YM1xtO8FXgTEFhOANS.HB8baj7CxNMRCoxDQh5oFYkZbli67s4pwZ36aNchD2YL.G0"
 
+GIT_ACCOUNT="vmware-provisioning"
+GIT_PASSWD="shiesa&a4taich+iecah8Chu"
+GIT_REPO_DIR="postfix_config"
+GIT_REPO="https://@@acount@@:@@pwd@@@git.pixelpark.com/ppadmin/${GIT_REPO_DIR}.git"
+POSTFIX_MYORIGIN='pixelpark.net'
+
 echo
 echo "Some information:"
 echo "  \$hostname:             $hostname"
@@ -369,7 +375,7 @@ make_pp_dirs() {
 #-----------------------------------------------------------
 misc_packages() {
 
-    local misc_pkgs="ksh tmux vim telnet curl"
+    local misc_pkgs="ksh tmux vim telnet curl git"
     local misc_pkgs_remove="deltarpm nfs* rpcbind abrt*"
 
     echo "Disabling mysql-community in /etc/yum.conf ..."
@@ -680,6 +686,121 @@ install_clamav() {
 
 }
 
+#-----------------------------------------------------------
+install_postfix() {
+
+    echo
+    log "Installing and configuring Postfix ..."
+
+    local -a main_options_remove=(
+        'command_directory'
+        'daemon_directory'
+        'data_directory'
+        'debug_peer_level'
+        'debugger_command'
+        'html_directory'
+        'lmtp_tls_loglevel'
+        'mail_owner'
+        'manpage_directory'
+        'queue_directory'
+        '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_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'
+        'unknown_local_recipient_reject_code'
+    )
+
+    local -a main_options_set=(
+        'append_dot_mydomain = no'
+        'biff = no'
+        'default_database_type = hash'
+        'inet_protocols = all'
+        'mailbox_size_limit = 0'
+        'message_size_limit = 358400000'
+        "mydomain = ${POSTFIX_MYORIGIN}"
+        "myhostname = ${hostname}"
+        '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'
+    )
+
+
+    yum install -y postfix mailx
+
+    cat <<-EOF >"/etc/postfix/generic"
+
+       root                    root+${hostname}
+       root@localhost          root+${hostname}
+       icinga                  icinga+${hostname}
+       icinga@localhost                icinga+${hostname}
+       nagios                  nagios+${hostname}
+       nagios@localhost                nagios+${hostname}
+       xymon                   xymon+${hostname}
+       xymon@localhost         xymon+${hostname}
+
+       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"
+
+    local option=
+    for option in "${main_options_remove[@]}" ; do
+        echo "Removing postfix option '${option}' ..."
+        sed -i -e "s/^\\(${option}( |$).*\\)/#\\1/" "/etc/postfix/main.cf"
+    done
+
+    for option in "${main_options_set[@]}" ; do
+        echo "Setting postfix option: '${option}' ..."
+        postfix -e "${option}"
+    done
+
+    mkdir -pv /var/tmp
+    cd /var/tmp
+
+    local url=$( echo "${GIT_REPO}" | sed -e "s/@@acount@@/${GIT_ACCOUNT}/" \
+                                          -e "s/@@pwd@@/${GIT_PASSWD}/" )
+    echo "Using Git URL: '${url}' ..."
+
+    git clone "${url}"
+    cd "${GIT_REPO_DIR}"
+
+    cd ..
+    echo "Removing '${GIT_REPO_DIR}'"
+    rm -rf "${GIT_REPO_DIR}"
+    cd
+
+}
+
 #-----------------------------------------------------------
 config_rsyslog_to_remote() {