Skip to content

Instantly share code, notes, and snippets.

@trentm
Created February 17, 2012 00:12
Show Gist options
  • Select an option

  • Save trentm/688a5e5ddcce8af51c46 to your computer and use it in GitHub Desktop.

Select an option

Save trentm/688a5e5ddcce8af51c46 to your computer and use it in GitHub Desktop.
diff --git a/bin/sdc-dsimport b/bin/sdc-dsimport
index 43ced76..3ab409e 100755
--- a/bin/sdc-dsimport
+++ b/bin/sdc-dsimport
@@ -46,12 +46,16 @@ function dataset_import {
if [[ -z "${dsapi}" ]]; then
dsapi=${CONFIG_dsapi_url}
fi
- # Need an IP for datasets hostname.
- local dsapi_ip=${dsapi}
- hostname=$(echo ${dsapi} | cut -f3 -d "/" | cut -f1 -d ":")
- if [[ ! `echo "${hostname}" | grep "^[0-9\.]*$" 2>&1` ]]; then
- ip=$(dig $hostname +short)
- dsapi_ip=$(echo $dsapi | sed "s|\(.*\)$hostname\(.*\)|\1$ip\2|")
+
+ local dsapi_ip
+ if [[ "${mode}" == "dsapi" ]]; then
+ # Need an IP for datasets hostname.
+ dsapi_ip=${dsapi}
+ local hostname=$(echo ${dsapi} | cut -f3 -d "/" | cut -f1 -d ":")
+ if [[ ! `echo "${hostname}" | grep "^[0-9\.]*$" 2>&1` ]]; then
+ local ip=$(dig $hostname +short)
+ dsapi_ip=$(echo $dsapi | sed "s|\(.*\)$hostname\(.*\)|\1$ip\2|")
+ fi
fi
# Note: /usr/bin/egrep on smartos doesn't support '{m,n}' quantifiers.
@@ -68,7 +72,7 @@ function dataset_import {
fatal "'${dataset_arg}' isn't a Dataset UUID and isn't an existing .dsmanifest file. Aborting."
fi
- local manifest;
+ local manifest
if [[ "${mode}" == "dsapi" ]]; then
echo "Getting dataset info from Dataset API (${dsapi}))."
manifest=$(DSAPI_URL=${dsapi_ip} sdc-dsapi /datasets/$dataset_uuid | json -H)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment