mirror of
https://github.com/d0zingcat/ghost-docker.git
synced 2026-05-29 23:16:51 +00:00
Added experimental script to automate fetching Tinybird tokens
This commit is contained in:
@@ -3,6 +3,7 @@ FROM python:3.13-slim@sha256:6544e0e002b40ae0f59bc3618b07c1e48064c4faed3a15ae2fb
|
|||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
curl \
|
curl \
|
||||||
|
jq \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ WORKDIR /home/tinybird
|
|||||||
|
|
||||||
# Install Tinybird using the standard installation script
|
# Install Tinybird using the standard installation script
|
||||||
COPY handleLogin.sh /usr/local/bin/tinybird-login
|
COPY handleLogin.sh /usr/local/bin/tinybird-login
|
||||||
|
COPY getTokens.sh /usr/local/bin/get-tokens
|
||||||
COPY tb-wrapper /usr/local/bin/tb-wrapper
|
COPY tb-wrapper /usr/local/bin/tb-wrapper
|
||||||
|
|
||||||
RUN curl https://tinybird.co | sh
|
RUN curl https://tinybird.co | sh
|
||||||
|
|||||||
41
tinybird/getTokens.sh
Executable file
41
tinybird/getTokens.sh
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get token from .tinyb JSON file
|
||||||
|
USER_TOKEN=$(jq -r '.token' .tinyb)
|
||||||
|
echo "User token: $USER_TOKEN"
|
||||||
|
|
||||||
|
if [ -z "$USER_TOKEN" ] || [ "$USER_TOKEN" = "null" ]; then
|
||||||
|
echo "Error: Could not find token in .tinyb file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get host from .tinyb JSON file
|
||||||
|
HOST=$(jq -r '.host' .tinyb)
|
||||||
|
echo "Host: $HOST"
|
||||||
|
|
||||||
|
if [ -z "$HOST" ] || [ "$HOST" = "null" ]; then
|
||||||
|
echo "Error: Could not find host in .tinyb file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get id from .tinyb JSON file
|
||||||
|
WORKSPACE_ID=$(jq -r '.id' .tinyb)
|
||||||
|
echo "Workspace ID: $WORKSPACE_ID"
|
||||||
|
|
||||||
|
if [ -z "$WORKSPACE_ID" ] || [ "$WORKSPACE_ID" = "null" ]; then
|
||||||
|
echo "Error: Could not find id in .tinyb file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make GET request to tokens endpoint and parse response
|
||||||
|
RESPONSE=$(curl -s -X GET \
|
||||||
|
"$HOST/v0/tokens" \
|
||||||
|
-H "Authorization: Bearer $USER_TOKEN")
|
||||||
|
|
||||||
|
# Parse tokens from response
|
||||||
|
ADMIN_TOKEN=$(echo "$RESPONSE" | jq -r '.tokens[] | select(.name == "admin token") | .token')
|
||||||
|
TRACKER_TOKEN=$(echo "$RESPONSE" | jq -r '.tokens[] | select(.name == "tracker") | .token')
|
||||||
|
|
||||||
|
# Echo the tokens as proof of concept
|
||||||
|
echo "Admin token: $ADMIN_TOKEN"
|
||||||
|
echo "Tracker token: $TRACKER_TOKEN"
|
||||||
Reference in New Issue
Block a user