Files
obsidian-vault/family/how-to/gitea-config.md
T

73 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: Gitea Config
created: '2026-05-23'
updated: '2026-09-14'
type: tech
namespace: family
tags: [infra, gitea, git, credentials]
related:
- "[[family/plans/t610-home-automation]]"
- "[[family/how-to/truenas-access]]"
---
# Gitea Config
**URL (внешний):** `https://git.mallexxx.duckdns.org`**HTTPS**, DNS `90.189.160.148`
**Версия:** 1.27.3 (проверено 2026-09-14: `GET /api/v1/version`)
**Внутренний LAN endpoint:** `http://172.16.3.4:3000`
**User:** `git_admin` (id 1, **is_admin: true**)
## API Token
Token name: `eagle-reflect`
Token value: `f2e6...8844` (полное значение — в remote репо `nolvu-landing` на Mac)
**Использование (проверено):**
```bash
TOKEN=$(git -C ~/Developer/nolvu-landing remote get-url origin | sed -E 's|https://git_admin:([^@]+)@.*|\1|')
curl -sS -H "Authorization: token $TOKEN" https://git.mallexxx.duckdns.org/api/v1/user # → кто я
curl -sS -H "Authorization: token $TOKEN" 'https://git.mallexxx.duckdns.org/api/v1/user/repos?limit=50'
```
> ⚠️ **В inline-команде Hermes эта конструкция ломается** (см. «Питфоллы») — писать скрипт файлом.
## Создание приватного репо через API (эталон 2026-09-14)
```bash
curl -sS -X POST -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
-d '{"name":"<REPO>","private":true,"auto_init":false,"default_branch":"main"}' \
'https://git.mallexxx.duckdns.org/api/v1/user/repos' | jq '{full_name,private,clone_url}'
```
## Рабочий паттерн remote + креды (НЕ токен в URL)
```bash
git remote add origin 'https://git.mallexxx.duckdns.org/git_admin/<REPO>.git' # чистый URL!
git config credential.helper store
printf 'https://git_admin:%s@git.mallexxx.duckdns.org\n' "$TOKEN" >> ~/.git-credentials
chmod 600 ~/.git-credentials
git push -u origin main
```
Проверка: `git ls-remote origin` — SHA должен совпасть с `git rev-parse HEAD`.
## Существующие репозитории (2026-09-14)
| Репо | Видимость |
|---|---|
| `git_admin/eagle-hermes` | private |
| `git_admin/kraken-docker-config` | private |
| `git_admin/nolvu-landing` | private |
| `git_admin/obsidian-vault` | **public** (единственный) |
| `git_admin/reflect-app` | private |
| `git_admin/HA-ZONT-Modbus` | private (создан 2026-09-14, см. `[[family/plans/t610-home-automation]]` §5-кватер-Е) |
## Питфоллы
1. 🔴 **Токен в URL = утечка.** В `.git/config` репо `nolvu-landing` remote записан как `https://git_admin:<token>@git.mallexxx.duckdns.org/...` → токен светится в каждом `git remote -v` и в выводах команд/логах. **Правильно:** чистый URL + токен в `~/.git-credentials` (chmod 600) + `credential.helper=store`. Кандидат на **ротацию токена**.
2. ⚠️ **Inline shell в Hermes ломается** на `$( … | sed -E 's|…|…|' )` — приём спотыкается на `|`. **Решение: писать скрипт файлом** (`write_file``bash file.sh`), не инлайн. Пример: `~/tmp-t610/setup_gitea_creds.sh`.
3. 📌 Старый адрес `http://git.mallexxx.duckdns.org` (без `s`) — **устарел**, рабочая схема только `https://`.
## Notes
- External URL использует DuckDNS DDNS на домашний IP.
- Внутренний API endpoint предпочтительнее, когда ты в домашней сети.