blob: 39f1c603a527dae9e327367ac1d7a0561c52d83d [file] [log] [blame]
tom2d7acb72014-09-22 22:13:00 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom2d7acb72014-09-22 22:13:00 -07003# Remotely patches the ONOS VM to tailor its hostname.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tom2d7acb72014-09-22 22:13:00 -07005
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
9address=${1:-$OCI}
10remote=$ONOS_USER@$address
11name=${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
16ssh $remote "
17 sudo perl -pi.bak -e \"s/127.0.1.1.*/127.0.1.1 $name/g\" /etc/hosts
tom22288032014-10-07 08:16:53 -070018 sudo bash -c \"echo $name >/etc/hostname\"
tom2d7acb72014-09-22 22:13:00 -070019 sudo hostname $name
tom7fc18372014-09-25 09:50:04 -070020" 2>/dev/null
21
22echo "$address: $(ssh $remote hostname)"