tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 2 | # ----------------------------------------------------------------------------- |
tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 3 | # Remotely patches the ONOS VM to tailor its hostname. |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 4 | # ----------------------------------------------------------------------------- |
tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
| 9 | address=${1:-$OCI} |
| 10 | remote=$ONOS_USER@$address |
| 11 | name=${2:-onos-1} |
| 12 | |
| 13 | [ -z "$address" ] && echo "Null address not allowed" >&2 && exit 1 |
| 14 | [ -z "$name" ] && echo "Null name not allowed" >&2 && exit 1 |
| 15 | |
| 16 | ssh $remote " |
| 17 | sudo perl -pi.bak -e \"s/127.0.1.1.*/127.0.1.1 $name/g\" /etc/hosts |
tom | 2228803 | 2014-10-07 08:16:53 -0700 | [diff] [blame] | 18 | sudo bash -c \"echo $name >/etc/hostname\" |
tom | 2d7acb7 | 2014-09-22 22:13:00 -0700 | [diff] [blame] | 19 | sudo hostname $name |
tom | 7fc1837 | 2014-09-25 09:50:04 -0700 | [diff] [blame] | 20 | " 2>/dev/null |
| 21 | |
| 22 | echo "$address: $(ssh $remote hostname)" |