diff --git a/salt/manager/tools/sbin/so-client b/salt/manager/tools/sbin/so-client index 04e540465..4177e84b0 100755 --- a/salt/manager/tools/sbin/so-client +++ b/salt/manager/tools/sbin/so-client @@ -87,7 +87,7 @@ while [[ $# -gt 0 ]]; do esac done -hydraUrl=${HYDRA_URL:-http://127.0.0.1:4445/admin} +hydraUrl=${HYDRA_URL:-http://127.0.0.1:4445} socRolesFile=${SOC_ROLES_FILE:-/opt/so/conf/soc/soc_clients_roles} soUID=${SOCORE_UID:-939} soGID=${SOCORE_GID:-939} @@ -116,7 +116,7 @@ function verifyEnvironment() { require "jq" require "curl" response=$(curl -Ss -L ${hydraUrl}/) - [[ "$response" != "404 page not found" ]] && fail "Unable to communicate with Hydra; specify URL via HYDRA_URL environment variable" + [[ "$response" != *"Error 404"* ]] && fail "Unable to communicate with Hydra; specify URL via HYDRA_URL environment variable" } function createFile() { @@ -145,7 +145,7 @@ function ensureRoleFileExists() { } function listClients() { - response=$(curl -Ss -L ${hydraUrl}/admin/clients) + response=$(curl -Ss -L -f ${hydraUrl}/admin/clients) [[ $? != 0 ]] && fail "Unable to communicate with Hydra" clientIds=$(echo "${response}" | jq -r ".[] | .client_id" | sort) @@ -192,7 +192,7 @@ function adjustClientRole() { if [[ "$hasRole" -ne 1 ]]; then fail "Client '$identityId' does not have the role: $role" else - sed "/^$role:$identityId\$/d" "$filename" > "$filename.tmp" + sed -e "\!^$role:$identityId\$!d" "$filename" > "$filename.tmp" cat "$filename".tmp > "$filename" rm -f "$filename".tmp fi @@ -206,7 +206,7 @@ function convertNameToId() { name=$1 name=${name//[^[:alnum:]]/_} - echo "$name" | tr '[:upper:]' '[:lower:]' + echo "socl_$name" | tr '[:upper:]' '[:lower:]' } function createClient() { @@ -216,11 +216,15 @@ function createClient() { id=$(convertNameToId "$name") now=$(date -u +%FT%TZ) + secret=$(get_random_value) body=$(cat <