#!/bin/bash

# 确保配置目录存在
mkdir -p config
mkdir -p data
mkdir -p uploads

# 检查配置文件是否存在
if [ ! -f config/config.yaml ]; then
    echo "创建默认配置文件..."
    cat > config/config.yaml << EOF
server:
  port: 8080
  mode: debug

database:
  type: sqlite3
  path: ./data/license.db

jwt:
  secret: your-secret-key-change-this
  expire: 24h

email:
  host: smtp.example.com
  port: 587
  username: your-email@example.com
  password: your-password

upload:
  path: ./uploads

site:
  title: "授权验证管理平台"
  description: "专业的软件授权和设备管理平台"
  base_url: "http://localhost:8080"
  icp: "京ICP备XXXXXXXX号-1"
  copyright: "© 2024 Your Company Name. All rights reserved."
  logo: "/static/images/logo.png"
  favicon: "/static/images/favicon.ico"
EOF
fi

# 编译并运行
echo "编译程序..."
go build -o licserver cmd/main.go

echo "启动服务器..."
./licserver 