Subversion Repositories ALCASAR

Rev

Rev 2990 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2990 rexy 1
#!/bin/bash
2
 
2992 rexy 3
###########################################################################################
4
##
5
##				    ALCASAR SERVICE MAIL INSTALL
6
##
7
##	Script by joss_p
8
##  This script configure the mail conf file and execute the configuration from the acc.
9
##
10
###########################################################################################
2990 rexy 11
 
12
#. /usr/local/etc/alcasar-mail.conf
13
 
14
saslPath="/etc/postfix/sasl"
15
smtpIP="0.0.0.0/0"
16
 
17
if [[ ${#} -ne 0 ]]
18
then
19
	while getopts ":s:p:r:m:o:a:w:123" option
20
	do
21
		case $option in
22
			1)
23
				TYPE_MAIL=1
24
			;;
25
			2)
26
				TYPE_MAIL=2
27
			;;
28
			3)
29
				TYPE_MAIL=3
30
			;;
31
			s)
32
				smtp=$OPTARG
33
			;;
34
			p)
35
				port=$OPTARG
36
			;;
37
			r)
38
				smtpIP=$OPTARG
39
			;;
40
			m)
41
				mailAddr=$OPTARG
42
			;;
43
			o)
44
				mailMdp=$OPTARG
45
			;;
46
			a)
47
				adminMail=$OPTARG
48
			;;
49
			w)
50
				whiteDomain=$OPTARG
51
			;;
52
			:)
53
				echo "L'option $OPTARG requiert un argument"
54
				exit 1
55
			;;
56
			\?)
57
				echo "$OPTARG : option invalide"
58
				exit 1
59
			;;
60
		esac
61
	done
62
fi
63
 
64
if [[ $TYPE_MAIL -eq 2 ]]; then
65
	echo "relayhost = [${smtp}]:${port}" >> /etc/postfix/main.cf
66
elif [[ $TYPE_MAIL -eq 3 ]]; then
67
	echo "relayhost = [${smtp}]:${port}" >> /etc/postfix/main.cf
68
	[ -d ${saslPath} ] || mkdir ${saslPath}
69
	echo "[${smtp}]:${port} ${mailAddr}:${mailMdp}" > ${saslPath}/sasl_passwd
70
	postmap ${saslPath}/sasl_passwd
71
	chmod -R 777 ${saslPath}
72
	#chown root:root ${saslPath}/sasl_passwd*
73
	#chmod 0600 ${saslPath}/sasl_passwd*
74
else
75
	echo "Erreur ! Aucun type de messagerie sélectionné !"
76
	exit 0
77
fi
78
old_smtpIP=`grep "SMTP_IP=" /usr/local/etc/alcasar-iptables-local.sh  | cut -d "'" -f2`
79
old_port=`grep "SMTP_PORT=" /usr/local/etc/alcasar-iptables-local.sh  | cut -d "=" -f2 | cut -f1`
80
sed -ie "/SMTP_IP=/ s@${old_smtpIP}@${smtpIP}@" /usr/local/etc/alcasar-iptables-local.sh
81
sed -ie "/SMTP_PORT=/ s/${old_port}/${port}/" /usr/local/etc/alcasar-iptables-local.sh
82
sed -ie "/SMTP_IP=/ s/^#//" /usr/local/etc/alcasar-iptables-local.sh
83
sed -ie "/SMTP_PORT/ s/^#//g" /usr/local/etc/alcasar-iptables-local.sh
84
#chmod 740 /usr/local/etc/alcasar-iptables-local.sh
85
#chmod 700 /usr/local/bin/alcasar-iptables.sh
86
bash /usr/local/bin/alcasar-iptables.sh
87
exit 0