仰望星辰工作室

miaopanel

miaopanel/ internal/appstore/catalog.go 8.1 KB · 175 行 原始文件
1// Package appstore installs optional runtimes and services on demand.
2//
3// The panel no longer installs nginx or any language runtime during setup: the
4// operator picks a version in the app store and the installer runs a bounded,
5// transparent shell script as root.
6package appstore
7
8import "fmt"
9
10// Version is one selectable release of an application.
11type Version struct {
12 Version string `json:"version"`
13 Label string `json:"label"`
14 Source string `json:"source"`
15}
16
17// AppDef is the static definition of an installable application.
18type AppDef struct {
19 ID string `json:"id"`
20 Name string `json:"name"`
21 Summary string `json:"summary"`
22 Category string `json:"category"`
23 // Family limits an app to one package-manager family: "" or "any" means
24 // both Debian and RHEL derivatives, "debian" / "rhel" restrict it.
25 Family string `json:"family"`
26 Note string `json:"note"`
27 Versions []Version `json:"versions"`
28}
29
30// Installed describes one locally detected installation.
31type Installed struct {
32 Version string `json:"version"`
33 Path string `json:"path"`
34 Active bool `json:"active"`
35 Managed bool `json:"managed"`
36}
37
38// App is the API payload: definition plus local state.
39type App struct {
40 AppDef
41 Installed []Installed `json:"installed"`
42 Running bool `json:"running"`
43 Supported bool `json:"supported"`
44}
45
46var catalog = []AppDef{
47 {
48 ID: "nginx", Name: "Nginx", Category: "web", Summary: "高性能 Web 服务器 / 反向代理,站点运行的基础",
49 Note: "切换版本会重启 nginx,站点会有约 1 秒中断;安装时会从软件源解析实际的包修订号,并在 nginx -t 失败时自动处理发行版动态模块的 ABI 冲突。",
50 // Keep the newest nginx.org stable branch first. The installer resolves
51 // the distro revision (for example 1.30.6-1~bookworm) at install time,
52 // so only the upstream x.y.z needs a bump here.
53 Versions: []Version{
54 {Version: "1.30.6", Label: "1.30.6(最新稳定)", Source: "nginx.org 稳定源"},
55 {Version: "1.28.3", Label: "1.28.3(旧稳定)", Source: "nginx.org 稳定源"},
56 {Version: "1.26.3", Label: "1.26.3(旧稳定)", Source: "nginx.org 稳定源"},
57 },
58 },
59 {
60 ID: "mysql", Name: "MySQL", Category: "database", Family: "any",
61 Summary: "Oracle MySQL 官方社区版,MySQL 协议标准实现",
62 Note: "支持 Debian/Ubuntu 与 RHEL/Rocky/Alma。8.x 使用官方源、数据目录 /var/lib/mysql;5.5/5.6/5.7 使用 Oracle 通用二进制(仅 x86_64,已 EOL,仅建议兼容旧应用),安装到 /www/server/mysql、数据目录 /www/server/mysql/data,安装器会自动补齐 libaio/ncurses 兼容库并在启动失败时打印 error.log。ARM64 无法运行这三个版本,建议改用 MariaDB 或自行用 Docker 运行 amd64 镜像。与 MariaDB 互斥;卸载均保留数据。Debian 下 root 使用本机 socket 认证;RHEL 初始密码写入 data/mysql_root_password.txt。",
63 Versions: []Version{
64 {Version: "8.4", Label: "8.4(LTS)", Source: "MySQL 官方源"},
65 {Version: "8.0", Label: "8.0(稳定)", Source: "MySQL 官方源"},
66 {Version: "5.7.44", Label: "5.7.44(EOL·仅 x86_64)", Source: "Oracle 通用二进制"},
67 {Version: "5.6.51", Label: "5.6.51(EOL·仅 x86_64)", Source: "Oracle 通用二进制"},
68 {Version: "5.5.62", Label: "5.5.62(EOL·仅 x86_64)", Source: "Oracle 通用二进制"},
69 },
70 },
71 {
72 ID: "mariadb", Name: "MariaDB", Category: "database", Family: "any",
73 Summary: "MySQL 协议兼容的关系型数据库,轻量、Debian 默认",
74 Note: "支持 Debian/Ubuntu 与 RHEL/Rocky/Alma。与 MySQL 互斥(同一 3306 与数据目录);数据目录 /var/lib/mysql 在卸载时保留。",
75 Versions: []Version{
76 {Version: "11.8", Label: "11.8(最新)", Source: "MariaDB 官方源"},
77 {Version: "11.4", Label: "11.4(LTS)", Source: "MariaDB 官方源"},
78 {Version: "10.11", Label: "10.11(LTS)", Source: "MariaDB 官方源"},
79 },
80 },
81 {
82 ID: "go", Name: "Go", Category: "runtime", Summary: "Go 编译与运行环境,供 Go 类型站点使用",
83 Note: "安装到 /www/server/go/<版本>,current 指向最新安装。",
84 Versions: []Version{
85 {Version: "1.27.3", Label: "1.27.3(最新)", Source: "go.dev"},
86 {Version: "1.26.10", Label: "1.26.10(上一稳定)", Source: "go.dev"},
87 },
88 },
89 {
90 ID: "node", Name: "Node.js", Category: "runtime", Summary: "Node.js 运行时与 npm,供 Node 类型站点使用",
91 Note: "安装到 /www/server/node/<版本>,站点 unit 的 PATH 已包含 current/bin。",
92 Versions: []Version{
93 {Version: "26.12.1", Label: "26.12.1(Current)", Source: "nodejs.org"},
94 {Version: "24.22.1", Label: "24.22.1(LTS)", Source: "nodejs.org"},
95 {Version: "22.23.4", Label: "22.23.4(LTS)", Source: "nodejs.org"},
96 {Version: "20.20.2", Label: "20.20.2(维护期)", Source: "nodejs.org"},
97 },
98 },
99 {
100 ID: "python", Name: "Python", Category: "runtime", Summary: "独立 Python 运行时(含 pip),不影响系统 Python",
101 Note: "使用 python-build-standalone 独立构建,安装到 /www/server/python/<版本>。",
102 Versions: []Version{
103 {Version: "3.14", Label: "3.14(最新补丁)", Source: "python-build-standalone"},
104 {Version: "3.13", Label: "3.13(最新补丁)", Source: "python-build-standalone"},
105 {Version: "3.12", Label: "3.12(最新补丁)", Source: "python-build-standalone"},
106 {Version: "3.11", Label: "3.11(最新补丁)", Source: "python-build-standalone"},
107 },
108 },
109 {
110 ID: "phpmyadmin", Name: "phpMyAdmin", Category: "tool", Summary: "Web 端数据库管理工具",
111 Note: "安装到 /www/wwwroot/phpmyadmin/<版本>,并自动创建 PHP 站点监听 0.0.0.0:16520:安装完成后直接访问 http://服务器IP:16520/(PHP 版本自动选择已安装的最高版)。需先安装 PHP。",
112 Versions: []Version{
113 {Version: "5.2.2", Label: "5.2.2(稳定)", Source: "files.phpmyadmin.net"},
114 },
115 },
116 {
117 ID: "php", Name: "PHP", Category: "runtime", Family: "any",
118 Summary: "PHP-FPM 运行时及常用扩展,供 PHP 站点使用",
119 Note: "Debian 使用 Sury 源(/run/php/php<版本>-fpm.sock);RHEL 使用 Remi 源(/run/php-fpm/www.sock)。",
120 Versions: []Version{
121 {Version: "8.5", Label: "8.5(最新)", Source: "Sury"},
122 {Version: "8.4", Label: "8.4(稳定)", Source: "Sury"},
123 {Version: "8.3", Label: "8.3(稳定)", Source: "Sury"},
124 {Version: "8.2", Label: "8.2(LTS)", Source: "Sury"},
125 {Version: "8.1", Label: "8.1(旧稳定)", Source: "Sury"},
126 {Version: "8.0", Label: "8.0(EOL)", Source: "Sury"},
127 {Version: "7.4", Label: "7.4(EOL)", Source: "Sury"},
128 {Version: "7.3", Label: "7.3(EOL)", Source: "Sury"},
129 {Version: "7.2", Label: "7.2(EOL)", Source: "Sury"},
130 {Version: "7.1", Label: "7.1(EOL)", Source: "Sury"},
131 },
132 },
133 {
134 ID: "git", Name: "Git", Category: "tool", Summary: "分布式版本控制工具",
135 Note: "使用发行版软件源安装。",
136 Versions: []Version{
137 {Version: "system", Label: "系统源最新", Source: "apt"},
138 },
139 },
140 {
141 ID: "docker", Name: "Docker", Category: "runtime", Family: "any",
142 Summary: "容器运行时与 Docker Compose,支持国内镜像加速",
143 Note: "使用阿里云 Docker CE 镜像源安装 docker-ce、compose 插件;首次安装写入国内 registry mirror 与日志轮转配置。安装后可在 Docker 页面填写阿里云个人加速地址。",
144 Versions: []Version{
145 {Version: "system", Label: "阿里云源最新稳定版", Source: "mirrors.aliyun.com/docker-ce"},
146 },
147 },
148}
149
150var appIndex = func() map[string]AppDef {
151 out := make(map[string]AppDef, len(catalog))
152 for _, app := range catalog {
153 out[app.ID] = app
154 }
155 return out
156}()
157
158func lookupApp(id string) (AppDef, bool) {
159 app, ok := appIndex[id]
160 return app, ok
161}
162
163func lookupVersion(app AppDef, version string) (Version, bool) {
164 for _, v := range app.Versions {
165 if v.Version == version {
166 return v, true
167 }
168 }
169 return Version{}, false
170}
171
172// revision is the package suffix marker used by the nginx.org repository.
173func nginxPackageVersion(version, codename string) string {
174 return fmt.Sprintf("%s-1~%s", version, codename)
175}