MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / installInitService

Method installInitService

internal/utils/service_linux.go:82–111  ·  view source on GitHub ↗

install init service

(exePath string, args []string)

Source from the content-addressed store, hash-verified

80
81// install init service
82func (this *ServiceManager) installInitService(exePath string, args []string) error {
83 shortName := teaconst.SystemdServiceName
84 scriptFile := Tea.Root + "/scripts/" + shortName
85 if !files.NewFile(scriptFile).Exists() {
86 return errors.New("'scripts/" + shortName + "' file not exists")
87 }
88
89 data, err := os.ReadFile(scriptFile)
90 if err != nil {
91 return err
92 }
93
94 data = regexp.MustCompile("INSTALL_DIR=.+").ReplaceAll(data, []byte("INSTALL_DIR="+Tea.Root))
95 err = os.WriteFile(initServiceFile, data, 0777)
96 if err != nil {
97 return err
98 }
99
100 chkCmd, err := executils.LookPath("chkconfig")
101 if err != nil {
102 return err
103 }
104
105 err = exec.Command(chkCmd, "--add", teaconst.ProcessName).Start()
106 if err != nil {
107 return err
108 }
109
110 return nil
111}
112
113// install systemd service
114func (this *ServiceManager) installSystemdService(systemd, exePath string, args []string) error {

Callers 1

InstallMethod · 0.95

Calls 2

WriteFileMethod · 0.80
StartMethod · 0.65

Tested by

no test coverage detected