Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

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