319f683a16
- 8 categories / 50 generators covering middleware, databases, runtimes, systemd services, system tools, network, monitoring, security - VNC supports XFCE / GNOME / KDE Plasma / MATE / LXQt desktops - Node.js versions 18-26 (incl. current LTS 24 Krypton and current 26) - Live preview, copy / download / multi-script bundle in web UI - Distro-aware (Ubuntu/Debian/CentOS/RHEL/Rocky/Alma/Fedora) - All 50 generators pass bash -n syntax check - Zero pip dependencies (Flask stdlib only)
166 lines
5.0 KiB
Markdown
166 lines
5.0 KiB
Markdown
# shell-gen — Linux 一键部署脚本生成器
|
|
|
|
Web 界面的 Linux 服务/中间件/运行时一键安装脚本生成器。在网页填写参数,实时生成可立即
|
|
执行的 `bash` 脚本。所有脚本支持 Ubuntu/Debian/CentOS/RHEL/Rocky/Alma 自动检测。
|
|
|
|
> 不在生成器所在机器运行;生成的脚本拿到目标机器上 `sudo bash xxx.sh` 即可。
|
|
|
|
## 快速开始
|
|
|
|
```bash
|
|
cd /root/shell-gen
|
|
bash start.sh
|
|
# 浏览器打开 http://<server>:5099/
|
|
```
|
|
|
|
或者用 systemd:
|
|
```bash
|
|
cp shell-gen.service /etc/systemd/system/
|
|
systemctl daemon-reload
|
|
systemctl enable --now shell-gen
|
|
```
|
|
|
|
## 已包含的生成器(50 个)
|
|
|
|
### 中间件服务 (10)
|
|
- **VNC 远程桌面** — TigerVNC + XFCE
|
|
- **Nginx** — 静态站点 / 反向代理 / 自签 SSL
|
|
- **HAProxy** — L4/L7 负载均衡 + stats 面板
|
|
- **Keepalived** — VRRP 双机热备 VIP 漂移
|
|
- **Redis** — 密码 + AOF + ACL
|
|
- **RabbitMQ** — 管理插件 + admin 用户
|
|
- **Tomcat** — 任意版本,生成 systemd unit
|
|
- **Docker** — Engine + buildx + compose + 国内镜像
|
|
- **etcd** — 单节点 / 集群
|
|
- **ZooKeeper** — 单节点 / 集群
|
|
|
|
### 数据库 (8)
|
|
- **PostgreSQL** — 任意版本 (PGDG 官方源)
|
|
- **MySQL / MariaDB** — 5.7 / 8.0 / 8.4 / 10.11 / 11.4
|
|
- **MongoDB** — 4.4 / 5.0 / 6.0 / 7.0 + 副本集
|
|
- **Memcached** — 监听/内存/连接数
|
|
- **SQLite** — 命令行工具 + sqlite-utils
|
|
- **Elasticsearch** — 7.x / 8.x 单节点
|
|
- **ClickHouse** — 服务端 + 客户端
|
|
- **Consul** — Service Discovery
|
|
|
|
### 开发语言运行时 (10)
|
|
- **Python** — 2.7 - 3.13 (源码编译)
|
|
- **Node.js** — 14/16/18/20/21/22 (二进制)
|
|
- **GCC** — 8.5 - 14.1 (源码编译)
|
|
- **Make** — 任意版本
|
|
- **CMake** — 任意版本
|
|
- **Go** — 1.18 - 1.23
|
|
- **OpenJDK** — 8/11/17/21
|
|
- **PHP** — 7.4 - 8.3 (含 fpm)
|
|
- **Ruby** — 2.7 - 3.3
|
|
- **Rust** — rustup + toolchain (rsproxy 国内镜像)
|
|
|
|
### systemd 服务 (6)
|
|
- **通用 systemd** — 任意命令 → unit
|
|
- **Gunicorn (Python)**
|
|
- **Node.js**
|
|
- **Java -jar (SpringBoot)**
|
|
- **Go binary**
|
|
- **Shell 脚本**
|
|
|
|
### 系统工具 (8)
|
|
- **防火墙** — ufw / firewalld / iptables 三合一
|
|
- **Swap** — 文件型
|
|
- **时间同步** — chrony (国内 NTP)
|
|
- **SSH 加固** — 端口 / 密码 / 公钥 / 横幅
|
|
- **Sysctl 调优** — BBR / TCP / 文件句柄
|
|
- **ulimit 资源限制**
|
|
- **主机名 / hosts**
|
|
- **磁盘自动挂载 (fstab)**
|
|
|
|
### 网络工具 (4)
|
|
- **WireGuard** — VPN + 自动生成客户端配置 + 二维码
|
|
- **Tailscale** — 客户端 + 自定义控制服务器
|
|
- **Dnsmasq** — DHCP + DNS 缓存
|
|
- **OpenVPN** — 简化部署 + 客户端配置生成
|
|
|
|
### 监控告警 (4)
|
|
- **Prometheus Node Exporter**
|
|
- **Prometheus Server** — 多个 scrape jobs
|
|
- **Grafana** — 自动添加 Prometheus 数据源
|
|
- **Logrotate** — 通用日志轮转
|
|
|
|
## 使用流程
|
|
|
|
1. **打开首页** `/` 浏览 50 个生成器
|
|
2. **点击进入详情页** 填写参数
|
|
3. **实时预览** — 右侧实时显示生成的脚本
|
|
4. **三种交付方式**:
|
|
- 📋 复制 — 直接粘贴到目标服务器
|
|
- 💾 下载 — 拿到 .sh 文件
|
|
- 📦 加入套餐 — 多个生成器合并成 zip + master installer
|
|
|
|
## 特色
|
|
|
|
- **distro 通用**: Ubuntu/Debian 自动用 apt, RHEL/CentOS/Rocky/Alma 自动用 yum,
|
|
未知发行版回退到 iptables。脚本运行时报 `[shell-gen] ...` 前缀,方便日志搜索。
|
|
- **语法已校验**: 50 个生成器默认参数生成的脚本均通过 `bash -n` 语法检查。
|
|
- **idempotent**: 多数脚本支持重复运行(用 cp + bak 备份,systemd daemon-reload)。
|
|
- **零依赖**: 仅需 Python 3.8+,Flask 标准库即可;无 pip 依赖。
|
|
|
|
## 添加自定义生成器
|
|
|
|
```python
|
|
# generators/myapp.py
|
|
from . import register, Generator, Field
|
|
from . import bash_header, quote, bool_str
|
|
|
|
class MyService(Generator):
|
|
id = "myservice"
|
|
title = "我的服务"
|
|
category = "middleware" # middleware/databases/runtimes/systemd/system/network/monitoring/security
|
|
icon = "🚀"
|
|
tags = ["custom"]
|
|
description = "..."
|
|
fields = [
|
|
Field("port", "端口", "number", default="8080"),
|
|
]
|
|
def render(self, p):
|
|
port = p.get("port", "8080")
|
|
out = [bash_header(self.title)]
|
|
out.append('apt-get install -y mypkg')
|
|
# ...
|
|
return "\n".join(out) + "\n"
|
|
|
|
register(MyService())
|
|
```
|
|
|
|
然后在 `app.py` 的 import 块加一行:
|
|
```python
|
|
from generators import myapp # noqa
|
|
```
|
|
|
|
## API
|
|
|
|
```bash
|
|
# 列出所有生成器
|
|
curl http://localhost:5099/api/categories
|
|
|
|
# 预览脚本
|
|
curl -X POST http://localhost:5099/api/preview \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"generator": "nginx", "params": {"server_name": "demo.local", "listen_port": "80"}}'
|
|
|
|
# 下载
|
|
curl -X POST http://localhost:5099/api/download \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"generator": "redis", "params": {"port": "6379"}}' \
|
|
-o redis.sh
|
|
|
|
# 打包多个
|
|
curl -X POST http://localhost:5099/api/bundle \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{"items": [{"generator": "redis", "params": {}}, {"generator": "nginx", "params": {}}]}' \
|
|
-o bundle.zip
|
|
```
|
|
|
|
## License
|
|
|
|
MIT
|