mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-13 13:10:22 +00:00
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.
34 lines
705 B
Go
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
|
|
}
|