2012-11-07 17:59:39 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# TODO: port to node, if you really need it
|
|
|
|
|
|
|
|
REDIS_PORT=6379 # default port
|
|
|
|
|
|
|
|
|
2013-07-03 15:59:42 +08:00
|
|
|
if test -z "$1"; then
|
|
|
|
echo "Usage: $0 <username> [<tablename>|~<token>]" >&2
|
2012-11-07 17:59:39 +08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
username="$1"
|
2013-07-03 15:59:42 +08:00
|
|
|
token="$2"
|
2012-11-07 17:59:39 +08:00
|
|
|
|
|
|
|
dbname=`redis-cli -p ${REDIS_PORT} -n 5 hget "rails:users:${username}" "database_name"`
|
2013-07-03 15:59:42 +08:00
|
|
|
if test $? -ne 0; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if test -z "${dbname}"; then
|
|
|
|
echo "Username ${username} unknown by redis (try CARTODB/script/restore_redis?)" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "Database name for user ${username}: ${dbname}" # only if verbose?
|
|
|
|
if test -n "$token"; then
|
|
|
|
redis-cli get "map_style|${dbname}|${token}" | sed -e 's/\\n/\n/g' -e 's/\\//g'
|
|
|
|
else
|
|
|
|
redis-cli keys "map_style|${dbname}|*"
|
|
|
|
fi
|