Line 32... |
Line 32... |
32 |
smtpIP=`grep ^MAIL_SMTP_IP= $CONF_FILE|cut -d"=" -f2`
|
32 |
smtpIP=`grep ^MAIL_SMTP_IP= $CONF_FILE|cut -d"=" -f2`
|
33 |
mailAddr=`grep ^MAIL_ADDR= $CONF_FILE|cut -d"=" -f2`
|
33 |
mailAddr=`grep ^MAIL_ADDR= $CONF_FILE|cut -d"=" -f2`
|
34 |
mailMdp=`grep ^MAIL_PASSWORD= $CONF_FILE|cut -d"=" -f2`
|
34 |
mailMdp=`grep ^MAIL_PASSWORD= $CONF_FILE|cut -d"=" -f2`
|
35 |
adminMail=`grep ^MAIL_ADMIN= $CONF_FILE|cut -d"=" -f2`
|
35 |
adminMail=`grep ^MAIL_ADMIN= $CONF_FILE|cut -d"=" -f2`
|
36 |
whiteDomain=`grep ^MAIL_WHTEDOMAIN= $CONF_FILE|cut -d"=" -f2`
|
36 |
whiteDomain=`grep ^MAIL_WHTEDOMAIN= $CONF_FILE|cut -d"=" -f2`
|
- |
|
37 |
domainName=`grep ^DOMAIN= $CONF_FILE|cut -d"=" -f2`
|
- |
|
38 |
hostName=`grep ^HOSTNAME= $CONF_FILE|cut -d"=" -f2`
|
- |
|
39 |
|
37 |
fi
|
40 |
fi
|
38 |
else # apply args
|
41 |
else # apply args
|
39 |
if [ "$1" = "-h" ] || [ "$1" = "--h" ]; then
|
42 |
if [ "$1" = "-h" ] || [ "$1" = "--h" ]; then
|
40 |
echo $usage
|
43 |
echo $usage
|
41 |
exit 0
|
44 |
exit 0
|
Line 97... |
Line 100... |
97 |
$SED "/^SMTP_PORT=/ s/^/#/" $LOCAL_IPTABLE_FILE
|
100 |
$SED "/^SMTP_PORT=/ s/^/#/" $LOCAL_IPTABLE_FILE
|
98 |
$SED "s/^\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT.*/#\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT -d \$SMTP_IP -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
101 |
$SED "s/^\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT.*/#\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT -d \$SMTP_IP -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
99 |
$SED "s/^\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT.*/#\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT -s \$SMTP_IP -m conntrack --ctstate ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
102 |
$SED "s/^\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT.*/#\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT -s \$SMTP_IP -m conntrack --ctstate ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
100 |
$SED "s/^relayhost =.*/relayhost =/" $POSTFIX_CONF_FILE
|
103 |
$SED "s/^relayhost =.*/relayhost =/" $POSTFIX_CONF_FILE
|
101 |
$SED "s/^smtp_tls_security_level =.*/smtp_tls_security_level = may/g" $POSTFIX_CONF_FILE
|
104 |
$SED "s/^smtp_tls_security_level =.*/smtp_tls_security_level = may/g" $POSTFIX_CONF_FILE
|
102 |
$SED "/^smtp_tls_wrappermode = yes/d" $POSTFIX_CONF_FILE
|
105 |
$SED "s/^smtp_tls_wrappermode =.*/smtp_tls_wrappermode = no/g" $POSTFIX_CONF_FILE
|
- |
|
106 |
$SED "s/^myhostname =.*/myhostname = $hostName.$domainName/g" $POSTFIX_CONF_FILE
|
103 |
[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
|
107 |
[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
|
104 |
elif [[ $TYPE_MAIL -eq 1 ]]; then # Enable mail service (act as smtp server)
|
108 |
elif [[ $TYPE_MAIL -eq 1 ]]; then # Enable mail service (act as smtp server)
|
105 |
$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
|
109 |
$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
|
106 |
$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=1/" $CONF_FILE
|
110 |
$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=1/" $CONF_FILE
|
107 |
$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=/" $CONF_FILE
|
111 |
$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=/" $CONF_FILE
|
108 |
$SED "s/^MAIL_SMTP_PORT=.*/MAIL_SMTP_PORT=/" $CONF_FILE
|
112 |
$SED "s/^MAIL_SMTP_PORT=.*/MAIL_SMTP_PORT=$smtpPort/" $CONF_FILE
|
109 |
$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=/" $CONF_FILE
|
113 |
$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=/" $CONF_FILE
|
110 |
$SED "s/^MAIL_PASSWORD=.*/MAIL_PASSWORD=/" $CONF_FILE
|
114 |
$SED "s/^MAIL_PASSWORD=.*/MAIL_PASSWORD=/" $CONF_FILE
|
111 |
$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=$whiteDomain/" $CONF_FILE
|
115 |
$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=$whiteDomain/" $CONF_FILE
|
112 |
$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=$adminMail/" $CONF_FILE
|
116 |
$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=$adminMail/" $CONF_FILE
|
113 |
$SED "/^SMTP_IP=/ s/^/#/" $LOCAL_IPTABLE_FILE
|
117 |
$SED "/^SMTP_IP=/ s/^/#/" $LOCAL_IPTABLE_FILE
|
114 |
$SED "/^SMTP_PORT=/ s/^/#/" $LOCAL_IPTABLE_FILE
|
118 |
$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$smtpPort/" $LOCAL_IPTABLE_FILE
|
115 |
$SED "s/^\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT.*/#\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT -d \$SMTP_IP -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
119 |
$SED "s/^#\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT.*/\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
116 |
$SED "s/^\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT.*/#\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT -s \$SMTP_IP -m conntrack --ctstate ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
120 |
$SED "s/^#\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT.*/\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT -m conntrack --ctstate ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
117 |
$SED "s/^relayhost =.*/relayhost =/" $POSTFIX_CONF_FILE
|
121 |
$SED "s/^relayhost =.*/relayhost =/" $POSTFIX_CONF_FILE
|
118 |
$SED "s/^smtp_tls_security_level =.*/smtp_tls_security_level = may/g" $POSTFIX_CONF_FILE
|
122 |
$SED "s/^smtp_tls_security_level =.*/smtp_tls_security_level = may/g" $POSTFIX_CONF_FILE
|
119 |
$SED "/^smtp_tls_wrappermode = yes/d" $POSTFIX_CONF_FILE
|
123 |
$SED "s/^smtp_tls_wrappermode =.*/smtp_tls_wrappermode = no/g" $POSTFIX_CONF_FILE
|
- |
|
124 |
$SED "s/^myhostname =.*/myhostname = $hostName.$domainName/g" $POSTFIX_CONF_FILE
|
120 |
[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
|
125 |
[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
|
121 |
elif [[ $TYPE_MAIL -eq 2 ]]; then # Enable mail service (relaying to an extern mail server)
|
126 |
elif [[ $TYPE_MAIL -eq 2 ]]; then # Enable mail service (relaying to an extern mail server)
|
122 |
$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
|
127 |
$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
|
123 |
$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=2/" $CONF_FILE
|
128 |
$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=2/" $CONF_FILE
|
124 |
$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtpIP/" $CONF_FILE
|
129 |
$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtpIP/" $CONF_FILE
|
Line 131... |
Line 136... |
131 |
$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$smtpPort/" $LOCAL_IPTABLE_FILE
|
136 |
$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$smtpPort/" $LOCAL_IPTABLE_FILE
|
132 |
$SED "s/^#\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT.*/\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT -d \$SMTP_IP -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
137 |
$SED "s/^#\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT.*/\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT -d \$SMTP_IP -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
133 |
$SED "s/^#\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT.*/\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT -s \$SMTP_IP -m conntrack --ctstate ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
138 |
$SED "s/^#\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT.*/\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT -s \$SMTP_IP -m conntrack --ctstate ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
134 |
$SED "s/^relayhost =.*/relayhost = $smtpIP:$smtpPort/g" $POSTFIX_CONF_FILE
|
139 |
$SED "s/^relayhost =.*/relayhost = $smtpIP:$smtpPort/g" $POSTFIX_CONF_FILE
|
135 |
$SED "s/^smtp_tls_security_level =.*/smtp_tls_security_level = may/g" $POSTFIX_CONF_FILE
|
140 |
$SED "s/^smtp_tls_security_level =.*/smtp_tls_security_level = may/g" $POSTFIX_CONF_FILE
|
136 |
$SED "/^smtp_tls_wrappermode = yes/d" $POSTFIX_CONF_FILE
|
141 |
$SED "s/^smtp_tls_wrappermode =.*/smtp_tls_wrappermode = no/g" $POSTFIX_CONF_FILE
|
- |
|
142 |
$SED "s/^myhostname =.*/myhostname = $hostName.$domainName/g" $POSTFIX_CONF_FILE
|
137 |
[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
|
143 |
[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
|
138 |
elif [[ $TYPE_MAIL -eq 3 ]]; then # Enable mail service (using an email address)
|
144 |
elif [[ $TYPE_MAIL -eq 3 ]]; then # Enable mail service (using an email address)
|
139 |
$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
|
145 |
$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
|
140 |
$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=3/" $CONF_FILE
|
146 |
$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=3/" $CONF_FILE
|
141 |
$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtpIP/" $CONF_FILE
|
147 |
$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtpIP/" $CONF_FILE
|
Line 148... |
Line 154... |
148 |
$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$smtpPort/" $LOCAL_IPTABLE_FILE
|
154 |
$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$smtpPort/" $LOCAL_IPTABLE_FILE
|
149 |
$SED "s/^#\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT.*/\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
155 |
$SED "s/^#\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT.*/\$IPTABLES -A OUTPUT -p tcp --dport \$SMTP_PORT -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
150 |
$SED "s/^#\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT.*/\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT -m conntrack --ctstate ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
156 |
$SED "s/^#\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT.*/\$IPTABLES -A INPUT -p tcp --sport \$SMTP_PORT -m conntrack --ctstate ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
|
151 |
$SED "s/^relayhost =.*/relayhost = $smtpIP:$smtpPort/g" $POSTFIX_CONF_FILE
|
157 |
$SED "s/^relayhost =.*/relayhost = $smtpIP:$smtpPort/g" $POSTFIX_CONF_FILE
|
152 |
$SED "s/^smtp_tls_security_level =.*/smtp_tls_security_level = encrypt/g" $POSTFIX_CONF_FILE
|
158 |
$SED "s/^smtp_tls_security_level =.*/smtp_tls_security_level = encrypt/g" $POSTFIX_CONF_FILE
|
153 |
$SED "/^smtp_tls_wrappermode = yes/d" $POSTFIX_CONF_FILE
|
159 |
$SED "s/^smtp_tls_wrappermode =.*/smtp_tls_wrappermode = yes/g" $POSTFIX_CONF_FILE
|
- |
|
160 |
if [ "$domainName" = "localdomain" ]; then # use a real domain name to avoid extern smtp server reject
|
- |
|
161 |
$SED "s/^myhostname =.*/myhostname = alcasar.net/g" $POSTFIX_CONF_FILE
|
- |
|
162 |
else
|
- |
|
163 |
$SED "s/^myhostname =.*/myhostname = $hostName.$domainName/g" $POSTFIX_CONF_FILE
|
- |
|
164 |
fi
|
154 |
[ -d ${SASLPATH} ] || mkdir ${SASLPATH}
|
165 |
[ -d ${SASLPATH} ] || mkdir ${SASLPATH}
|
155 |
echo "[${smtpIP}]:${smtpPort} ${mailAddr}:${mailMdp}" > ${SASLPATH}/sasl_passwd
|
166 |
echo "[${smtpIP}]:${smtpPort} ${mailAddr}:${mailMdp}" > ${SASLPATH}/sasl_passwd
|
156 |
postmap ${SASLPATH}/sasl_passwd
|
167 |
postmap ${SASLPATH}/sasl_passwd
|
157 |
chmod -R 644 ${SASLPATH}
|
168 |
chmod -R 644 ${SASLPATH}
|
158 |
chown root:root ${SASLPATH}/sasl_passwd*
|
169 |
chown root:root ${SASLPATH}/sasl_passwd*
|