112 lines
4.0 KiB
Bash
Executable File
112 lines
4.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Wrapper script for install, for easier execution via URL.
|
|
|
|
if [ -d /opt/idssys/defaults ]; then
|
|
source /opt/idssys/defaults/colors.inc
|
|
source /opt/idssys/defaults/default.inc
|
|
else
|
|
source /dev/stdin <<< "$(curl -sL http://go.scity.us/colorsinc)"
|
|
source /dev/stdin <<< "$(curl -sL http://go.scity.us/defaultinc)"
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${idsCL[LightGreen]}Postfix Installation Script for scity.us${idsCL[Default]}"
|
|
echo ""
|
|
|
|
read -n 1 -p "Are you sure you wish to install Postfix (Y/n)?" choice
|
|
case "$choice" in
|
|
[Nn]) echo "";;
|
|
* )
|
|
echo "postfix postfix/mailname string scity.us" | debconf-set-selections
|
|
echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
|
|
|
|
$APTFUNC install -y postfix mailutils-common mailutils
|
|
cd /etc/postfix
|
|
service stop postfix
|
|
|
|
echo
|
|
echo -e -n "${idsCL[LightCyan]}Server is 'I'nternal or 'E'xternal or 'D'irect? ${idsCL[Default]}"
|
|
read -e SERVERLOC
|
|
|
|
[ "${SERVERLOC}" = "" ] && SERVERLOC=I
|
|
|
|
mv /etc/postfix/main.cf /etc/postfix/main.cf.bak
|
|
|
|
[ ! -f /etc/mailname ] && echo "scity.us" > /etc/mailname
|
|
|
|
case ${SERVERLOC} in
|
|
[Ii]) wget https://git.schroedercity.com/voltron/Misc-Scripts/raw/branch/master/defaults/main.cf -O /etc/postfix/main.cf;;
|
|
[Ee])
|
|
echo
|
|
echo -e -n "${idsCL[LightCyan]}Username for scity.us domain email: ${idsCL[Default]}"
|
|
read -i "systems" -e USERNAME
|
|
echo
|
|
echo -e -n "${idsCL[LightCyan]}Password for scity.us domain email: ${idsCL[Default]}"
|
|
read -s PASSWORD
|
|
echo
|
|
wget https://git.schroedercity.com/voltron/Misc-Scripts/raw/branch/master/defaults/main.auth.cf -O /etc/postfix/main.cf
|
|
echo "mail.scity.us ${USERNAME}@scity.us:${PASSWORD}" > /etc/postfix/sasl_passwd
|
|
sudo chmod 600 /etc/postfix/sasl_passwd
|
|
sudo postmap /etc/postfix/sasl_passwd
|
|
sudo rm -f /etc/postfix/sasl_passwd
|
|
;;
|
|
[Dd])
|
|
echo
|
|
echo -e -n "${idsCL[LightCyan]}Username for direct: ${idsCL[Default]}"
|
|
read -i "david@schroedercity.com" -e USERNAME
|
|
echo
|
|
echo -e -n "${idsCL[LightCyan]}Password for direct: ${idsCL[Default]}"
|
|
read -s PASSWORD
|
|
echo
|
|
wget https://git.schroedercity.com/voltron/Misc-Scripts/raw/branch/master/defaults/direct.auth.cf -O /etc/postfix/main.cf
|
|
echo "[pro.turbo-smtp.com]:587 ${USERNAME}:${PASSWORD}" > /etc/postfix/sasl_passwd
|
|
sudo chmod 600 /etc/postfix/sasl_passwd
|
|
sudo postmap /etc/postfix/sasl_passwd
|
|
sudo rm -f /etc/postfix/sasl_passwd
|
|
;;
|
|
esac
|
|
|
|
wget https://git.schroedercity.com/voltron/Misc-Scripts/raw/branch/master/defaults/sender_canonical -O /etc/postfix/sender_canonical
|
|
|
|
hostname=`hostname`
|
|
echo -e -n "${idsCL[LightCyan]}Server Name: ${idsCL[Default]}"
|
|
read -i "${hostname}" -e pfhostname
|
|
echo ""
|
|
|
|
echo -e -n "${idsCL[LightCyan]}Default from email (portion before @scity.us): ${idsCL[Default]}"
|
|
read -i "${hostname}" -e pffromemail
|
|
echo ""
|
|
|
|
sed -i "s/<<HOSTNAME>>/${pfhostname}/g" main.cf
|
|
sed -i "s/<<FROMEMAIL>>/${pffromemail}/g" sender_canonical
|
|
|
|
service postfix start
|
|
|
|
echo -e -n "${idsCL[Yellow]}Send test Alert to (leave blank to not send test): ${idsCL[Default]}"
|
|
read TESTEMAIL
|
|
|
|
if [ "${TESTEMAIL}" != "" ]; then
|
|
if [ "${TESTEMAIL}" = "push" ]; then
|
|
TESTEMAIL='b3upzaom7a@pomail.net'
|
|
elif [ "${TESTEMAIL}" = "mms" ]; then
|
|
TESTEMAIL='9208839613@mms.att.net'
|
|
fi
|
|
[ "$(ip route | awk '/default/ { print $5 }')" == "link" ] && HIP=$(ip addr show $(ip route | awk '/1 dev eth0/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1) ||
|
|
HIP=$(ip addr show $(ip route | awk '/default/ { print $5 }') | grep "inet" | head -n 1 | awk '/inet/ {print $2}' | cut -d'/' -f1)
|
|
echo -e "Received from: ${pffromemail}@scity.us\nHostname: $(hostname) ($(hostname -f))\nIP: ${HIP}\n\n\nSent: $(date)" | mail -r ${pffromemail}@scity.us -s "Test Message (Postfix Install)" $TESTEMAIL
|
|
fi
|
|
|
|
echo ""
|
|
echo -e "${idsCL[LightGreen]}Postfix has been Installed${idsCL[Default]}"
|
|
if [ ${action-x} ]; then exit 0; fi
|
|
read -n 1 -s -p "Press any key to continue"
|
|
SCRIPT_MENU;;
|
|
esac
|
|
|
|
|
|
echo ""
|
|
echo -e "${idsCL[Yellow]}Postfix has not been Installed.${idsCL[Default]}"
|
|
echo ""
|
|
|
|
|
|
exit 0 |