# tianwen_server_shell **Repository Path**: shandian534/tianwen_server_shell ## Basic Information - **Project Name**: tianwen_server_shell - **Description**: 服务器安装相关 - **Primary Language**: Shell - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-23 - **Last Updated**: 2026-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 天问服务端 Shell (tianwen_server_shell) > 天问服务端 Shell 脚本项目 ## 项目简介 本项目是天问服务端的 Shell 脚本集合,用于服务器管理、部署、监控等自动化操作。 ## 目录结构 ``` tianwen_server_shell/ ├── scripts/ # Shell 脚本目录 ├── config/ # 配置文件目录 ├── tests/ # 测试脚本目录 ├── docs/ # 文档目录 ├── logs/ # 日志文件目录(运行时生成) ├── .claude/ # Claude AI 配置 ├── .gitignore # Git 忽略规则 ├── CLAUDE.md # AI 上下文文档 └── README.md # 项目说明(本文件) ``` ## 环境要求 - **操作系统**: Linux / macOS / Unix - **Shell**: Bash 4.0+ 或兼容的 Shell - **工具**: Git ## 快速开始 ### 1. 克隆仓库 ```bash git clone cd tianwen_server_shell ``` ### 2. 配置环境 ```bash # 复制配置模板(如果存在) cp config/config.example.env config/config.env # 编辑配置文件 vim config/config.env ``` ### 3. 运行脚本 ```bash # 赋予脚本执行权限 chmod +x scripts/*.sh # 运行示例脚本 ./scripts/example.sh --help ``` ## 脚本说明 ### scripts/ | 脚本名称 | 功能描述 | 状态 | |---------|---------|------| | example.sh | 示例脚本模板 | 模板 | | install_jdk8.sh | JDK 8 一键安装脚本 | 已完成 | | set_static_ip.sh | 静态IP配置脚本 | 已完成 | | maven_deploy.sh | Maven 打包部署脚本 | 已完成 | ## Maven 打包部署 使用 `scripts/maven_deploy.sh` 脚本可以一键完成 Maven 项目的打包、上传和部署。 ### 使用方法 ```bash # 基本使用(交互式选择服务器) ./scripts/maven_deploy.sh # 指定服务器和 Profile ./scripts/maven_deploy.sh -s 生产服务器 -p prod # 仅打包,不上传 ./scripts/maven_deploy.sh -n # 跳过测试 ./scripts/maven_deploy.sh -t # 查看帮助 ./scripts/maven_deploy.sh --help ``` ### 实际使用示例 ```bash # 仅打包(已测试成功) ./scripts/maven_deploy.sh -s 丰泽服务器 -f /Users/shandian/IdeaProjects/flexflow2.0edubigdata/pom.xml -n # 完整部署(打包 + 上传到服务器) ./scripts/maven_deploy.sh -s 丰泽服务器 -f /Users/shandian/IdeaProjects/flexflow2.0edubigdata/pom.xml # 使用其他 profile ./scripts/maven_deploy.sh -s 丰泽服务器 -f /path/to/pom.xml -p production ``` **参数说明**: - `-s <服务器名>`: 指定服务器配置(如"丰泽服务器") - `-f `: 指定 Maven 项目的 pom.xml 文件路径 - `-n`: 仅打包模式,跳过上传和部署 - `-p `: 指定 Maven profile(如 production) ### 功能特性 - **Maven 打包**: 自动查找 pom.xml 并执行打包 - **文件上传**: 使用 RSYNC 高效传输文件 - **远程部署**: SSH 连接远程服务器执行部署脚本 - **多服务器支持**: 配置文件支持多个服务器配置 - **安全验证**: 部署前检查 SSH 连接和远程脚本 ### 配置文件 在 `config/deploy.conf` 中配置服务器信息: ```bash SERVER_NAME=生产服务器 SERVER_HOST=192.168.1.100 SERVER_USER=root SERVER_PORT=22 DEPLOY_PATH=/opt/app/ DEPLOY_SCRIPT=/opt/app/deploy.sh RSYNC_EXCLUDE=--exclude=.git --exclude=target --exclude=logs SSH_KEY=~/.ssh/id_rsa ``` 详细使用说明请参考 [Maven 部署脚本使用指南](docs/maven_deploy_guide.md)。 --- ## 静态IP配置 使用 `scripts/set_static_ip.sh` 脚本可以方便地将动态获取IP改为固定IP配置。 ### 使用方法 ```bash # 交互式配置 sudo ./scripts/set_static_ip.sh # 指定接口配置 sudo ./scripts/set_static_ip.sh -i eth0 # 查看帮助 ./scripts/set_static_ip.sh --help ``` ### 支持的系统 - RHEL/CentOS 7/8/9 - Debian 10+ - Ubuntu 18.04+ - Arch Linux ### 安全特性 - 自动备份原始配置 - 配置前预览确认 - 配置后网络验证 - 提供回滚步骤 ## 开发指南 ### 添加新脚本 1. 在 `scripts/` 目录下创建新的 `.sh` 文件 2. 参考 `example.sh` 的格式和结构 3. 添加执行权限: `chmod +x scripts/your-script.sh` 4. 编写对应的测试脚本放在 `tests/` 目录 ### 代码规范 - 使用 `#!/bin/bash` 作为 shebang - 启用严格模式: `set -euo pipefail` - 添加详细的注释和文档 - 使用有意义的函数和变量命名 - 实现错误处理和日志记录 ### 测试 ```bash # 运行测试脚本 bash tests/test_example.sh ``` ## 常见问题 ### Q: 脚本没有执行权限? ```bash chmod +x scripts/*.sh ``` ### Q: 如何调试脚本? ```bash # 启用调试模式 bash -x scripts/your-script.sh ``` ## 贡献指南 1. Fork 本仓库 2. 创建特性分支: `git checkout -b feature/your-feature` 3. 提交更改: `git commit -am 'Add some feature'` 4. 推送分支: `git push origin feature/your-feature` 5. 提交 Pull Request ## 许可证 [待定] ## 联系方式 - 项目维护者: [待填写] - 问题反馈: [待填写] --- *最后更新: 2026-03-24*