Last active
December 15, 2015 00:19
-
-
Save mrmichalis/5172546 to your computer and use it in GitHub Desktop.
for IP in 201 202 247; do ssh root@$IP 'sh -s' < getip.sh >> /etc/hosts; done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ $# -lt 1 ]; then | |
echo "usage: $0 [hosts list]" 1>&2 | |
exit 1 | |
fi | |
HOSTSLIST=$1 | |
IPADDR=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') | |
if [ -a $HOSTSLIST ]; then | |
for IP in $(cat $HOSTSLIST | grep -v $IPADDR)); do ssh root@$IP "grep 192.168.1. /etc/hosts" >> /etc/hosts; done | |
for IP in $(cat $HOSTSLIST | grep -v $IPADDR); do scp /etc/hosts root@$IP:/etc/hosts; done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment