2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-05 05:47:17 +08:00

refactor: 重构os包

This commit is contained in:
耗子
2024-06-23 01:08:07 +08:00
parent 85c38e5bc5
commit c876f4c484
13 changed files with 54 additions and 71 deletions

View File

@@ -1,7 +1,6 @@
package plugins
import (
"os"
"regexp"
"strings"
@@ -11,9 +10,9 @@ import (
"github.com/TheTNB/panel/app/http/controllers"
"github.com/TheTNB/panel/pkg/io"
"github.com/TheTNB/panel/pkg/os"
"github.com/TheTNB/panel/pkg/shell"
"github.com/TheTNB/panel/pkg/systemctl"
"github.com/TheTNB/panel/pkg/tools"
)
type PhpMyAdminController struct {
@@ -24,7 +23,7 @@ func NewPhpMyAdminController() *PhpMyAdminController {
}
func (r *PhpMyAdminController) Info(ctx http.Context) http.Response {
files, err := os.ReadDir("/www/server/phpmyadmin")
files, err := io.ReadDir("/www/server/phpmyadmin")
if err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, "找不到 phpMyAdmin 目录")
}
@@ -72,7 +71,7 @@ func (r *PhpMyAdminController) SetPort(ctx http.Context) http.Response {
return controllers.ErrorSystem(ctx)
}
if tools.IsRHEL() {
if os.IsRHEL() {
if out, err := shell.Execf("firewall-cmd --zone=public --add-port=%d/tcp --permanent", port); err != nil {
return controllers.Error(ctx, http.StatusInternalServerError, out)
}