Skip to content

Instantly share code, notes, and snippets.

@dcarroll
Created July 28, 2017 17:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dcarroll/032965d8164fef51c879536486bf68da to your computer and use it in GitHub Desktop.
Save dcarroll/032965d8164fef51c879536486bf68da to your computer and use it in GitHub Desktop.
Simple script to check if the org you are using is a Dev Hub. Run by passing a username or alias to the script.
#!/bin/bash
# specify your username or alias
usernameOrAlias=$1
hub=$(sfdx force:data:soql:query -q "SELECT DurableId, SettingValue FROM OrganizationSettingsDetail WHERE SettingName = 'ScratchOrgManagementPref'" -t -u ${usernameOrAlias} --json)
# parse response
size="$(echo ${hub} | jq -r .result.size)"
if [[ $size -eq 0 ]];
then
echo "${usernameOrAlias} is not a dev hub"
exit 0
fi
records="$(echo ${hub} | jq -r .result.records)"
value="$(echo ${records} | jq -r .[].SettingValue)"
# evaluate the setting value
if $value === 'true'
then
echo "${usernameOrAlias} is a dev hub"
else
echo "${usernameOrAlias} is not a dev hub"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment