Files
kairos-agent/cmd/agent/rotate.go
Ettore Di Giacinto c7cbb37b24 gear: Extract netboot artifacts
This changeset also adds a `config_url` and `options` keyword in the c3os config.
Along with that the config logic is changed so the configuration is taken also from boot commands and merged in the final installed config file.
2022-07-07 16:57:38 +00:00

34 lines
705 B
Go

package main
import (
machine "github.com/c3os-io/c3os/internal/machine"
"github.com/c3os-io/c3os/internal/vpn"
config "github.com/c3os-io/c3os/pkg/config"
)
func rotate(configDir []string, newToken, apiAddress, rootDir string, restart bool) error {
if err := config.ReplaceToken(configDir, newToken); err != nil {
return err
}
c, err := config.Scan(config.Directories(configDir...))
if err != nil {
return err
}
err = vpn.Setup(machine.EdgeVPNDefaultInstance, apiAddress, rootDir, false, c)
if err != nil {
return err
}
if restart {
svc, err := machine.EdgeVPN(machine.EdgeVPNDefaultInstance, rootDir)
if err != nil {
return err
}
return svc.Restart()
}
return nil
}