MCPcopy Index your code
hub / github.com/1Panel-dev/1Panel / loadFromPredefined

Function loadFromPredefined

core/utils/controller/controller.go:205–224  ·  view source on GitHub ↗
(mgr Controller, keyword string)

Source from the content-addressed store, hash-verified

203}
204
205func loadFromPredefined(mgr Controller, keyword string) string {
206 predefinedMap := map[string][]string{
207 "clam": {"clamav-daemon.service", "clamd@scan.service", "clamd"},
208 "freshclam": {"clamav-freshclam.service", "freshclam.service"},
209 "fail2ban": {"fail2ban.service", "fail2ban"},
210 "supervisor": {"supervisord.service", "supervisor.service", "supervisord", "supervisor"},
211 "ssh": {"sshd.service", "ssh.service", "sshd", "ssh"},
212 "1panel-core": {"1panel-core.service"},
213 "1panel-agent": {"1panel-agent.service"},
214 "docker": {"docker.service", "dockerd"},
215 }
216 if val, ok := predefinedMap[keyword]; ok {
217 for _, item := range val {
218 if exist, _ := mgr.IsExist(item); exist {
219 return item
220 }
221 }
222 }
223 return ""
224}
225
226// GetServicePath returns the configuration file path for the specified service.
227// If serviceName is empty, it returns the default directory path based on the system's service manager.

Callers 1

LoadServiceNameFunction · 0.70

Calls 1

IsExistMethod · 0.65

Tested by

no test coverage detected