Files
Phantom/archive/scripts/create-gitea-token.sh
NW 863a67db8e config: full APAW agent infrastructure + Phantom project files
- Added all agent definitions (.kile/agents/*.md)
- Added commands, rules, skills, shared modules
- Added src/, scripts/, tests/, docker/, agent-evolution/
- Extracted 3 archives: website/, workspace/, release/
- Created .env with Gitea creds for UniqueSoft/Phantom
- Created docs/ with project-specific guides
- Added .gitignore for node_modules
2026-05-18 17:53:59 +01:00

66 lines
1.8 KiB
Bash

#!/bin/bash
# Create Gitea API token using Basic Auth
# Usage: ./scripts/create-gitea-token.sh <username> <password>
API_URL="https://git.softuniq.eu/api/v1"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <username> <password>"
echo ""
echo "Example: $0 NW mypassword"
echo ""
echo "This will create a new API token for the user."
exit 1
fi
USERNAME="$1"
PASSWORD="$2"
TOKEN_NAME="Pipeline Test $(date +%Y%m%d%H%M%S)"
echo "=== Gitea Token Creation ==="
echo ""
echo "👤 Username: $USERNAME"
echo "🔑 Token name: $TOKEN_NAME"
echo ""
# Create token using Basic Auth
echo "🔐 Creating token..."
RESPONSE=$(curl -s -X POST \
-u "$USERNAME:$PASSWORD" \
-H "Content-Type: application/json" \
-d "{\"name\":\"$TOKEN_NAME\",\"scopes\":[\"all\"]}" \
"$API_URL/users/$USERNAME/tokens")
# Check for error
if echo "$RESPONSE" | grep -q '"message"'; then
ERROR=$(echo "$RESPONSE" | sed 's/.*"message":"\([^"]*\)".*/\1/')
echo "❌ Failed to create token: $ERROR"
echo ""
echo "Response: $RESPONSE"
exit 1
fi
# Extract token
TOKEN=$(echo "$RESPONSE" | sed 's/.*"sha1":"\([^"]*\)".*/\1/' | head -1)
TOKEN_ID=$(echo "$RESPONSE" | sed 's/.*"id":\([0-9]*\).*/\1/' | head -1)
if [ -n "$TOKEN" ] && [ ${#TOKEN} -gt 10 ]; then
echo "✅ Token created successfully!"
echo ""
echo "📋 Token details:"
echo " ID: $TOKEN_ID"
echo " Name: $TOKEN_NAME"
echo " Token: $TOKEN"
echo ""
echo "💡 Save this token for future use:"
echo ""
echo " export GITEA_TOKEN=$TOKEN"
echo ""
echo " # Add to ~/.bashrc for persistence:"
echo " echo 'export GITEA_TOKEN=$TOKEN' >> ~/.bashrc"
echo ""
else
echo "❌ Failed to extract token from response"
echo "Response: $RESPONSE"
exit 1
fi