diff --git a/initialize/config.go b/initialize/config.go index d4c845c..efad99f 100644 --- a/initialize/config.go +++ b/initialize/config.go @@ -265,8 +265,13 @@ func processUnits(units []system.Unit, root string, um system.UnitManager) error } if restartNetworkd { + log.Printf("Restarting systemd-networkd") networkd := system.Unit{Unit: config.Unit{Name: "systemd-networkd.service"}} - actions = append(actions, action{networkd, "restart"}) + res, err := um.RunUnitCommand(networkd, "restart") + if err != nil { + return err + } + log.Printf("Restarted systemd-networkd (%s)", res) } for _, action := range actions { @@ -275,7 +280,7 @@ func processUnits(units []system.Unit, root string, um system.UnitManager) error if err != nil { return err } - log.Printf("Result of %q on %q': %s", action.command, action.unit.Name, res) + log.Printf("Result of %q on %q: %s", action.command, action.unit.Name, res) } return nil diff --git a/initialize/config_test.go b/initialize/config_test.go index d3cc3ba..0dad5a4 100644 --- a/initialize/config_test.go +++ b/initialize/config_test.go @@ -87,16 +87,26 @@ func TestProcessUnits(t *testing.T) { { units: []system.Unit{ system.Unit{Unit: config.Unit{ - Name: "foo.network", + Name: "baz.service", + Content: "[Service]\nExecStart=/bin/baz", + Command: "start", }}, system.Unit{Unit: config.Unit{ - Name: "bar.network", + Name: "foo.network", + Content: "[Network]\nFoo=true", + }}, + system.Unit{Unit: config.Unit{ + Name: "bar.network", + Content: "[Network]\nBar=true", }}, }, result: TestUnitManager{ + placed: []string{"baz.service", "foo.network", "bar.network"}, commands: []UnitAction{ UnitAction{"systemd-networkd.service", "restart"}, + UnitAction{"baz.service", "start"}, }, + reload: true, }, }, {