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

Function loadFromPredefined

agent/utils/controller/controller.go:179–200  ·  view source on GitHub ↗
(mgr Controller, keyword string)

Source from the content-addressed store, hash-verified

177}
178
179func loadFromPredefined(mgr Controller, keyword string) string {
180 predefinedMap := map[string][]string{
181 "clam": {"clamav-daemon.service", "clamd@scan.service", "clamd"},
182 "freshclam": {"clamav-freshclam.service", "freshclam.service"},
183 "fail2ban": {"fail2ban.service", "fail2ban"},
184 "supervisor": {"supervisord.service", "supervisor.service", "supervisord", "supervisor"},
185 "ssh": {"sshd.service", "ssh.service", "sshd", "ssh"},
186 "1panel-core": {"1panel-core.service"},
187 "1panel-agent": {"1panel-agent.service"},
188 "1panel-ai-proxy": {"1panel-ai-proxy.service"},
189 "docker": {"docker.service", "dockerd"},
190 "iptables": {"iptables", "iptables-services"},
191 }
192 if val, ok := predefinedMap[keyword]; ok {
193 for _, item := range val {
194 if exist, _ := mgr.IsExist(item); exist {
195 return item
196 }
197 }
198 }
199 return ""
200}
201
202// GetServicePath returns the configuration file path for the specified service.
203// 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