Files
dock/WebSSH
2025-11-02 17:37:28 +08:00

62 lines
1.7 KiB
Bash
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.
#!/bin/bash
echo "🚀 NexTerm 一键安装Docker Compose + 随机端口)"
# 生成加密密钥
ENCRYPTION_KEY=$(openssl rand -hex 32)
echo "🔑 生成加密密钥: $ENCRYPTION_KEY"
# 创建配置目录
mkdir -p /boot/docker-apps
# 创建 Docker Compose 配置文件
cat > /boot/docker-apps/nexterm.yml << EOF
version: '3.8'
services:
nexterm:
image: germannewsmaker/nexterm:1.0.5-OPEN-PREVIEW
container_name: nexterm
ports:
- "3000" # 随机端口
environment:
- ENCRYPTION_KEY=$ENCRYPTION_KEY
- TZ=Asia/Shanghai
volumes:
- nexterm_data:/app/data
restart: unless-stopped
volumes:
nexterm_data:
EOF
echo "📁 配置文件已创建: /boot/docker-apps/nexterm.yml"
# 停止并删除旧版本(如果存在)
echo "🔄 清理旧版本..."
docker compose -f /boot/docker-apps/nexterm.yml down 2>/dev/null || true
# 启动服务
echo "🐳 启动 NexTerm..."
docker compose -f /boot/docker-apps/nexterm.yml up -d
# 等待启动
echo "⏳ 等待服务启动..."
sleep 10
# 获取实际端口
ACTUAL_PORT=$(docker compose -f /boot/docker-apps/nexterm.yml port nexterm 3000 | cut -d: -f2)
SERVER_IP=$(curl -s ipv4.icanhazip.com 2>/dev/null || hostname -I | awk '{print $1}')
echo ""
echo "✅ 安装完成!"
echo "🌐 访问地址: http://$SERVER_IP:$ACTUAL_PORT"
echo "🔑 加密密钥: $ENCRYPTION_KEY"
echo ""
echo "📋 管理命令:"
echo " 启动: docker compose -f /boot/docker-apps/nexterm.yml start"
echo " 停止: docker compose -f /boot/docker-apps/nexterm.yml stop"
echo " 重启: docker compose -f /boot/docker-apps/nexterm.yml restart"
echo " 卸载: docker compose -f /boot/docker-apps/nexterm.yml down"
echo " 日志: docker compose -f /boot/docker-apps/nexterm.yml logs"