| 1 | |
| 2 | |
| 3 | |
| 4 | package autostart |
| 5 | |
| 6 | import "github.com/lima-vm/lima/v2/pkg/autostart/systemd" |
| 7 | |
| 8 | |
| 9 | func DaemonManager(_ string) autoStartManager { |
| 10 | return ¬SupportedManager{} |
| 11 | } |
| 12 | |
| 13 | |
| 14 | func Manager() autoStartManager { |
| 15 | return ManagerWith(true) |
| 16 | } |
| 17 | |
| 18 | |
| 19 | |
| 20 | func ManagerWith(keepAlive bool) autoStartManager { |
| 21 | if !systemd.IsRunningSystemd() { |
| 22 | TODO: |
| 23 | return ¬SupportedManager{} |
| 24 | } |
| 25 | restart := "on-failure" |
| 26 | if !keepAlive { |
| 27 | restart = "no" |
| 28 | } |
| 29 | return &TemplateFileBasedManager{ |
| 30 | filePath: systemd.GetUnitPath, |
| 31 | template: systemd.Template, |
| 32 | enabler: systemd.EnableDisableUnit, |
| 33 | autoStartedIdentifier: systemd.AutoStartedUnitName, |
| 34 | requestStart: systemd.RequestStart, |
| 35 | requestStop: systemd.RequestStop, |
| 36 | extraTemplateVars: map[string]string{"Restart": restart}, |
| 37 | } |
| 38 | } |