梦想主机经理

运维部署 社区 v1.0.0

技能解读

当前原文的自动摘译,尚未人工审校。

1. 设置凭证

复制并配置.env文件:有关详细的凭据设置,请参阅setup_guide.md。

2. 配置域映射(可选但推荐)

将您的域名添加到.env以方便命名:

3. 测试连接

验证您的设置是否有效(使用域名或完整路径):

4. 部署您的站点

对于 React 应用程序: 对于静态站点: 对于备份:

反应应用程序部署

部署使用 Create React App、Vite 或 Next.js 构建的 React 应用程序: 自动:检测框架类型 运行构建过程 上传优化的工件

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
运维部署
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
98 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@0-CYBERDYNE-SYSTEMS-0 · v1.0.0 · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
Python
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
  • 读取环境变量
网络行为
仅限本地
安装命令数
无(仅作为资料)
作者说明文件(原文) SKILL.md

# DreamHost Manager Skill

Complete solution for managing websites on DreamHost hosting via SFTP/SSH.

## Quick Start

### 1. Setup Credentials

Copy and configure `.env` file:

```bash
cp assets/.env.template .env
# Edit .env with your DreamHost credentials
```

See `setup_guide.md` for detailed credential setup.

### 2. Configure Domain Mappings (Optional but Recommended)

Add your domains to `.env` for convenient naming:

```bash
# .env
DOMAIN_farm-friend.com=/home/dh_cqevup/farm-friend.com
DOMAIN_yourdomain.com=/home/username/yourdomain.com
```

### 3. Test Connection

Verify your setup works (using domain name or full path):

```bash
# Using domain name (if configured in .env)
python scripts/sftp_operations.py list farm-friend.com

# Using full path (always works)
python scripts/sftp_operations.py list /home/dh_cqevup/farm-friend.com
```

### 4. Deploy Your Site

**For React apps:**
```bash
# Using domain name
python scripts/react_deployer.py deploy . farm-friend.com
python scripts/routing_manager.py configure-app farm-friend.com

# Or using full path
python scripts/react_deployer.py deploy . /home/dh_cqevup/farm-friend.com
python scripts/routing_manager.py configure-app /home/dh_cqevup/farm-friend.com
```

**For static sites:**
```bash
python scripts/directory_sync.py upload ./my-website farm-friend.com
```

**For backups:**
```bash
python scripts/backup_restore.py backup farm-friend.com ./backups
```

## Core Features

### React Application Deployment

Deploy React apps built with Create React App, Vite, or Next.js:

```bash
python scripts/react_deployer.py deploy <project_dir> <remote_path>
```

Automatically:
- Detects framework type
- Runs build process
- Uploads optimized artifacts
- Cleans old deployments

### Multi-Site Routing

Configure multiple sites on same domain using:
- **Subdomains**: `app1.yourdomain.com`, `app2.yourdomain.com`
- **Subdirectories**: `yourdomain.com/app1`, `yourdomain.com/app2`

```bash
# Subdomain
python scripts/routing_manager.py configure-subdomain /home/user/app1.yourdomain.com

# Subdirectory
python scripts/routing_manager.py configure-subdir app1 /home/user/yourdomain.com/app1
```

### File Operations

Upload, download, and manage files:

```bash
# Upload single file
python scripts/sftp_operations.py upload ./index.html yourdomain.com/index.html

# Download file
python scripts/sftp_operations.py download yourdomain.com/index.html ./backup.html

# List files
python scripts/sftp_operations.py list yourdomain.com

# Create directory
python scripts/sftp_operations.py mkdir yourdomain.com/new-folder

# Delete file
python scripts/sftp_operations.py delete yourdomain.com/old.html
```

Note: Use domain names (if configured in .env) or full paths like `/home/user/yourdomain.com`

### Directory Synchronization

Sync entire directories for quick deployments:

```bash
python scripts/directory_sync.py upload ./my-website yourdomain.com
```

Features:
- Recursive upload/download
- Timestamp comparison (skips unchanged files)
- Automatic exclusion (.git, node_modules, etc.)
- Progress tracking

### Backup & Restore

Create and restore timestamped backups:

```bash
# Create backup
python scripts/backup_restore.py backup yourdomain.com ./backups

# List backups
python scripts/backup_restore.py list ./backups

# Restore backup
python scripts/backup_restore.py restore ./backups/backup_20240115_120000.tar.gz yourdomain.com
```

Features:
- Automatic timestamped backups
- Tar.gz compression
- Safe restore (backs up current version first)
- Large file support

### Blog & Content Management

Upload and manage blog posts:

```bash
# Upload post with images
python scripts/blog_manager.py upload ./posts/my-post.md yourdomain.com/blog

# List posts
python scripts/blog_manager.py list yourdomain.com/blog

# Update post
python scripts/blog_manager.py update ./posts/my-post.md yourdomain.com/blog/my-post.md

# Delete post
python scripts/blog_manager.py delete yourdomain.com/blog/old.md
```

### Server Commands

Execute shell commands on the server:

```bash
# Check disk usage
python scripts/ssh_commands.py disk-usage yourdomain.com

# Change file permissions
python scripts/ssh_commands.py chmod yourdomain.com/config.php 644

# Recursively change permissions (standard web setup)
python scripts/ssh_commands.py chmod-recursive yourdomain.com 644 755

# Create symlink
python scripts/ssh_commands.py symlink yourdomain.com /backup

# Find files
python scripts/ssh_commands.py find yourdomain.com "*.html"

# Execute custom command
python scripts/ssh_commands.py exec "cd /home/user/yourdomain.com && ls -la"
```

## Scripts Reference

| Script | Purpose | Key Functions |
|--------|---------|---------------|
| `sftp_operations.py` | Core file operations | upload, download, list, mkdir, delete, rename |
| `directory_sync.py` | Sync directories | Recursive upload/download with timestamp checking |
| `react_deployer.py` | Deploy React apps | Auto-detect framework, build, deploy artifacts |
| `routing_manager.py` | Configure routing | .htaccess for React Router, multi-site setup |
| `backup_restore.py` | Backup management | Create, restore, list timestamped backups |
| `ssh_commands.py` | Server commands | chmod, symlinks, find, disk usage |
| `blog_manager.py` | Blog content | Upload posts, manage assets, organize content |

## Documentation

- **setup_guide.md** - Credential setup and first-time configuration
- **common_workflows.md** - Practical examples for deployment, backups, content management
- **react_deployment.md** - React-specific deployment and multi-site routing

## Configuration

### .env File Format

```bash
DREAMHOST_HOST=your_host.dreamhost.com
DREAMHOST_USER=your_username
DREAMHOST_PASSWORD=your_password
# OR for SSH key (more secure):
# DREAMHOST_SSH_KEY_PATH=/path/to/.ssh/id_rsa
```

See `assets/.env.template` for complete template with security notes.

### Domain Name Mapping & Per-Domain Credentials

Each domain can have its own DreamHost credentials (host, user, password). Configure them in your `.env` file:

```bash
# .env
# ========== DOMAIN 1: farm-friend.com ==========
DOMAIN_farm-friend.com=/home/dh_cqevup/farm-friend.com
DREAMHOST_HOST_farm-friend.com=server1.dreamhost.com
DREAMHOST_USER_farm-friend.com=user1
DREAMHOST_PASSWORD_farm-friend.com=password1

# ========== DOMAIN 2: yourdomain.com ==========
DOMAIN_yourdomain.com=/home/dh_xxxx/yourdomain.com
DREAMHOST_HOST_yourdomain.com=server2.dreamhost.com
DREAMHOST_USER_yourdomain.com=user2
DREAMHOST_PASSWORD_yourdomain.com=password2
```

The agent automatically extracts the domain from your command and uses the matching credentials:

```bash
# Agent automatically uses farm-friend.com credentials
python scripts/sftp_operations.py list farm-friend.com

# Agent automatically uses yourdomain.com credentials
python scripts/react_deployer.py deploy . yourdomain.com

# Also works with full paths (uses credentials from the domain in the path)
python scripts/sftp_operations.py list /home/dh_cqevup/farm-friend.com
```

**How it works:**
1. Agent extracts domain from the command: `farm-friend.com`
2. Looks up credentials in .env: `DREAMHOST_HOST_farm-friend.com`, `DREAMHOST_USER_farm-friend.com`, etc.
3. Connects to that domain's DreamHost account
4. Performs the requested operation

This allows seamless management of multiple domains with different DreamHost accounts.

## Common Workflows

### Deploy Static Website

```bash
python scripts/directory_sync.py upload ./website yourdomain.com
```

### Deploy React App with Routing

```bash
python scripts/react_deployer.py deploy . yourdomain.com
python scripts/routing_manager.py configure-app yourdomain.com
```

### Daily Backup

```bash
python scripts/backup_restore.py backup yourdomain.com ./backups
```

### Update Blog Post

```bash
python scripts/blog_manager.py update ./posts/post.md yourdomain.com/blog/post.md
```

See `references/common_workflows.md` for more examples.

## Dependencies

Install required packages:

```bash
pip install -r requirements.txt
```

Required:
- **paramiko** - SFTP/SSH library
- **python-dotenv** - Environment variable loading
- **scp** - Enhanced file transfer

## Troubleshooting

### Connection Issues

1. Verify credentials in `.env`
2. Check host is accessible
3. Confirm SFTP port 22 is open
4. Test with: `python scripts/sftp_operations.py list /home/username`

See `references/setup_guide.md` for detailed troubleshooting.

## Next Steps

1. Follow setup in `references/setup_guide.md`
2. Test with examples in `references/common_workflows.md`
3. Deploy your site!

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。