Subversion Repositories ALCASAR

Rev

Rev 3020 | Rev 3022 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3020 Rev 3021
Line 26... Line 26...
26
	mail=`grep ^MAIL= $CONF_FILE|cut -d"=" -f2`
26
	mail=`grep ^MAIL= $CONF_FILE|cut -d"=" -f2`
27
	if [ "$mail" = "off" ]; then
27
	if [ "$mail" = "off" ]; then
28
		TYPE_MAIL=0
28
		TYPE_MAIL=0
29
	else
29
	else
30
		TYPE_MAIL=`grep ^MAIL_TYPE= $CONF_FILE|cut -d"=" -f2`
30
		TYPE_MAIL=`grep ^MAIL_TYPE= $CONF_FILE|cut -d"=" -f2`
31
		port=`grep ^MAIL_PORT= $CONF_FILE|cut -d"=" -f2`
31
		smtpPort=`grep ^MAIL_SMTP_PORT= $CONF_FILE|cut -d"=" -f2`
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`
Line 54... Line 54...
54
			;;
54
			;;
55
			3)
55
			3)
56
				TYPE_MAIL=3
56
				TYPE_MAIL=3
57
			;;
57
			;;
58
			p)
58
			p)
59
				port=$OPTARG
59
				smtpPort=$OPTARG
60
			;;
60
			;;
61
			s)
61
			s)
62
				smtpIP=$OPTARG
62
				smtpIP=$OPTARG
63
			;;
63
			;;
64
			m)
64
			m)
Line 87... Line 87...
87
echo "Type=$TYPE_MAIL - port=$port - smtpIP=$smtpIP - mailAddr=$mailAddr - mailMdp=$mailMdp - adminMail=$adminMail - whitedomain=$whiteDomain"
87
echo "Type=$TYPE_MAIL - port=$port - smtpIP=$smtpIP - mailAddr=$mailAddr - mailMdp=$mailMdp - adminMail=$adminMail - whitedomain=$whiteDomain"
88
if  [[ $TYPE_MAIL -eq 0 ]]; then # disable mail service
88
if  [[ $TYPE_MAIL -eq 0 ]]; then # disable mail service
89
	$SED "s/^MAIL=.*/MAIL=off/" $CONF_FILE
89
	$SED "s/^MAIL=.*/MAIL=off/" $CONF_FILE
90
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=/" $CONF_FILE
90
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=/" $CONF_FILE
91
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=/" $CONF_FILE
91
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=/" $CONF_FILE
92
	$SED "s/^MAIL_PORT=.*/MAIL_PORT=/" $CONF_FILE
92
	$SED "s/^MAIL_SMTP_PORT=.*/MAIL_SMTP_PORT=/" $CONF_FILE
93
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=/" $CONF_FILE
93
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=/" $CONF_FILE
94
	$SED "s/^MAIL_PASSWORD=.*/MAIL_PASSWORD=/" $CONF_FILE
94
	$SED "s/^MAIL_PASSWORD=.*/MAIL_PASSWORD=/" $CONF_FILE
95
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=/" $CONF_FILE
95
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=/" $CONF_FILE
96
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=/" $CONF_FILE
96
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=/" $CONF_FILE
97
	$SED "/^SMTP_IP=/ s/^/#/" $LOCAL_IPTABLE_FILE
97
	$SED "/^SMTP_IP=/ s/^/#/" $LOCAL_IPTABLE_FILE
Line 102... Line 102...
102
	[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
102
	[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
103
elif [[ $TYPE_MAIL -eq 2 ]]; then # Enable mail service (relaying to an extern mail server)
103
elif [[ $TYPE_MAIL -eq 2 ]]; then # Enable mail service (relaying to an extern mail server)
104
	$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
104
	$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
105
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=2/" $CONF_FILE
105
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=2/" $CONF_FILE
106
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtpIP/" $CONF_FILE
106
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtpIP/" $CONF_FILE
107
	$SED "s/^MAIL_PORT=.*/MAIL_PORT=$port/" $CONF_FILE
107
	$SED "s/^MAIL_SMTP_PORT=.*/MAIL_SMTP_PORT=$smtpPort/" $CONF_FILE
108
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=/" $CONF_FILE
108
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=/" $CONF_FILE
109
	$SED "s/^MAIL_PASSWORD=.*/MAIL_PASSWORD=/" $CONF_FILE
109
	$SED "s/^MAIL_PASSWORD=.*/MAIL_PASSWORD=/" $CONF_FILE
110
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=$whiteDomain/" $CONF_FILE
110
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=$whiteDomain/" $CONF_FILE
111
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=$adminMail/" $CONF_FILE
111
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=$adminMail/" $CONF_FILE
112
	$SED "s/^#SMTP_IP=.*/SMTP_IP=$smtpIP/" $LOCAL_IPTABLE_FILE
112
	$SED "s/^#SMTP_IP=.*/SMTP_IP=$smtpIP/" $LOCAL_IPTABLE_FILE
113
	$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$port/" $LOCAL_IPTABLE_FILE
113
	$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$smtpPort/" $LOCAL_IPTABLE_FILE
114
	$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
114
	$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
115
	$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
115
	$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
116
	$SED "s/^relayhost =.*/relayhost = $smtpIP:$port/g" $POSTFIX_CONF_FILE
116
	$SED "s/^relayhost =.*/relayhost = $smtpIP:$port/g" $POSTFIX_CONF_FILE
117
	[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
117
	[ -e ${SASLPATH}/sasl_passwd ] && rm -f ${SASLPATH}/sasl_passwd
118
elif [[ $TYPE_MAIL -eq 3 ]]; then # Enable mail service (using an email address)
118
elif [[ $TYPE_MAIL -eq 3 ]]; then # Enable mail service (using an email address)
119
	$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
119
	$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
120
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=3/" $CONF_FILE
120
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=3/" $CONF_FILE
121
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtpIP/" $CONF_FILE
121
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtpIP/" $CONF_FILE
122
	$SED "s/^MAIL_PORT=.*/MAIL_PORT=$port/" $CONF_FILE
122
	$SED "s/^MAIL_SMTP_PORT=.*/MAIL_SMTP_PORT=$smtpPort/" $CONF_FILE
123
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=$mailAddr/" $CONF_FILE
123
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=$mailAddr/" $CONF_FILE
124
	$SED "s/^MAIL_PASSWORD=.*/MAIL_PASSWORD=$mailMdp/" $CONF_FILE
124
	$SED "s/^MAIL_PASSWORD=.*/MAIL_PASSWORD=$mailMdp/" $CONF_FILE
125
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=$whiteDomain/" $CONF_FILE
125
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=$whiteDomain/" $CONF_FILE
126
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=$adminMail/" $CONF_FILE
126
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=$adminMail/" $CONF_FILE
127
	$SED "s/^#SMTP_IP=.*/SMTP_IP=$smtpIP/" $LOCAL_IPTABLE_FILE
127
	$SED "s/^#SMTP_IP=.*/SMTP_IP=$smtpIP/" $LOCAL_IPTABLE_FILE
128
	$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$port/" $LOCAL_IPTABLE_FILE
128
	$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$smtpPort/" $LOCAL_IPTABLE_FILE
129
	$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
129
	$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
130
	$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
130
	$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
131
	$SED "s/^relayhost =.*/relayhost = $smtpIP:$port/g" $POSTFIX_CONF_FILE
131
	$SED "s/^relayhost =.*/relayhost = $smtpIP:$port/g" $POSTFIX_CONF_FILE
132
	[ -d ${SASLPATH} ] || mkdir ${SASLPATH}
132
	[ -d ${SASLPATH} ] || mkdir ${SASLPATH}
133
	echo "[${smtpIP}]:${port} ${mailAddr}:${mailMdp}" > ${SASLPATH}/sasl_passwd
133
	echo "[${smtpIP}]:${port} ${mailAddr}:${mailMdp}" > ${SASLPATH}/sasl_passwd