mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-04-27 19:28:59 +00:00
* 🎨 Split off cli into separate binaries This commit splits off the cli into 3 binaries: - agent - cli - provider The provider now is a separate component that can be tested by itself and have its own lifecycle. This paves the way to a ligher c3os variant, HA support and other features that can be provided on runtime. This is working, but still there are low hanging fruit to care about. Fixes #14 * 🤖 Add provider bin to releases * ⚙️ Handle signals * ⚙️ Reduce buildsize footprint * 🎨 Scan for providers also in /system/providers * 🤖 Run goreleaser * 🎨 Refactoring
34 lines
685 B
Go
34 lines
685 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(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
|
|
}
|