Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if ! which sshpass > /dev/null; then
- aptitude install sshpass
- fi
- if [ ! -f "$1" ]; then
- echo "Usage: ./$0 <config file name>"
- echo "Config file format: <host address> <password> <new IP>"
- exit 1
- fi
- cd "$(dirname "$0")"
- echo -n '' > output
- cat "$1" | while read host password newip; do
- echo "
- echo \"
- 127.0.0.1
- ${newip}
- ${host}
- \" > /etc/dkim-internal-hosts
- if ! cat /etc/postfix/main.cf | grep mynetworks | grep -q "${newip}"; then
- sed -i -r 's/^(mynetworks = .*$)/\1 ${newip}/' /etc/postfix/main.cf
- fi
- /etc/init.d/postfix reload
- /etc/init.d/dk-filter restart
- /etc/init.d/opendkim restart
- " | sshpass -p "${password}" ssh "${host}" -lroot
- if [ "$?" = "0" ]; then
- echo "${host} OK" | tee -a output
- else
- echo "${host} ERROR" | tee -a output
- fi
- echo " "
- echo "--------------------------------------------------"
- echo " "
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement