愉快的使用cursor

This commit is contained in:
zeaslity
2025-02-26 09:25:24 +08:00
parent 60a1849207
commit b8170e00d4
11 changed files with 554 additions and 89 deletions

View File

@@ -0,0 +1,81 @@
package op
// SystemdUp 启动服务
func SystemdUp(serviceName string) (bool, []string) {
ok, resultLog := SingleLineCommandExecutor([]string{"systemctl", "enable", serviceName})
if !ok {
return false, resultLog
}
ok, resultLog = SingleLineCommandExecutor([]string{"systemctl", "start", serviceName})
if !ok {
return false, resultLog
}
return true, resultLog
}
// SystemdDown 停止服务
func SystemdDown(serviceName string) (bool, []string) {
ok, resultLog := SingleLineCommandExecutor([]string{"systemctl", "disable", serviceName})
if !ok {
return false, resultLog
}
ok, resultLog = SingleLineCommandExecutor([]string{"systemctl", "stop", serviceName})
if !ok {
return false, resultLog
}
return true, resultLog
}
// SystemdStatus 查看服务状态
func SystemdStatus(serviceName string) (bool, []string) {
ok, resultLog := SingleLineCommandExecutor([]string{"systemctl", "status", serviceName})
if !ok {
return false, resultLog
}
return true, resultLog
}
// SystemdRestart 重启服务
func SystemdRestart(serviceName string) (bool, []string) {
ok, resultLog := SingleLineCommandExecutor([]string{"systemctl", "restart", serviceName})
if !ok {
return false, resultLog
}
return true, resultLog
}
// SystemdReload 重新加载服务
func SystemdReload(serviceName string) (bool, []string) {
ok, resultLog := SingleLineCommandExecutor([]string{"systemctl", "reload", serviceName})
if !ok {
return false, resultLog
}
return true, resultLog
}
// SystemdEnable 启用服务
func SystemdEnable(serviceName string) (bool, []string) {
ok, resultLog := SingleLineCommandExecutor([]string{"systemctl", "enable", serviceName})
if !ok {
return false, resultLog
}
return true, resultLog
}
// SystemdDisable 禁用服务
func SystemdDisable(serviceName string) (bool, []string) {
ok, resultLog := SingleLineCommandExecutor([]string{"systemctl", "disable", serviceName})
if !ok {
return false, resultLog
}
return true, resultLog
}
// SystemdDaemonReload 重新加载服务
func SystemdDaemonReload() (bool, []string) {
ok, resultLog := SingleLineCommandExecutor([]string{"systemctl", "daemon-reload"})
if !ok {
return false, resultLog
}
return true, resultLog
}