愉快的使用cursor
This commit is contained in:
81
agent-wdd/op/SystemdExcutor.go
Normal file
81
agent-wdd/op/SystemdExcutor.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user