Files
dock/WebSSH
2025-11-02 12:07:33 +08:00

59 lines
1.5 KiB
Plaintext
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.
va#!/bin/bash
# NexTerm 一键安装脚本
set -e
echo "🚀 开始安装 NexTerm..."
# 定义变量
CONTAINER_NAME="nexterm"
PORT="6989"
VOLUME_NAME="nexterm"
IMAGE="germannewsmaker/nexterm:1.0.5-OPEN-PREVIEW"
# 生成安全的加密密钥(如果未提供)
if [ -z "$ENCRYPTION_KEY" ]; then
echo "🔑 生成加密密钥..."
ENCRYPTION_KEY=$(openssl rand -hex 32)
echo "生成的加密密钥: $ENCRYPTION_KEY"
echo "请妥善保存此密钥!"
fi
# 停止并删除已存在的容器
echo "🛑 清理现有容器..."
docker rm -f $CONTAINER_NAME 2>/dev/null || true
# 创建数据卷
echo "💾 创建数据卷..."
docker volume create $VOLUME_NAME 2>/dev/null || true
# 运行容器
echo "🐳 启动 NexTerm 容器..."
docker run -d \
--name $CONTAINER_NAME \
--hostname $CONTAINER_NAME \
-p $PORT:6989 \
-e ENCRYPTION_KEY=$ENCRYPTION_KEY \
-e TZ=Asia/Shanghai \
--restart=unless-stopped \
--log-opt max-size=10m \
--log-opt max-file=3 \
-v $VOLUME_NAME:/app/data \
$IMAGE
# 等待服务启动
echo "⏳ 等待服务启动..."
sleep 10
# 检查容器状态
if docker ps | grep -q $CONTAINER_NAME; then
echo "✅ NexTerm 安装成功!"
echo "📊 容器名称: $CONTAINER_NAME"
echo "🌐 访问地址: http://$(curl -s ipv4.icanhazip.com 2>/dev/null || hostname -I | awk '{print $1}'):$PORT"
echo "🔑 加密密钥: $ENCRYPTION_KEY"
echo "💾 数据卷: $VOLUME_NAME"
else
echo "❌ 容器启动失败请检查日志docker logs $CONTAINER_NAME"
exit 1
fi