diff --git a/install-postfix.sh b/install-postfix.sh new file mode 100755 index 0000000..8775df6 --- /dev/null +++ b/install-postfix.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# Wrapper script for install, for easier execution via URL. + +source /dev/stdin <<< "$(curl -sL http://go.scity.us/colorsinc)" +source /dev/stdin <<< "$(curl -sL http://go.scity.us/defaultinc)" + +echo "" +echo -e "${idsCL[LightGreen]}Postfox 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]) break;; +* ) + 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 + cd /etc/postfix + service stop postfix + + echo + echo -e -n "${idsCL[LightCyan]}Server is internal or external (I/e): ${idsCL[Default]}" + read SERVERLOC + + if [ "${SERVERLOC}" = "" ]; then SERVERLOC=I; fi + + mv /etc/postfix/main.cf /etc/postfix/main.cf.bak + + if [ ! -f /etc/mailname ]; then + echo "scity.us" > /etc/mailname + fi + + 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 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 + ;; + 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 (Default = \"${hostname}\"): ${idsCL[Default]}" + read pfhostname + echo "" + + if [ "${pfhostname}" = "" ]; then pfhostname=${hostname}; fi + + read -p "Default from email (portion before @scity.us, Default = \"${hostname}\"): " pffromemail + echo "" + + if [ "${pffromemail}" = "" ]; then pffromemail=${hostname}; fi + + sed -i "s/<>/${pfhostname}/g" main.cf + sed -i "s/<>/${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}" = "txt" ]; then + TESTEMAIL='9208839613@txt.att.net' + elif [ "${TESTEMAIL}" = "mms" ]; then + TESTEMAIL='9208839613@mms.att.net' + fi + echo "Test Alert Body" | mail -r ${pffromemail}@scity.us -s "Test Alert Subject" $TESTEMAIL + fi + + echo "" + echo -e "${Green}Postfix has been Installed${Color_Off}" + 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 \ No newline at end of file