install init service
(exePath string, args []string)
| 80 | |
| 81 | // install init service |
| 82 | func (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 |
| 114 | func (this *ServiceManager) installSystemdService(systemd, exePath string, args []string) error { |