1Panel/backend/utils
巴山夜语 79020abb1c
feat(systemctl): implement service manager initialization and command execution (#8380)
* feat(systemctl): 实现服务管理器初始化和命令执行

- 新增 systemctl 包,实现对 systemd、openrc 和 sysvinit 三种服务管理器的支持
- 添加服务状态检查、启动、停止、重启和启用/禁用功能
- 实现服务发现和智能服务名处理
- 添加配置文件查看功能
- 优化错误处理和日志记录

* refactor(system): 重构系统服务管理逻辑

- 引入 systemctl 工具包以统一处理系统服务
- 优化服务状态获取、配置文件路径解析等逻辑
- 重构 HostToolService 中的 GetToolStatus 方法
- 更新 DockerService、SettingService 等相关服务的处理方式
- 调整快照创建和恢复过程中的服务处理逻辑

* feat(utils): 添加目录复制功能并优化文件复制逻辑

- 新增 CopyDirs 函数,用于复制整个目录及其内容
- 添加对符号链接的复制支持
- 实现通用的 Copy 函数,根据文件类型自动选择 CopyFile 或 CopyDirs
- 在 CopyFile 函数中增加对源文件是目录的检查和错误提示

* refactortoolbox: 重构 Fail2ban 和 Pure-FTPd 的管理逻辑

- 优化了 Fail2ban 和 Pure-FTPd 的启动、停止、重启等操作的实现
- 改进了 Fail2ban 版本信息的获取方法
- 统一了错误处理和日志记录的格式
- 调整了部分导入的包,提高了代码的可维护性

* build: 禁用 CGO 以提高构建性能和兼容性

- 在 Linux 后端构建命令中添加 CGO_ENABLED=0 环境变量
- 此修改可以提高构建速度,并确保生成的二进制文件在没有 C 库依赖的环境中也能运行

* refactor(docker): 重构 Docker 服务的重启和操作逻辑

- 添加 isDockerSnapInstalled 函数来判断 Docker 是否通过 Snap 安装
- 在 OperateDocker 和 restartDocker 函数中增加对 Snap 安装的处理
- 移除未使用的 getDockerRestartCommand 函数

* fix(service): 优化快照恢复后的服务重启逻辑

- 在使用 systemd 管理服务时,增加 daemon-reload 操作以确保服务配置更新
- 重启 1panel 服务,以应用快照恢复的更改

* refactor(server): 支持非 systemd 系统的恢复操作

- 增加 isSystemd 函数判断系统是否为 systemd 类型
- 根据系统类型选择性地恢复服务文件
- 兼容 systemd 和非 systemd 系统的恢复流程

* fix(upgrade): 优化升级过程中的服务重启逻辑

- 移动服务重启逻辑到版本号更新之后,修复因提前重启导致的版本号未更新BUG。
- 在 systemctl 重启之前添加 daemon-reload 命令

---------

Co-authored-by: gcsong023 <gcsong023@users.noreply.github.com>
2025-04-17 10:26:13 +08:00
..
ai_tools feat: Support gpu of schema v11 (#7988) 2025-02-25 14:16:34 +08:00
captcha
cloud_storage feat: allow tencent cloud cos dual stack domain (#8123) 2025-03-11 23:58:23 +08:00
cmd fix: 解决 Docker 重启失败的问题 (#6805) 2024-10-22 09:42:28 +00:00
common feat(systemctl): implement service manager initialization and command execution (#8380) 2025-04-17 10:26:13 +08:00
compose
copier
docker perf: 优化应用同步查询接口 (#5241) 2024-05-31 09:57:20 +00:00
encrypt feat: Added password encryption for login functionality (#7764) 2025-01-23 18:09:12 +08:00
env
files fix: 解决主机文件压缩解压特殊字符问题 (#6451) 2024-09-11 08:20:15 +00:00
firewall fix(iptables): 复杂环境下转发删除端口错误 (#7868) 2025-02-13 22:56:09 +08:00
geo feat: Optimize Location Information Display in System Login Logs (#7459) 2024-12-20 04:16:25 +00:00
http fix: Fixed an issue where the language pack initialization download f… (#7375) 2024-12-16 09:00:10 +00:00
ini_conf fix: 移除项目未使用代码 (#3948) 2024-02-22 07:32:07 +00:00
jwt
mfa feat: 2FA支持前一个验证码 (#5942) 2024-07-26 11:15:53 +08:00
mysql fix: Fix the mysql root account permission switchover exception (#8378) 2025-04-11 07:08:02 +00:00
nginx feat: Add MCP management (#8299) 2025-04-02 09:01:54 +00:00
ntp
postgresql fix: Fix the issue of backup failure due to complex passwords in the pg (#7596) 2024-12-30 13:36:51 +08:00
redis fix: 修改面板设置证书时间显示不一致的问题 (#5267) 2024-06-04 03:41:50 +00:00
ssh fix(container): Fix cpu surge when the container terminal executes exit (#8096) 2025-03-07 11:06:59 +00:00
ssl feat: Website SSL DNS Type support WestCN (#8305) 2025-04-02 10:21:54 +00:00
systemctl feat(systemctl): implement service manager initialization and command execution (#8380) 2025-04-17 10:26:13 +08:00
terminal fix: Modify the container terminal connection mode (#8301) 2025-04-02 10:19:54 +00:00
toolbox feat(systemctl): implement service manager initialization and command execution (#8380) 2025-04-17 10:26:13 +08:00
websocket pref: 完善告警通知 (#6227) 2024-08-23 13:53:00 +00:00
xpack feat: Support Ollama model management (#7866) 2025-02-13 15:28:29 +08:00