diff --git a/internal/utils/firewall.go b/internal/utils/firewall.go index 29e29094..a9f71854 100644 --- a/internal/utils/firewall.go +++ b/internal/utils/firewall.go @@ -4,6 +4,7 @@ package utils import ( "github.com/TeaOSLab/EdgeAPI/internal/remotelogs" + executils "github.com/TeaOSLab/EdgeAPI/internal/utils/exec" "github.com/iwind/TeaGo/types" "os/exec" "runtime" @@ -14,7 +15,7 @@ func AddPortsToFirewall(ports []int) { // Linux if runtime.GOOS == "linux" { // firewalld - firewallCmd, _ := exec.LookPath("firewall-cmd") + firewallCmd, _ := executils.LookPath("firewall-cmd") if len(firewallCmd) > 0 { err := exec.Command(firewallCmd, "--add-port="+types.String(port)+"/tcp").Run() if err == nil { diff --git a/internal/utils/service_linux.go b/internal/utils/service_linux.go index a90950d3..a3f631bf 100644 --- a/internal/utils/service_linux.go +++ b/internal/utils/service_linux.go @@ -5,6 +5,7 @@ package utils import ( "errors" teaconst "github.com/TeaOSLab/EdgeAPI/internal/const" + executils "github.com/TeaOSLab/EdgeAPI/internal/utils/exec" "github.com/iwind/TeaGo/Tea" "github.com/iwind/TeaGo/files" "os" @@ -15,13 +16,13 @@ import ( var systemdServiceFile = "/etc/systemd/system/edge-api.service" var initServiceFile = "/etc/init.d/" + teaconst.SystemdServiceName -// 安装服务 +// Install 安装服务 func (this *ServiceManager) Install(exePath string, args []string) error { if os.Getgid() != 0 { return errors.New("only root users can install the service") } - systemd, err := exec.LookPath("systemctl") + systemd, err := executils.LookPath("systemctl") if err != nil { return this.installInitService(exePath, args) } @@ -29,14 +30,14 @@ func (this *ServiceManager) Install(exePath string, args []string) error { return this.installSystemdService(systemd, exePath, args) } -// 启动服务 +// Start 启动服务 func (this *ServiceManager) Start() error { if os.Getgid() != 0 { return errors.New("only root users can start the service") } if files.NewFile(systemdServiceFile).Exists() { - systemd, err := exec.LookPath("systemctl") + systemd, err := executils.LookPath("systemctl") if err != nil { return err } @@ -53,7 +54,7 @@ func (this *ServiceManager) Uninstall() error { } if files.NewFile(systemdServiceFile).Exists() { - systemd, err := exec.LookPath("systemctl") + systemd, err := executils.LookPath("systemctl") if err != nil { return err } @@ -93,7 +94,7 @@ func (this *ServiceManager) installInitService(exePath string, args []string) er return err } - chkCmd, err := exec.LookPath("chkconfig") + chkCmd, err := executils.LookPath("chkconfig") if err != nil { return err }