diff --git a/src/aws/dependencies/updateOrAppend.sh b/src/aws/dependencies/updateOrAppend.sh index acc6bbea..8c75fe86 100644 --- a/src/aws/dependencies/updateOrAppend.sh +++ b/src/aws/dependencies/updateOrAppend.sh @@ -2,11 +2,11 @@ # If the name already exists in the file, it updates the corresponding IP. # If the name does not exist, it appends a new IP and name pair to the end of the file. # Arguments: -# ip: The IP address to be updated or appended. # name: The name to be updated or appended. +# ip: The IP address to be updated or appended. updateOrAppend() { - local ip="$1" - local name="$2" + local name="$1" + local ip="$2" local file="/etc/hosts" local escaped_name=$(printf '%s\n' "$name" | sed 's:[][\/.^$*]:\\&:g') diff --git a/src/aws/init.sh b/src/aws/init.sh index acd52753..084bddc6 100644 --- a/src/aws/init.sh +++ b/src/aws/init.sh @@ -188,7 +188,9 @@ function init { isOpen=$(waitForOutput "ssh-keyscan -H $publicIp | grep ecdsa-sha2-nistp256") echo "Opened ssh tunnel" - openSSHTunnel $publicIp $portConfigArray + updateOrAppend $instanceName $publicIp + openSSHTunnel $instanceName $portConfigArray + storeConfigIntoTreehousesConfigAsStringfiedJson $instanceName $keyName $instanceId $publicIp $groupName } diff --git a/src/aws/restart.sh b/src/aws/restart.sh index 69071992..3ecde38d 100644 --- a/src/aws/restart.sh +++ b/src/aws/restart.sh @@ -30,5 +30,5 @@ function restart(){ echo "the new ip address is $publicIp" updateIPAddress $balloonName $publicIp - replaceIp $oldPublicIp $publicIp + updateOrAppend $instanceName $publicIp } \ No newline at end of file