Browse Source

Adding initial app setup to setup script

Joe Ceresini 7 years ago
parent
commit
54ba5b9df5
1 changed files with 22 additions and 3 deletions
  1. 22 3
      setup.sh

+ 22 - 3
setup.sh

@@ -1,12 +1,20 @@
 #!/bin/bash
 
-# Ensure we are up-to-date and have postfix installed
+################################################################
+# Prerequisites 
+################################################################
+
+# Ensure we are up-to-date and have required software installed
 yum update -y
-yum install postfix -y
+yum install postfix python-virtualenv -y
 
 # Create user for handling mail
 useradd -m -s /sbin/nologin incoming
 
+################################################################
+# Setup postfix
+################################################################
+
 # Remove defaults that may interfere
 sed -i -e 's/^\s*\(inet_interfaces\s*=\)/#\1/' \
        -e 's/^\s*\(mydestination\s*=\)/#\1/' \
@@ -26,7 +34,7 @@ home_mailbox = Maildir/
 EOF
 
 # Disable ALL bounces
-sed -i 's/^\(.*\)bounce$/\1discard/' /etc/postfix/master.cf
+sed -i 's/^\(bounce\s.*\)bounce$/\1discard/' /etc/postfix/master.cf
 
 # Write aliases for users we want to handle mail for
 cat <<EOF > /etc/postfix/virtual_aliases
@@ -37,4 +45,15 @@ EOF
 # Restart postfix
 systemctl restart postfix
 
+################################################################
+# Setup mailparser environment
+################################################################
+
+# Setup virtualenv from which we will run everything
+# (this helps prevent yum from breaking functionality) 
 
+sudo -u incoming bash -c " \
+	virtualenv ~incoming/venv \
+	source ~incoming/venv/bin/activate \
+	pip install mailbox requests \
+	"