MCPcopy
hub / github.com/jeessy2/ddns-go / installService

Function installService

main.go:327–352  ·  view source on GitHub ↗

安装服务

()

Source from the content-addressed store, hash-verified

325
326// 安装服务
327func installService() {
328 s := getService()
329
330 status, err := s.Status()
331 if err != nil && status == service.StatusUnknown {
332 // 服务未知,创建服务
333 if err = s.Install(); err == nil {
334 s.Start()
335 util.Log("安装 ddns-go 服务成功! 请打开浏览器并进行配置")
336 if service.ChosenSystem().String() == "unix-systemv" {
337 if _, err := exec.Command("/etc/init.d/ddns-go", "enable").Output(); err != nil {
338 log.Println(err)
339 }
340 if _, err := exec.Command("/etc/init.d/ddns-go", "start").Output(); err != nil {
341 log.Println(err)
342 }
343 }
344 return
345 }
346 util.Log("安装 ddns-go 服务失败, 异常信息: %s", err)
347 }
348
349 if status != service.StatusUnknown {
350 util.Log("ddns-go 服务已安装, 无需再次安装")
351 }
352}
353
354// 重启服务
355func restartService() {

Callers 1

mainFunction · 0.85

Calls 4

LogFunction · 0.92
getServiceFunction · 0.85
StartMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected