Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ## External (remote) smtp relay enabler ## airwolfx86
- ## info@binarisk.com
- ## FOR POSTIFX
- LOOP=1
- unset OPTION1
- unset RELAYHOST
- unset USERNAME
- unset PASSWORD
- OPTION2=$1
- DATEXT=$(date +"%T")
- if [ $OPTION2 = "config" ]
- then
- clear
- while [ $LOOP -gt 0 ]; do
- echo "Your remote SMTP server IP :"
- read RELAYHOST
- echo "Your remote SMTP username :"
- read USERNAME
- echo "Your remote SMTP password :"
- read -s PASSWORD
- echo " "
- echo "Now you will save this information to the postfix service:"
- echo "[Server]: $RELAYHOST [Username]: $USERNAME [Password]: $PASSWORD"
- echo " "
- echo "Save and exit (YES) / Retry (R) / Quit (Q) :"
- read OPTION1
- if [ "$OPTION1" = "YES" ] || [ "$OPTION1" = "yes" ] || [ "$OPTION1" = "Y" ] || [ "$OPTION1" = "y" ]
- then
- cp /etc/postfix/main.cf "/etc/postfix/main_cf_$DATEXT" # main.cf backup
- cp /etc/postfix/sasl_passwd "/etc/postfix/sasl_passwd_$DATEXT" # sasl_passwd backup
- postconf -e "relayhost = $relayhost"
- postconf -e "smtp_sasl_auth_enable = yes"
- postconf -e "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd"
- postconf -e "smtp_sasl_security_options ="
- echo "$relayhost $username:$password" >> /etc/postfix/sasl_passwd
- chown root:root /etc/postfix/sasl_passwd
- chmod 600 /etc/postfix/sasl_passwd
- postmap /etc/postfix/sasl_passwd # create postfix passwd db
- /etc/init.d/postfix restart
- clear
- echo "Your backup files main.cf and sasl_passwd are stored with date and time"
- echo "Done..."
- LOOP=0
- fi
- if [ "$OPTION1" = "R" ] || [ "$OPTION1" = "r" ]
- then
- clear
- LOOP=1
- fi
- if [ "$OPTION1" = "Q" ] || [ "$OPTION1" = "q" ]
- then
- clear
- echo "No changes where made..."
- LOOP=0
- fi
- done
- exit
- fi
- if [ $OPTION2 = "help" ]
- then
- clear
- echo "[ Remote SMTP Postfix Help ]"
- echo "You must have POSTFIX installed"
- echo "A valid email username / password in the remote smtp server"
- exit
- fi
- clear
- echo "Usage : backupcode-relay config | help "
- exit
Add Comment
Please, Sign In to add comment