Skip to content

Commit

Permalink
use updateOrAppend function
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroTochigi committed Feb 24, 2024
1 parent 67b9bf7 commit 8b6a467
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/aws/dependencies/updateOrAppend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion src/aws/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/aws/restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ function restart(){
echo "the new ip address is $publicIp"
updateIPAddress $balloonName $publicIp

replaceIp $oldPublicIp $publicIp
updateOrAppend $instanceName $publicIp
}

0 comments on commit 8b6a467

Please sign in to comment.