Skip to content

Commit

Permalink
Keep original k3s init file for openrc (#514)
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Morales <[email protected]>

relates to kairos-io/kairos#2108

---------

Signed-off-by: Mauro Morales <[email protected]>
  • Loading branch information
mauromorales authored Jan 3, 2024
1 parent 95bc4b4 commit 9128c99
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/provider/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"strings"

logging "github.com/ipfs/go-log"
Expand Down Expand Up @@ -197,8 +198,22 @@ func oneTimeBootstrap(l logging.StandardLogger, c *providerConfig.Config, vpnSet
}

if utils.IsOpenRCBased() {
// Instead of creating an empty file, let's use the one generated by the k3s installer
content, err := os.ReadFile("/etc/init.d/k3s")
if err != nil {
l.Errorf("Failed to read init file: %s", err.Error())
return err
}

if len(content) == 0 {
err = fmt.Errorf("empty init file for k3s")
l.Errorf("openrc error: %s", err.Error())
return err
}

svc, err = openrc.NewService(
openrc.WithName(svcName),
openrc.WithUnitContent(string(content)),
)
if err != nil {
l.Errorf("Failed to create service: %s", err.Error())
Expand Down

0 comments on commit 9128c99

Please sign in to comment.