From 7082e2fa43f9c0b7dbaa364c93184d1c284d5aec Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 8 Nov 2023 16:53:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=20ssh=20=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E8=87=AA=E5=90=AF=E7=8A=B6=E6=80=81=E5=88=A4=E6=96=AD?= =?UTF-8?q?=20(#2851)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/ssh.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/app/service/ssh.go b/backend/app/service/ssh.go index 421785a04..0b2ab9ea1 100644 --- a/backend/app/service/ssh.go +++ b/backend/app/service/ssh.go @@ -68,7 +68,18 @@ func (u *SSHService) GetSSHInfo() (*dto.SSHInfo, error) { data.Status = constant.StatusEnable } } - data.AutoStart, _ = systemctl.IsEnable(serviceName) + + out, err := systemctl.RunSystemCtl("is-enabled", serviceName) + if err != nil { + data.AutoStart = false + } else { + if out == "alias\n" { + data.AutoStart, _ = systemctl.IsEnable("ssh") + } else { + data.AutoStart = out == "enabled\n" + } + } + sshConf, err := os.ReadFile(sshPath) if err != nil { data.Message = err.Error()