From a1dceaaa829645cee35e5b30215ce50f31de18c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Mon, 10 Jun 2024 01:53:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0Podman=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/services/plugin.go | 1 + scripts/frp/update.sh | 82 +++++++++++++++++++++++++++++++++++++ scripts/podman/install.sh | 43 +++++++++++++++++++ scripts/podman/uninstall.sh | 40 ++++++++++++++++++ scripts/podman/update.sh | 42 +++++++++++++++++++ types/plugin_list.go | 56 +++++++++++++++---------- 6 files changed, 242 insertions(+), 22 deletions(-) create mode 100644 scripts/frp/update.sh create mode 100644 scripts/podman/install.sh create mode 100644 scripts/podman/uninstall.sh create mode 100644 scripts/podman/update.sh diff --git a/internal/services/plugin.go b/internal/services/plugin.go index 357594d8..234f967a 100644 --- a/internal/services/plugin.go +++ b/internal/services/plugin.go @@ -53,6 +53,7 @@ func (r *PluginImpl) All() []types.Plugin { types.PluginRsync, types.PluginSupervisor, types.PluginFail2ban, + types.PluginPodman, types.PluginFrp, types.PluginGitea, types.PluginToolBox, diff --git a/scripts/frp/update.sh b/scripts/frp/update.sh new file mode 100644 index 00000000..9e137f20 --- /dev/null +++ b/scripts/frp/update.sh @@ -0,0 +1,82 @@ +#!/bin/bash +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/www/server/bin:/www/server/sbin:$PATH + +: ' +Copyright (C) 2022 - now HaoZi Technology Co., Ltd. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +' + +HR="+----------------------------------------------------" +ARCH=$(uname -m) +downloadUrl="https://dl.cdn.haozi.net/panel/frp" +frpPath="/www/server/frp" +frpVersion="0.58.0" + +if [ ! -d "${frpPath}" ]; then + mkdir -p ${frpPath} +fi + +# 架构判断 +if [ "${ARCH}" == "x86_64" ]; then + frpFile="frp_${frpVersion}_linux_amd64.7z" +elif [ "${ARCH}" == "aarch64" ]; then + frpFile="frp_${frpVersion}_linux_arm64.7z" +else + echo -e $HR + echo "错误:不支持的架构" + exit 1 +fi + +# 备份配置 +if [ -f "${frpPath}/frps.toml" ]; then + cp -f ${frpPath}/frps.toml ${frpPath}/frps.toml.bak +fi +if [ -f "${frpPath}/frpc.toml" ]; then + cp -f ${frpPath}/frpc.toml ${frpPath}/frpc.toml.bak +fi + +# 下载frp +cd ${frpPath} +wget -T 120 -t 3 -O ${frpPath}/${frpFile} ${downloadUrl}/${frpFile} +wget -T 20 -t 3 -O ${frpPath}/${frpFile}.checksum.txt ${downloadUrl}/${frpFile}.checksum.txt +if ! sha256sum --status -c ${frpPath}/${frpFile}.checksum.txt; then + echo -e $HR + echo "错误:frp checksum 校验失败,文件可能被篡改或不完整,已终止操作" + rm -rf ${frpPath} + exit 1 +fi + +# 解压frp +cd ${frpPath} +7z x ${frpFile} +chmod -R 700 ${frpPath} +rm -f ${frpFile} ${frpFile}.checksum.txt + +# 还原配置 +if [ -f "${frpPath}/frps.toml.bak" ]; then + cp -f ${frpPath}/frps.toml.bak ${frpPath}/frps.toml +fi +if [ -f "${frpPath}/frpc.toml.bak" ]; then + cp -f ${frpPath}/frpc.toml.bak ${frpPath}/frpc.toml +fi + +systemctl restart frps +systemctl restart frpc + +panel writePlugin frp ${frpVersion} +echo -e ${HR} +echo "frp 安装完成" +echo -e ${HR} + diff --git a/scripts/podman/install.sh b/scripts/podman/install.sh new file mode 100644 index 00000000..8ce28950 --- /dev/null +++ b/scripts/podman/install.sh @@ -0,0 +1,43 @@ +#!/bin/bash +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/www/server/bin:/www/server/sbin:$PATH + +: ' +Copyright (C) 2022 - now HaoZi Technology Co., Ltd. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +' + +HR="+----------------------------------------------------" +OS=$(source /etc/os-release && { [[ "$ID" == "debian" ]] && echo "debian"; } || { [[ "$ID" == "centos" ]] || [[ "$ID" == "rhel" ]] || [[ "$ID" == "rocky" ]] || [[ "$ID" == "almalinux" ]] && echo "centos"; } || echo "unknown") +podmanVersion="4.0.0" + +if [ "${OS}" == "centos" ]; then + dnf makecache -y + dnf install podman -y +elif [ "${OS}" == "debian" ]; then + apt-get update + apt-get install podman -y +else + echo -e $HR + echo "错误:耗子 Linux 面板不支持该系统" + exit 1 +fi + +systemctl enable podman +systemctl start podman + +panel writePlugin podman ${podmanVersion} +echo -e ${HR} +echo "podman 安装完成" +echo -e ${HR} diff --git a/scripts/podman/uninstall.sh b/scripts/podman/uninstall.sh new file mode 100644 index 00000000..e7263fa8 --- /dev/null +++ b/scripts/podman/uninstall.sh @@ -0,0 +1,40 @@ +#!/bin/bash +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH + +: ' +Copyright (C) 2022 - now HaoZi Technology Co., Ltd. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +' + +HR="+----------------------------------------------------" +OS=$(source /etc/os-release && { [[ "$ID" == "debian" ]] && echo "debian"; } || { [[ "$ID" == "centos" ]] || [[ "$ID" == "rhel" ]] || [[ "$ID" == "rocky" ]] || [[ "$ID" == "almalinux" ]] && echo "centos"; } || echo "unknown") + +systemctl stop podman +systemctl disable podman + +if [ "${OS}" == "centos" ]; then + dnf remove podman -y +elif [ "${OS}" == "debian" ]; then + apt-get remove podman -y +else + echo -e $HR + echo "错误:耗子 Linux 面板不支持该系统" + exit 1 +fi + +panel deletePlugin podman +echo -e $HR +echo "podman 卸载完成" +echo -e $HR diff --git a/scripts/podman/update.sh b/scripts/podman/update.sh new file mode 100644 index 00000000..5dac8788 --- /dev/null +++ b/scripts/podman/update.sh @@ -0,0 +1,42 @@ +#!/bin/bash +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/www/server/bin:/www/server/sbin:$PATH + +: ' +Copyright (C) 2022 - now HaoZi Technology Co., Ltd. + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +' + +HR="+----------------------------------------------------" +OS=$(source /etc/os-release && { [[ "$ID" == "debian" ]] && echo "debian"; } || { [[ "$ID" == "centos" ]] || [[ "$ID" == "rhel" ]] || [[ "$ID" == "rocky" ]] || [[ "$ID" == "almalinux" ]] && echo "centos"; } || echo "unknown") +podmanVersion="4.0.0" + +if [ "${OS}" == "centos" ]; then + dnf makecache -y + dnf update podman -y +elif [ "${OS}" == "debian" ]; then + apt-get update + apt-get upgrade podman -y +else + echo -e $HR + echo "错误:耗子 Linux 面板不支持该系统" + exit 1 +fi + +systemctl restart podman + +panel writePlugin podman ${podmanVersion} +echo -e ${HR} +echo "podman 安装完成" +echo -e ${HR} diff --git a/types/plugin_list.go b/types/plugin_list.go index 9a3b0e5b..316eb4a5 100644 --- a/types/plugin_list.go +++ b/types/plugin_list.go @@ -2,7 +2,7 @@ package types var PluginOpenResty = Plugin{ Name: "OpenResty", - Description: "OpenResty® 是一款基于 NGINX 和 LuaJIT 的 Web 平台。", + Description: "OpenResty® 是一款基于 NGINX 和 LuaJIT 的 Web 平台", Slug: "openresty", Version: "1.25.3.1", Requires: []string{}, @@ -14,7 +14,7 @@ var PluginOpenResty = Plugin{ var PluginMySQL57 = Plugin{ Name: "MySQL-5.7", - Description: "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品。(已停止维护,不建议使用!预计 2025 年 12 月移除)", + Description: "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品(已停止维护,不建议使用!预计 2025 年 12 月移除)", Slug: "mysql57", Version: "5.7.44", Requires: []string{}, @@ -26,7 +26,7 @@ var PluginMySQL57 = Plugin{ var PluginMySQL80 = Plugin{ Name: "MySQL-8.0", - Description: "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品。(建议内存 > 2G 安装)", + Description: "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品(建议内存 > 2G 安装)", Slug: "mysql80", Version: "8.0.37", Requires: []string{}, @@ -38,7 +38,7 @@ var PluginMySQL80 = Plugin{ var PluginMySQL84 = Plugin{ Name: "MySQL-8.4", - Description: "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品。(建议内存 > 2G 安装)", + Description: "MySQL 是最流行的关系型数据库管理系统之一,Oracle 旗下产品(建议内存 > 2G 安装)", Slug: "mysql84", Version: "8.4.0", Requires: []string{}, @@ -50,7 +50,7 @@ var PluginMySQL84 = Plugin{ var PluginPostgreSQL15 = Plugin{ Name: "PostgreSQL-15", - Description: "PostgreSQL 是世界上最先进的开源关系数据库,在类似 BSD 与 MIT 许可的 PostgreSQL 许可下发行。", + Description: "PostgreSQL 是世界上最先进的开源关系数据库,在类似 BSD 与 MIT 许可的 PostgreSQL 许可下发行", Slug: "postgresql15", Version: "15.7", Requires: []string{}, @@ -62,7 +62,7 @@ var PluginPostgreSQL15 = Plugin{ var PluginPostgreSQL16 = Plugin{ Name: "PostgreSQL-16", - Description: "PostgreSQL 是世界上最先进的开源关系数据库,在类似 BSD 与 MIT 许可的 PostgreSQL 许可下发行。", + Description: "PostgreSQL 是世界上最先进的开源关系数据库,在类似 BSD 与 MIT 许可的 PostgreSQL 许可下发行", Slug: "postgresql16", Version: "16.3", Requires: []string{}, @@ -74,7 +74,7 @@ var PluginPostgreSQL16 = Plugin{ var PluginPHP74 = Plugin{ Name: "PHP-7.4", - Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言。(已停止维护,不建议使用!预计 2024 年 12 月移除)", + Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言(已停止维护,不建议使用!预计 2024 年 12 月移除)", Slug: "php74", Version: "7.4.33", Requires: []string{}, @@ -86,7 +86,7 @@ var PluginPHP74 = Plugin{ var PluginPHP80 = Plugin{ Name: "PHP-8.0", - Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言。(已停止维护,不建议使用!预计 2025 年 12 月移除)", + Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言(已停止维护,不建议使用!预计 2025 年 12 月移除)", Slug: "php80", Version: "8.0.30", Requires: []string{}, @@ -98,7 +98,7 @@ var PluginPHP80 = Plugin{ var PluginPHP81 = Plugin{ Name: "PHP-8.1", - Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言。", + Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言", Slug: "php81", Version: "8.1.29", Requires: []string{}, @@ -110,7 +110,7 @@ var PluginPHP81 = Plugin{ var PluginPHP82 = Plugin{ Name: "PHP-8.2", - Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言。", + Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言", Slug: "php82", Version: "8.2.20", Requires: []string{}, @@ -122,7 +122,7 @@ var PluginPHP82 = Plugin{ var PluginPHP83 = Plugin{ Name: "PHP-8.3", - Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言。", + Description: "PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言", Slug: "php83", Version: "8.3.8", Requires: []string{}, @@ -134,7 +134,7 @@ var PluginPHP83 = Plugin{ var PluginPHPMyAdmin = Plugin{ Name: "phpMyAdmin", - Description: "phpMyAdmin 是一个以 PHP 为基础,以 Web-Base 方式架构在网站主机上的 MySQL 数据库管理工具。", + Description: "phpMyAdmin 是一个以 PHP 为基础,以 Web-Base 方式架构在网站主机上的 MySQL 数据库管理工具", Slug: "phpmyadmin", Version: "5.2.1", Requires: []string{}, @@ -146,7 +146,7 @@ var PluginPHPMyAdmin = Plugin{ var PluginPureFTPd = Plugin{ Name: "Pure-FTPd", - Description: "Pure-Ftpd 是一个快速、高效、轻便、安全的 FTP 服务器,它以安全和配置简单为设计目标,支持虚拟主机,IPV6,PAM 等功能。", + Description: "Pure-Ftpd 是一个快速、高效、轻便、安全的 FTP 服务器,它以安全和配置简单为设计目标,支持虚拟主机,IPV6,PAM 等功能", Slug: "pureftpd", Version: "1.0.50", Requires: []string{}, @@ -158,7 +158,7 @@ var PluginPureFTPd = Plugin{ var PluginRedis = Plugin{ Name: "Redis", - Description: "Redis 是一个开源的使用 ANSI C 语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value 数据库,并提供多种语言的 API。", + Description: "Redis 是一个开源的使用 ANSI C 语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value 数据库,并提供多种语言的 API", Slug: "redis", Version: "7.2.5", Requires: []string{}, @@ -170,7 +170,7 @@ var PluginRedis = Plugin{ var PluginS3fs = Plugin{ Name: "S3fs", - Description: "S3fs 通过 FUSE 挂载兼容 S3 标准的存储桶,例如 Amazon S3、阿里云 OSS、腾讯云 COS、七牛云 Kodo 等。", + Description: "S3fs 通过 FUSE 挂载兼容 S3 标准的存储桶,例如 Amazon S3、阿里云 OSS、腾讯云 COS、七牛云 Kodo 等", Slug: "s3fs", Version: "1.9", Requires: []string{}, @@ -182,7 +182,7 @@ var PluginS3fs = Plugin{ var PluginRsync = Plugin{ Name: "Rsync", - Description: "Rsync 是一款提供快速增量文件传输的开源工具。", + Description: "Rsync 是一款提供快速增量文件传输的开源工具", Slug: "rsync", Version: "3.2.7", Requires: []string{}, @@ -194,7 +194,7 @@ var PluginRsync = Plugin{ var PluginSupervisor = Plugin{ Name: "Supervisor", - Description: "Supervisor 是一个客户端/服务器系统,允许用户监视和控制类 UNIX 操作系统上的多个进程。", + Description: "Supervisor 是一个客户端/服务器系统,允许用户监视和控制类 UNIX 操作系统上的多个进程", Slug: "supervisor", Version: "4.2.5", Requires: []string{}, @@ -206,7 +206,7 @@ var PluginSupervisor = Plugin{ var PluginFail2ban = Plugin{ Name: "Fail2ban", - Description: "Fail2ban 扫描系统日志文件并从中找出多次尝试失败的IP地址,将该IP地址加入防火墙的拒绝访问列表中。", + Description: "Fail2ban 扫描系统日志文件并从中找出多次尝试失败的IP地址,将该IP地址加入防火墙的拒绝访问列表中", Slug: "fail2ban", Version: "1.0.2", Requires: []string{}, @@ -216,28 +216,40 @@ var PluginFail2ban = Plugin{ Update: `bash /www/panel/scripts/fail2ban/update.sh`, } +var PluginPodman = Plugin{ + Name: "Podman", + Description: "Podman(POD MANager)是一款用于管理容器和镜像、挂载到这些容器中的卷以及由容器组构成的 Pod 的工具", + Slug: "podman", + Version: "4.0.0", + Requires: []string{}, + Excludes: []string{"docker"}, + Install: `bash /www/panel/scripts/podman/install.sh`, + Uninstall: `bash /www/panel/scripts/podman/uninstall.sh`, + Update: `bash /www/panel/scripts/podman/update.sh`, +} + var PluginFrp = Plugin{ Name: "Frp", - Description: "frp 是一个专注于内网穿透的高性能的反向代理应用。", + Description: "frp 是一个专注于内网穿透的高性能的反向代理应用", Slug: "frp", Version: "0.58.0", Requires: []string{}, Excludes: []string{}, Install: `bash /www/panel/scripts/frp/install.sh`, Uninstall: `bash /www/panel/scripts/frp/uninstall.sh`, - Update: `bash /www/panel/scripts/frp/install.sh`, + Update: `bash /www/panel/scripts/frp/update.sh`, } var PluginGitea = Plugin{ Name: "Gitea", - Description: "Gitea 是一款极易搭建的自助 Git 服务,它包括 Git 托管、代码审查、团队协作、软件包注册和 CI/CD。", + Description: "Gitea 是一款极易搭建的自助 Git 服务,它包括 Git 托管、代码审查、团队协作、软件包注册和 CI/CD", Slug: "gitea", Version: "1.22.0", Requires: []string{}, Excludes: []string{}, Install: `bash /www/panel/scripts/gitea/install.sh`, Uninstall: `bash /www/panel/scripts/gitea/uninstall.sh`, - Update: `bash /www/panel/scripts/gitea/install.sh`, + Update: `bash /www/panel/scripts/gitea/update.sh`, } var PluginToolBox = Plugin{