Windshaft-cartodb/tools/multilayer_token

44 lines
756 B
Bash
Executable File

#!/bin/sh
verbose=no
while test -n "$1"; do
if test "$1" = "-v"; then
verbose=yes
else
cfg=$1
fi
shift
done
if test -z "$cfg"; then
echo "Usage: $0 [-v] <config_file>" >&2
exit 1
fi
port=8181
user=dev
domain=localhost.lan
proto=http
path="tiles/layergroup"
# This is for direct windshaft connection
#port=8083
#path="database/cartodb_dev_user_1_db/layergroup"
cmd="curl -skH Content-Type:application/json --data-binary @${cfg} ${proto}://${user}.${domain}:${port}/${path}"
if test x${verbose} = xyes; then
cmd="${cmd} -v"
fi
res=`${cmd}`
if test $? -gt 0; then
echo "curl command failed: ${cmd}"
fi
if test x${verbose} = xyes; then
echo "${res}"
fi
tok=`echo "$res" | sed 's/.*"layergroupid":"\([^"]*\)".*/\1/'`
echo $tok