headscale-tailscale-replace.../farmq-admin/check_existing_data.py
시골약사 c37cf023c1 사이드바 브랜딩을 PharmQ Super Admin (PSA)로 업데이트
- base.html 상단 네비게이션 브랜딩 변경
- 팜큐 약국 관리 시스템 → PharmQ Super Admin (PSA)
- UI 일관성 향상을 위한 브랜딩 통합

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 13:45:29 +09:00

104 lines
3.9 KiB
Python

#!/usr/bin/env python3
"""
기존 Headscale 데이터 확인 스크립트
"""
import sqlite3
import os
from datetime import datetime
def check_headscale_data():
"""Headscale 데이터베이스의 기존 데이터 확인"""
db_path = '/srv/headscale-setup/data/db.sqlite'
if not os.path.exists(db_path):
print(f"❌ Database file not found: {db_path}")
return
print(f"📊 Checking Headscale database: {db_path}")
print("=" * 60)
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
try:
# 테이블 목록 확인
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
tables = cursor.fetchall()
print(f"📋 Available tables: {[table[0] for table in tables]}")
print()
# Users 테이블 확인
try:
cursor.execute("SELECT * FROM users")
users = cursor.fetchall()
print(f"👥 Users ({len(users)} records):")
if users:
cursor.execute("PRAGMA table_info(users)")
columns = [col[1] for col in cursor.fetchall()]
print(f" Columns: {columns}")
for user in users:
print(f" - {dict(zip(columns, user))}")
print()
except Exception as e:
print(f" ❌ Error reading users: {e}")
# Nodes 테이블 확인
try:
cursor.execute("SELECT * FROM nodes")
nodes = cursor.fetchall()
print(f"💻 Nodes ({len(nodes)} records):")
if nodes:
cursor.execute("PRAGMA table_info(nodes)")
columns = [col[1] for col in cursor.fetchall()]
print(f" Columns: {columns}")
for node in nodes:
node_dict = dict(zip(columns, node))
print(f" - ID: {node_dict.get('id')}, Given Name: {node_dict.get('given_name')}, "
f"Hostname: {node_dict.get('hostname')}, IPv4: {node_dict.get('ipv4')}, "
f"User ID: {node_dict.get('user_id')}")
print()
except Exception as e:
print(f" ❌ Error reading nodes: {e}")
# PreAuthKeys 테이블 확인
try:
cursor.execute("SELECT * FROM pre_auth_keys")
keys = cursor.fetchall()
print(f"🔑 PreAuth Keys ({len(keys)} records):")
if keys:
cursor.execute("PRAGMA table_info(pre_auth_keys)")
columns = [col[1] for col in cursor.fetchall()]
print(f" Columns: {columns}")
for key in keys:
key_dict = dict(zip(columns, key))
print(f" - ID: {key_dict.get('id')}, Key: {key_dict.get('key')[:20]}..., "
f"Used: {key_dict.get('used')}, User ID: {key_dict.get('user_id')}")
print()
except Exception as e:
print(f" ❌ Error reading pre_auth_keys: {e}")
# API Keys 테이블 확인
try:
cursor.execute("SELECT * FROM api_keys")
api_keys = cursor.fetchall()
print(f"🗝️ API Keys ({len(api_keys)} records):")
if api_keys:
cursor.execute("PRAGMA table_info(api_keys)")
columns = [col[1] for col in cursor.fetchall()]
print(f" Columns: {columns}")
for api_key in api_keys:
key_dict = dict(zip(columns, api_key))
print(f" - ID: {key_dict.get('id')}, Prefix: {key_dict.get('prefix')}, "
f"Created: {key_dict.get('created_at')}")
print()
except Exception as e:
print(f" ❌ Error reading api_keys: {e}")
except Exception as e:
print(f"❌ Database connection error: {e}")
finally:
conn.close()
if __name__ == '__main__':
check_headscale_data()