Go to file
시골약사 53c1f45e02 🚀 Add complete client registration system for FARMQ Headscale
## New Features:
- **register-client.sh**: Automated client registration script
  - Auto-detects OS (Ubuntu/CentOS/macOS)
  - Installs Tailscale automatically
  - Registers to https://head.0bin.in with pre-auth key
  - Verifies connection and displays status

- **create-preauth-key.sh**: Pre-auth key management script
  - Creates users and pre-auth keys with custom expiration
  - Supports reusable keys for multiple devices
  - Provides ready-to-use registration commands
  - Example: `./create-preauth-key.sh pharmacy1 7d`

- **CLIENT_SETUP_GUIDE.md**: Complete installation guide
  - Automated and manual installation instructions
  - Cross-platform support (Linux/macOS/Windows/Mobile)
  - Troubleshooting section
  - Key management for admins

## Pharmacy Page Fix:
- Fix machine count display in pharmacy management page
- Update get_all_pharmacies_with_stats() to use actual Headscale Node data
- Show correct online/offline machine counts per pharmacy
- Fixed: "0대" → "2대 online" for proper machine statistics

## Key Benefits:
- **One-line registration**: `sudo ./register-client.sh`
- **Pre-auth keys work once, connect forever** - answers user's question
- **Reusable keys** for multiple devices per pharmacy
- **Cross-platform** support for all major operating systems

Current active keys:
- myuser: fc4f2dc55ee00c5352823d156129b9ce2df4db02f1d76a21
- pharmacy1: 5c15b41ea8b135dbed42455ad1a9a0cf0352b100defd241c (7d validity)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 18:23:04 +09:00
config 🎉 Working Headscale Setup with Docker Complete 2025-09-09 14:34:56 +09:00
farmq-admin 🚀 Add complete client registration system for FARMQ Headscale 2025-09-09 18:23:04 +09:00
headplane-config 🔧 Fix Headplane UI configuration and enable external access 2025-09-09 15:10:56 +09:00
.env.example 🎉 Working Headscale Setup with Docker Complete 2025-09-09 14:34:56 +09:00
.gitignore 📝 Update .gitignore to exclude Python virtual environments and cache files 2025-09-09 15:53:11 +09:00
CLIENT_CONNECTION_TEST.md 📚 Update documentation with Headplane UI access and configuration 2025-09-09 15:12:54 +09:00
CLIENT_SETUP_GUIDE.md 🚀 Add complete client registration system for FARMQ Headscale 2025-09-09 18:23:04 +09:00
create-preauth-key.sh 🚀 Add complete client registration system for FARMQ Headscale 2025-09-09 18:23:04 +09:00
docker-compose.yml 🔧 Fix Headplane UI configuration and enable external access 2025-09-09 15:10:56 +09:00
FARMQ_HEADPLANE_CUSTOMIZATION_PLAN.md 🏥 Add FARMQ Headplane customization business plan 2025-09-09 15:34:12 +09:00
HEADPLANE_KOREAN_LOCALIZATION_PLAN.md 📋 Add Headplane Korean localization plan 2025-09-09 15:24:04 +09:00
headscale_models.py 🗃️ Add comprehensive SQLAlchemy models for Headscale database 2025-09-09 15:47:16 +09:00
INSTALLATION_GUIDE.md 📚 Update documentation with Headplane UI access and configuration 2025-09-09 15:12:54 +09:00
README.md 🎉 Working Headscale Setup with Docker Complete 2025-09-09 14:34:56 +09:00
register-client.sh 🚀 Add complete client registration system for FARMQ Headscale 2025-09-09 18:23:04 +09:00
start.sh 📚 Update documentation with Headplane UI access and configuration 2025-09-09 15:12:54 +09:00
test_headscale_models.py 🗃️ Add comprehensive SQLAlchemy models for Headscale database 2025-09-09 15:47:16 +09:00
TROUBLESHOOTING_DATABASE_FOREIGN_KEY.md 🏥 Add complete FARMQ Admin Flask application 2025-09-09 17:44:56 +09:00

🚀 Headscale + Headplane Docker Setup

Tailscale을 완전히 대체하는 자체 호스팅 솔루션

📁 파일 구조

headscale-setup/
├── docker-compose.yml    # Docker Compose 설정
├── .env                  # 환경변수 (복사 필요)
├── .env.example          # 환경변수 템플릿
├── start.sh             # 자동 설치 스크립트
├── README.md            # 이 문서
├── .gitignore           # Git 제외 파일
├── config/
│   └── config.yaml      # Headscale 설정
├── data/                # 데이터베이스 및 키 파일 (자동 생성)
└── run/                 # 런타임 파일 (자동 생성)

🚀 Git Repository

🚀 빠른 시작

1. 환경변수 설정

# .env.example을 .env로 복사
cp .env.example .env

2. 자동 설치 (권장)

# 실행 권한 부여 및 실행
chmod +x ./start.sh
./start.sh

3. 수동 설치

# 1. Headscale 시작
docker-compose up -d headscale

# 2. API 키 생성
docker-compose exec headscale headscale apikeys create

# 3. .env 파일에 API 키 입력 (HEADSCALE_API_KEY 값 수정)
vi .env

# 4. Headplane 시작
docker-compose up -d headplane

📋 접속 정보

👤 사용자 관리

사용자 생성

docker-compose exec headscale headscale users create myuser

Pre-auth 키 생성

docker-compose exec headscale headscale preauthkeys create --user myuser --reusable --expiration 24h

📱 클라이언트 연결

Linux/macOS

# Tailscale 클라이언트 설치 후
tailscale up --login-server=http://localhost:8080

Windows

tailscale up --login-server=http://localhost:8080

🔧 유용한 명령어

상태 확인

docker-compose ps
docker-compose logs -f

노드 목록 확인

docker-compose exec headscale headscale nodes list

사용자 목록 확인

docker-compose exec headscale headscale users list

🛠️ 트러블슈팅

컨테이너 재시작

docker-compose restart

로그 확인

docker-compose logs headscale
docker-compose logs headplane

완전 초기화

docker-compose down
sudo rm -rf data/*
docker-compose up -d

🔄 Git 관리

필요시 수동으로 Git 커밋을 진행하세요:

# 현재 상태 확인
git status

# 변경사항 커밋
git add .
git commit -m "Update: 설명"
git push origin main