Advertisement
iarmin

remote-smtp-reconfigure

Jun 24th, 2011
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.87 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if ! which sshpass > /dev/null; then
  4.     aptitude install sshpass
  5. fi
  6.  
  7. if [ ! -f "$1" ]; then
  8.     echo "Usage: ./$0 <config file name>"
  9.     echo "Config file format: <host address> <password> <new IP>"
  10.     exit 1
  11. fi
  12.  
  13. cd "$(dirname "$0")"
  14. echo -n '' > output
  15. cat "$1" | while read host password newip; do
  16. echo "
  17.     echo \"
  18. 127.0.0.1
  19. ${newip}
  20. ${host}
  21.     \" > /etc/dkim-internal-hosts
  22.     if ! cat /etc/postfix/main.cf | grep mynetworks | grep -q "${newip}"; then
  23.         sed -i -r 's/^(mynetworks = .*$)/\1 ${newip}/' /etc/postfix/main.cf
  24.     fi
  25.     /etc/init.d/postfix reload
  26.     /etc/init.d/dk-filter restart
  27.     /etc/init.d/opendkim restart
  28. " | sshpass -p "${password}" ssh "${host}" -lroot
  29. if [ "$?" = "0" ]; then
  30.     echo "${host}   OK" | tee -a output
  31. else
  32.     echo "${host}   ERROR" | tee -a output
  33. fi
  34. echo " "
  35. echo "--------------------------------------------------"
  36. echo " "
  37. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement