Skip to content

Commit

Permalink
Use portal config.json instead of DNS TXT records
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdett committed Mar 7, 2017
1 parent c4647bc commit 8cc5d7c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ if [[ "$DIT4C_INSTANCE_URI_UPDATE_URL" == "" ]]; then
exit 1
fi

PORTAL_DOMAIN=$(echo $DIT4C_INSTANCE_URI_UPDATE_URL | awk -F/ '{print $3}')
PORTAL_URI=$(echo $DIT4C_INSTANCE_URI_UPDATE_URL | sed -e 's/^\(https*:\/\/[^\/]*\).*$/\1/')
PORTAL_PUBLIC_CONFIG_URL="${PORTAL_URI}/config.json"

umask 0077
while true
do
SSH_SERVER=$(dig +short TXT $PORTAL_DOMAIN | grep -Eo "dit4c-fileserver-9pfs=[^\"]*" | cut -d= -f2 | xargs /opt/bin/sort_by_latency.sh | head -1)
SSH_SERVER=$(curl $PORTAL_PUBLIC_CONFIG_URL | jq -r '.storage | .["9pfs"] | .servers | .[] | @text' | xargs /opt/bin/sort_by_latency.sh | head -1)
SSH_HOST=$(echo $SSH_SERVER | cut -d: -f1)
SSH_PORT=$(echo $SSH_SERVER | cut -d: -f2)

Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ echo nameserver 8.8.8.8 > /etc/resolv.conf

# Install packages
apt-get update
apt-get install -y curl openssh-client nmap dnsutils fuse socat
apt-get install -y curl fuse jq nmap openssh-client socat
apt-get clean

# Cleanup DNS config
Expand Down
8 changes: 8 additions & 0 deletions test/dit4c-helper-storage-9pfs.linux.amd64.aci.bats
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ teardown() {
[ "$status" -eq 0 ]
}

@test "jq binary runs" {
run sudo $RKT run --insecure-options=image --stage1-path=$RKT_STAGE1 \
$IMAGE \
--exec /usr/bin/jq -- -V
echo $output
[ "$status" -eq 0 ]
}

@test "nmap binary runs" {
run sudo $RKT run --insecure-options=image --stage1-path=$RKT_STAGE1 \
$IMAGE \
Expand Down

0 comments on commit 8cc5d7c

Please sign in to comment.