Subversion Repositories ALCASAR

Compare Revisions

No changes between revisions

Ignore whitespace Rev 2992 → Rev 2993

/scripts/alcasar-mail-install.sh/alcasar-mail-install.sh
0,0 → 1,101
#!/bin/bash
 
###########################################################################################
## ALCASAR SERVICE MAIL INSTALL
##
## Script by joss_p & Rexy
## This script configure the mail conf file and execute the configuration from the acc.
###########################################################################################
 
# ****** Paths - chemin des commandes *******
SED="/bin/sed -i"
CONF_FILE="/usr/local/etc/alcasar.conf"
LOCAL_IPTABLE_FILE="/usr/local/etc/alcasar-iptables-local.sh"
saslPath="/etc/postfix/sasl"
smtpIP="0.0.0.0/0"
 
usage="Usage: alcasar-mail_install.sh 0|1|2|3"
nb_args=$#
if [ $nb_args -eq 0 ]
then
echo "$usage"
exit 0
fi
if [[ ${#} -ne 0 ]]
then
while getopts ":s:p:r:m:o:a:w:0123" option
do
case $option in
0)
TYPE_MAIL=0
;;
1)
TYPE_MAIL=1
;;
2)
TYPE_MAIL=2
;;
3)
TYPE_MAIL=3
;;
s)
smtp=$OPTARG
;;
p)
port=$OPTARG
;;
r)
smtpIP=$OPTARG
;;
m)
mailAddr=$OPTARG
;;
o)
mailMdp=$OPTARG
;;
a)
adminMail=$OPTARG
;;
w)
whiteDomain=$OPTARG
;;
:)
echo "L'option $OPTARG requiert un argument"
exit 1
;;
\?)
echo "$OPTARG : option invalide"
exit 1
;;
esac
done
fi
if [[ $TYPE_MAIL -eq 0 ]]; then # idesable mail service
$SED "s/^MAIL=.*/MAIL=off/" $CONF_FILE
$SED "s/^MAIL_TYPE=.*/MAIL_TYPE=/" $CONF_FILE
$SED "s/^MAIL_SMTP=.*/MAIL_SMTP=/" $CONF_FILE
$SED "s/^MAIL_SMTP_IP=.*/MAIL_SMTP_IP=/" $CONF_FILE
$SED "s/^MAIL_PORT=.*/MAIL_PORT=/" $CONF_FILE
$SED "s/^MAIL_ADDR=.*/MAIL_ADDR=/" $CONF_FILE
$SED "s/^MAIL_WHITEDOMAIN=.*/MAIL_WHITEDOMAINE=/" $CONF_FILE
$SED "s/^MAIL_ADMIN=.*/MAIL_ADMIN=/" $CONF_FILE
$SED "/^SMTP_IP/ s/^/#/" $LOCAL_IPTABLE_FILE
$SED "/^\$IPTABLES -A OUTPUT -p tcp -d \$SMTP_IP/ s/^/#/" $LOCAL_IPTABLE_FILE
$SED "/^SMTP_PORT/ s/^/#/g" $LOCAL_IPTABLE_FILE
$SED "/^\$IPTABLES -A INPUT -p tcp -s \$SMTP_IP/ s/^/#/g" $LOCAL_IPTABLE_FILE
elif [[ $TYPE_MAIL -eq 2 ]]; then
echo "relayhost = [${smtp}]:${port}" >> /etc/postfix/main.cf
elif [[ $TYPE_MAIL -eq 3 ]]; then
echo "relayhost = [${smtp}]:${port}" >> /etc/postfix/main.cf
[ -d ${saslPath} ] || mkdir ${saslPath}
echo "[${smtp}]:${port} ${mailAddr}:${mailMdp}" > ${saslPath}/sasl_passwd
postmap ${saslPath}/sasl_passwd
chmod -R 777 ${saslPath}
#chown root:root ${saslPath}/sasl_passwd*
#chmod 0600 ${saslPath}/sasl_passwd*
else
echo "Erreur ! Aucun type de messagerie sélectionné !"
exit 0
fi
/usr/local/bin/alcasar-iptables.sh
exit 0
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:executable
+*
\ No newline at end of property