Files
AntiCaptcha/scripts/install.sh
T
admin 524c404194
Build and Deploy / build-frontend (push) Failing after 2s
Build and Deploy / build-backend (push) Has been skipped
Build and Deploy / build-docker (push) Has been skipped
Build and Deploy / deploy (push) Has been skipped
feat: initial commit - Go + CGO captcha recognition service
Features:
- Go + CGO ONNX/OpenCV wrapper for high performance
- SQLite (default) / MySQL database support
- Optional Redis caching
- JWT authentication system
- Multiple captcha recognition APIs:
  - OCR text recognition
  - Slider captcha matching
  - Image similarity comparison
  - Rotation captcha detection
  - Object detection
- React frontend with install wizard
- Docker and docker-compose support
- Gitea CI/CD pipeline

Project structure:
- cmd/server: Main entry point
- internal/: Core business logic
- pkg/onnx: ONNX Runtime CGO wrapper
- pkg/opencv: OpenCV CGO wrapper
- web/: React frontend
- deploy/: Deployment configs
- scripts/: Utility scripts
2026-07-16 08:56:38 +00:00

107 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# AntiCaptcha 安装脚本
set -e
echo "========================================="
echo " AntiCaptcha 安装脚本"
echo "========================================="
# 检查系统
if [ ! -f /etc/os-release ]; then
echo "无法检测操作系统"
exit 1
fi
. /etc/os-release
# 安装依赖
install_deps() {
echo "正在安装依赖..."
case "$ID" in
ubuntu|debian)
apt update
apt install -y libopencv-dev libonnxruntime-dev
;;
centos|rhel|fedora)
yum install -y opencv-devel onnxruntime
;;
alpine)
apk add --no-cache opencv onnxruntime
;;
*)
echo "不支持的系统: $ID"
exit 1
;;
esac
}
# 安装 Go
install_go() {
if command -v go &> /dev/null; then
echo "Go 已安装: $(go version)"
return
fi
echo "正在安装 Go..."
wget -q https://go.dev/dl/go1.22.5.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
rm go1.22.5.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
}
# 构建项目
build() {
echo "正在构建项目..."
go mod download
CGO_ENABLED=1 go build -o anticaptcha ./cmd/server
}
# 创建 systemd 服务
create_service() {
echo "正在创建 systemd 服务..."
cat > /etc/systemd/system/anticaptcha.service << EOF
[Unit]
Description=AntiCaptcha Service
After=network.target
[Service]
Type=simple
ExecStart=/opt/anticaptcha/anticaptcha
WorkingDirectory=/opt/anticaptcha
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable anticaptcha
}
# 主流程
main() {
install_deps
install_go
build
echo ""
echo "========================================="
echo " 安装完成!"
echo "========================================="
echo ""
echo "运行方式:"
echo " ./anticaptcha"
echo ""
echo "或创建 systemd 服务后:"
echo " systemctl start anticaptcha"
echo ""
}
main "$@"