mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-25 05:09:47 +00:00
art: Make sure the agent doesn't start when performing auto-installs
This commit is contained in:
committed by
Itxaka
parent
602d086ce4
commit
6c08ac78a8
@@ -24,6 +24,12 @@ func Run(apiAddress string, dir []string, force bool) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
bf := machine.BootFrom()
|
||||||
|
if c.Install != nil && c.Install.Auto && (bf == machine.NetBoot || bf == machine.LiveCDBoot) {
|
||||||
|
// Don't go ahead if we are asked to install from a booting live medium
|
||||||
|
fmt.Println("Agent run aborted. Installation being performed from live medium")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
os.MkdirAll("/var/log/c3os", 0600)
|
os.MkdirAll("/var/log/c3os", 0600)
|
||||||
fileName := filepath.Join("/var/log/c3os", "agent-provider.log")
|
fileName := filepath.Join("/var/log/c3os", "agent-provider.log")
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/c3os-io/c3os/internal/machine/openrc"
|
"github.com/c3os-io/c3os/internal/machine/openrc"
|
||||||
"github.com/c3os-io/c3os/internal/machine/systemd"
|
"github.com/c3os-io/c3os/internal/machine/systemd"
|
||||||
@@ -20,6 +21,37 @@ type Service interface {
|
|||||||
Restart() error
|
Restart() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
PassiveBoot = "passive"
|
||||||
|
ActiveBoot = "active"
|
||||||
|
RecoveryBoot = "recovery"
|
||||||
|
LiveCDBoot = "liveCD"
|
||||||
|
NetBoot = "netboot"
|
||||||
|
UnknownBoot = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BootFrom returns the booting partition of the SUT
|
||||||
|
func BootFrom() string {
|
||||||
|
out, err := utils.SH("cat /proc/cmdline")
|
||||||
|
if err != nil {
|
||||||
|
return UnknownBoot
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case strings.Contains(out, "COS_ACTIVE"):
|
||||||
|
return ActiveBoot
|
||||||
|
case strings.Contains(out, "COS_PASSIVE"):
|
||||||
|
return PassiveBoot
|
||||||
|
case strings.Contains(out, "COS_RECOVERY"), strings.Contains(out, "COS_SYSTEM"):
|
||||||
|
return RecoveryBoot
|
||||||
|
case strings.Contains(out, "live:CDLABEL"):
|
||||||
|
return LiveCDBoot
|
||||||
|
case strings.Contains(out, "netboot"):
|
||||||
|
return NetBoot
|
||||||
|
default:
|
||||||
|
return UnknownBoot
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func EdgeVPN(instance, rootDir string) (Service, error) {
|
func EdgeVPN(instance, rootDir string) (Service, error) {
|
||||||
if utils.IsOpenRCBased() {
|
if utils.IsOpenRCBased() {
|
||||||
return openrc.NewService(
|
return openrc.NewService(
|
||||||
|
Reference in New Issue
Block a user