Subversion Repositories ALCASAR

Rev

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

Rev 2994 Rev 2997
Line 10... Line 10...
10
# ****** Paths - chemin des commandes *******
10
# ****** Paths - chemin des commandes *******
11
SED="/bin/sed -i"
11
SED="/bin/sed -i"
12
CONF_FILE="/usr/local/etc/alcasar.conf"
12
CONF_FILE="/usr/local/etc/alcasar.conf"
13
POSTFIX_CONF_FILE="/etc/postfix/main.cf"
13
POSTFIX_CONF_FILE="/etc/postfix/main.cf"
14
LOCAL_IPTABLE_FILE="/usr/local/etc/alcasar-iptables-local.sh"
14
LOCAL_IPTABLE_FILE="/usr/local/etc/alcasar-iptables-local.sh"
15
saslPath="/etc/postfix/sasl"
15
SASLPATH="/etc/postfix/sasl"
16
smtpIP="0.0.0.0/0"
16
smtpIP="0.0.0.0/0"
17
 
17
 
18
usage="Usage: alcasar-mail_install.sh 0|1|2|3"
18
usage="Usage: alcasar-mail_install.sh 0|1|2|3"
19
nb_args=$#
19
nb_args=$#
20
if [ $nb_args -eq 0 ]
20
if [ $nb_args -eq 0 ]
Line 76... Line 76...
76
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=/" $CONF_FILE
76
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=/" $CONF_FILE
77
	$SED "s/^MAIL_SMTP=.*/MAIL_SMTP=/" $CONF_FILE
77
	$SED "s/^MAIL_SMTP=.*/MAIL_SMTP=/" $CONF_FILE
78
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=/" $CONF_FILE
78
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=/" $CONF_FILE
79
	$SED "s/^MAIL_PORT=.*/MAIL_PORT=/" $CONF_FILE
79
	$SED "s/^MAIL_PORT=.*/MAIL_PORT=/" $CONF_FILE
80
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=/" $CONF_FILE
80
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=/" $CONF_FILE
81
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAINE=/" $CONF_FILE
81
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=/" $CONF_FILE
82
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=/" $CONF_FILE
82
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=/" $CONF_FILE
83
	$SED "/^SMTP_IP/ s/^/#/" $LOCAL_IPTABLE_FILE
83
	$SED "/^SMTP_IP=/ s/^/#/" $LOCAL_IPTABLE_FILE
84
	$SED "/^SMTP_PORT/ s/^/#/g" $LOCAL_IPTABLE_FILE
84
	$SED "/^SMTP_PORT=/ s/^/#/" $LOCAL_IPTABLE_FILE
85
	$SED "/^\$IPTABLES -A OUTPUT -p tcp -d \$SMTP_IP/ s/^/#/" $LOCAL_IPTABLE_FILE
85
	$SED "/^\$IPTABLES -A OUTPUT -p tcp -d \$SMTP_IP/ s/^/#/" $LOCAL_IPTABLE_FILE
86
	$SED "/^\$IPTABLES -A INPUT  -p tcp -s \$SMTP_IP/ s/^/#/g" $LOCAL_IPTABLE_FILE
86
	$SED "/^\$IPTABLES -A INPUT  -p tcp -s \$SMTP_IP/ s/^/#/g" $LOCAL_IPTABLE_FILE
87
	$SED "s/^relayhost =.*/relayhost =/g" $POSTFIX_CONF_FILE
87
	$SED "s/^relayhost =.*/relayhost =/" $POSTFIX_CONF_FILE
88
elif [[ $TYPE_MAIL -eq 2 ]]; then # relay to an extern mail server
88
elif [[ $TYPE_MAIL -eq 2 ]]; then # Enable mail service (relaying to an extern mail server)
89
	echo "relayhost = [${smtp}]:${port}" >> /etc/postfix/main.cf
89
	echo "relayhost = [${smtp}]:${port}" >> /etc/postfix/main.cf
90
elif [[ $TYPE_MAIL -eq 3 ]]; then # use an email address
90
elif [[ $TYPE_MAIL -eq 3 ]]; then # Enable mail service (using an email address)
91
	$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
91
	$SED "s/^MAIL=.*/MAIL=on/" $CONF_FILE
92
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=3/" $CONF_FILE
92
	$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=3/" $CONF_FILE
93
	$SED "s/^MAIL_SMTP=.*/MAIL_SMTP=/" $CONF_FILE
93
	$SED "s/^MAIL_SMTP=.*/MAIL_SMTP=/" $CONF_FILE
94
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtp/" $CONF_FILE
94
	$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=$smtp/" $CONF_FILE
95
	$SED "s/^MAIL_PORT=.*/MAIL_PORT=$port/" $CONF_FILE
95
	$SED "s/^MAIL_PORT=.*/MAIL_PORT=$port/" $CONF_FILE
96
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=$mailAddr/" $CONF_FILE
96
	$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=$mailAddr/" $CONF_FILE
97
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAINE=$whiteDomain/" $CONF_FILE
97
	$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAIN=$whiteDomain/" $CONF_FILE
98
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=$adminMail/" $CONF_FILE
98
	$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=$adminMail/" $CONF_FILE
99
	$SED "/^SMTP_IP/ s/^/SMTP_IP=$port/" $LOCAL_IPTABLE_FILE
99
	$SED "s/^#SMTP_IP=.*/SMTP_IP=$port/" $LOCAL_IPTABLE_FILE
100
	$SED "/^SMTP_PORT/ s/^/SMTP_PORT=$port/g" $LOCAL_IPTABLE_FILE
100
	$SED "s/^#SMTP_PORT=.*/SMTP_PORT=$port/" $LOCAL_IPTABLE_FILE
101
	$SED "/^\$IPTABLES -A OUTPUT -p tcp -d \$SMTP_IP/ s/^/#/" $LOCAL_IPTABLE_FILE
101
	$SED "s/^#\$IPTABLES -A OUTPUT -p tcp -d \$SMTP_IP.*/\$IPTABLES -A OUTPUT -p tcp -d \$SMTP_IP --dport \$SMTP_PORT -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT/" $LOCAL_IPTABLE_FILE
102
	$SED "/^\$IPTABLES -A INPUT  -p tcp -s \$SMTP_IP/ s/^/#/g" $LOCAL_IPTABLE_FILE
102
	$SED "s/^#\$IPTABLES -A INPUT  -p tcp -s \$SMTP_IP.*/\$IPTABLES -A INPUT  -p tcp -s \$SMTP_IP --sport \$SMTP_PORT -m conntrack --ctstate ESTABLISHED     -j ACCEPT/" $LOCAL_IPTABLE_FILE
103
	$SED "s/^relayhost =.*/relayhost =/g" $POSTFIX_CONF_FILE
-
 
104
	$SED "s/^relayhost =.*/relayhost = $smtp:$port/g" $POSTFIX_CONF_FILE
103
	$SED "s/^relayhost =.*/relayhost = $smtp:$port/g" $POSTFIX_CONF_FILE
105
	[ -d ${saslPath} ] || mkdir ${saslPath}
104
	[ -d ${SASLPATH} ] || mkdir ${SASLPATH}
106
	echo "[${smtp}]:${port} ${mailAddr}:${mailMdp}" > ${saslPath}/sasl_passwd
105
	echo "[${smtp}]:${port} ${mailAddr}:${mailMdp}" > ${SASLPATH}/sasl_passwd
107
	postmap ${saslPath}/sasl_passwd
106
	postmap ${SASLPATH}/sasl_passwd
108
	chmod -R 777 ${saslPath}
107
	chmod -R 777 ${SASLPATH}
109
	#chown root:root ${saslPath}/sasl_passwd*
108
	#chown root:root ${SASLPATH}/sasl_passwd*
110
	#chmod 0600 ${saslPath}/sasl_passwd*
109
	#chmod 0600 ${SASLPATH}/sasl_passwd*
111
else
110
else
112
	echo "Erreur ! Aucun type de messagerie sélectionné !"
111
	echo "Erreur ! Aucun type de messagerie sélectionné !"
113
	exit 0
112
	exit 0
114
fi
113
fi
115
/usr/local/bin/alcasar-iptables.sh
114
/usr/local/bin/alcasar-iptables.sh