1
0
mirror of https://github.com/kairos-io/kairos-agent.git synced 2025-05-09 00:36:42 +00:00

art: Rebranding ()

See: https://github.com/c3os-io/c3os/issues/88
This commit is contained in:
Ettore Di Giacinto 2022-09-17 18:43:51 +02:00 committed by Itxaka
parent 0763c820f2
commit e25526cfc9
16 changed files with 68 additions and 66 deletions

View File

@ -6,12 +6,12 @@ import (
"os" "os"
"path/filepath" "path/filepath"
events "github.com/c3os-io/c3os/sdk/bus" events "github.com/kairos-io/kairos/sdk/bus"
"github.com/c3os-io/c3os/internal/bus" "github.com/kairos-io/kairos/internal/bus"
config "github.com/c3os-io/c3os/pkg/config" config "github.com/kairos-io/kairos/pkg/config"
machine "github.com/c3os-io/c3os/pkg/machine" machine "github.com/kairos-io/kairos/pkg/machine"
bundles "github.com/c3os-io/c3os/sdk/bundles" bundles "github.com/kairos-io/kairos/sdk/bundles"
"github.com/nxadm/tail" "github.com/nxadm/tail"
) )
@ -22,7 +22,7 @@ func Run(opts ...Option) error {
return err return err
} }
os.MkdirAll("/usr/local/.c3os", 0600) //nolint:errcheck os.MkdirAll("/usr/local/.kairos", 0600) //nolint:errcheck
// Reads config // Reads config
c, err := config.Scan(config.Directories(o.Dir...)) c, err := config.Scan(config.Directories(o.Dir...))
@ -36,9 +36,9 @@ func Run(opts ...Option) error {
return nil return nil
} }
os.MkdirAll("/var/log/c3os", 0600) //nolint:errcheck os.MkdirAll("/var/log/kairos", 0600) //nolint:errcheck
fileName := filepath.Join("/var/log/c3os", "agent-provider.log") fileName := filepath.Join("/var/log/kairos", "agent-provider.log")
// Create if not exist // Create if not exist
if _, err := os.Stat(fileName); err != nil { if _, err := os.Stat(fileName); err != nil {

View File

@ -3,7 +3,8 @@ package agent
import ( import (
"io/ioutil" "io/ioutil"
"github.com/c3os-io/c3os/internal/c3os" "github.com/kairos-io/kairos/internal/kairos"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )
@ -20,7 +21,7 @@ type Config struct {
func LoadConfig(path ...string) (*Config, error) { func LoadConfig(path ...string) (*Config, error) {
if len(path) == 0 { if len(path) == 0 {
path = append(path, "/etc/c3os/agent.yaml", "/etc/elemental/config.yaml") path = append(path, "/etc/kairos/agent.yaml", "/etc/elemental/config.yaml")
} }
cfg := &Config{} cfg := &Config{}
@ -33,28 +34,28 @@ func LoadConfig(path ...string) (*Config, error) {
} }
if cfg.Branding.InteractiveInstall == "" { if cfg.Branding.InteractiveInstall == "" {
f, err := ioutil.ReadFile(c3os.BrandingFile("interactive_install_text")) f, err := ioutil.ReadFile(kairos.BrandingFile("interactive_install_text"))
if err == nil { if err == nil {
cfg.Branding.InteractiveInstall = string(f) cfg.Branding.InteractiveInstall = string(f)
} }
} }
if cfg.Branding.Install == "" { if cfg.Branding.Install == "" {
f, err := ioutil.ReadFile(c3os.BrandingFile("install_text")) f, err := ioutil.ReadFile(kairos.BrandingFile("install_text"))
if err == nil { if err == nil {
cfg.Branding.Install = string(f) cfg.Branding.Install = string(f)
} }
} }
if cfg.Branding.Recovery == "" { if cfg.Branding.Recovery == "" {
f, err := ioutil.ReadFile(c3os.BrandingFile("recovery_text")) f, err := ioutil.ReadFile(kairos.BrandingFile("recovery_text"))
if err == nil { if err == nil {
cfg.Branding.Recovery = string(f) cfg.Branding.Recovery = string(f)
} }
} }
if cfg.Branding.Reset == "" { if cfg.Branding.Reset == "" {
f, err := ioutil.ReadFile(c3os.BrandingFile("reset_text")) f, err := ioutil.ReadFile(kairos.BrandingFile("reset_text"))
if err == nil { if err == nil {
cfg.Branding.Reset = string(f) cfg.Branding.Reset = string(f)
} }

View File

@ -4,8 +4,8 @@ import (
"fmt" "fmt"
"strings" "strings"
config "github.com/c3os-io/c3os/pkg/config" config "github.com/kairos-io/kairos/pkg/config"
"github.com/c3os-io/c3os/pkg/utils" "github.com/kairos-io/kairos/pkg/utils"
) )
type GrubOptions struct{} type GrubOptions struct{}

View File

@ -1,7 +1,7 @@
package hook package hook
import ( import (
config "github.com/c3os-io/c3os/pkg/config" config "github.com/kairos-io/kairos/pkg/config"
) )
type Interface interface { type Interface interface {

View File

@ -1,8 +1,8 @@
package hook package hook
import ( import (
config "github.com/c3os-io/c3os/pkg/config" config "github.com/kairos-io/kairos/pkg/config"
"github.com/c3os-io/c3os/pkg/utils" "github.com/kairos-io/kairos/pkg/utils"
) )
type Lifecycle struct{} type Lifecycle struct{}

View File

@ -1,16 +1,16 @@
package hook package hook
import ( import (
config "github.com/c3os-io/c3os/pkg/config" config "github.com/kairos-io/kairos/pkg/config"
"github.com/c3os-io/c3os/pkg/utils" "github.com/kairos-io/kairos/pkg/utils"
events "github.com/c3os-io/c3os/sdk/bus" events "github.com/kairos-io/kairos/sdk/bus"
) )
type RunStage struct{} type RunStage struct{}
func (r RunStage) Run(c config.Config) error { func (r RunStage) Run(c config.Config) error {
utils.SH("elemental run-stage c3os-install.after") //nolint:errcheck utils.SH("elemental run-stage kairos-install.after") //nolint:errcheck
events.RunHookScript("/usr/bin/c3os-agent.install.after.hook") //nolint:errcheck events.RunHookScript("/usr/bin/kairos-agent.install.after.hook") //nolint:errcheck
return nil return nil
} }

View File

@ -10,17 +10,17 @@ import (
"syscall" "syscall"
"time" "time"
events "github.com/c3os-io/c3os/sdk/bus" events "github.com/kairos-io/kairos/sdk/bus"
config "github.com/c3os-io/c3os/pkg/config" config "github.com/kairos-io/kairos/pkg/config"
hook "github.com/c3os-io/c3os/internal/agent/hooks" hook "github.com/kairos-io/kairos/internal/agent/hooks"
"github.com/c3os-io/c3os/internal/bus" "github.com/kairos-io/kairos/internal/bus"
"github.com/c3os-io/c3os/internal/cmd" "github.com/kairos-io/kairos/internal/cmd"
"github.com/c3os-io/c3os/pkg/utils" "github.com/kairos-io/kairos/pkg/utils"
machine "github.com/c3os-io/c3os/pkg/machine" machine "github.com/kairos-io/kairos/pkg/machine"
qr "github.com/mudler/go-nodepair/qrcode" qr "github.com/mudler/go-nodepair/qrcode"
"github.com/mudler/go-pluggable" "github.com/mudler/go-pluggable"
"github.com/pterm/pterm" "github.com/pterm/pterm"
@ -185,8 +185,8 @@ func Install(dir ...string) error {
} }
func RunInstall(options map[string]string) error { func RunInstall(options map[string]string) error {
utils.SH("elemental run-stage c3os-install.pre") //nolint:errcheck utils.SH("elemental run-stage kairos-install.pre") //nolint:errcheck
events.RunHookScript("/usr/bin/c3os-agent.install.pre.hook") //nolint:errcheck events.RunHookScript("/usr/bin/kairos-agent.install.pre.hook") //nolint:errcheck
f, _ := ioutil.TempFile("", "xxxx") f, _ := ioutil.TempFile("", "xxxx")
defer os.RemoveAll(f.Name()) defer os.RemoveAll(f.Name())

View File

@ -5,16 +5,16 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/c3os-io/c3os/internal/bus" "github.com/kairos-io/kairos/internal/bus"
"github.com/c3os-io/c3os/internal/cmd" "github.com/kairos-io/kairos/internal/cmd"
config "github.com/c3os-io/c3os/pkg/config" config "github.com/kairos-io/kairos/pkg/config"
events "github.com/c3os-io/c3os/sdk/bus" events "github.com/kairos-io/kairos/sdk/bus"
"github.com/c3os-io/c3os/sdk/unstructured" "github.com/kairos-io/kairos/sdk/unstructured"
"github.com/c3os-io/c3os/pkg/utils"
"github.com/erikgeiser/promptkit/textinput" "github.com/erikgeiser/promptkit/textinput"
"github.com/jaypipes/ghw" "github.com/jaypipes/ghw"
"github.com/kairos-io/kairos/pkg/utils"
"github.com/mudler/go-pluggable" "github.com/mudler/go-pluggable"
"github.com/mudler/yip/pkg/schema" "github.com/mudler/yip/pkg/schema"
"github.com/pterm/pterm" "github.com/pterm/pterm"
@ -165,7 +165,7 @@ func InteractiveInstall(spawnShell bool) error {
return err return err
} }
userName, err := prompt("User to setup", "c3os", canBeEmpty, true, false) userName, err := prompt("User to setup", "kairos", canBeEmpty, true, false)
if err != nil { if err != nil {
return err return err
} }

View File

@ -3,9 +3,9 @@ package agent
import ( import (
"fmt" "fmt"
"github.com/c3os-io/c3os/internal/bus" "github.com/kairos-io/kairos/internal/bus"
"github.com/c3os-io/c3os/pkg/config" "github.com/kairos-io/kairos/pkg/config"
events "github.com/c3os-io/c3os/sdk/bus" events "github.com/kairos-io/kairos/sdk/bus"
"github.com/mudler/go-pluggable" "github.com/mudler/go-pluggable"
) )

View File

@ -4,12 +4,12 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/c3os-io/c3os/internal/bus" "github.com/kairos-io/kairos/internal/bus"
"github.com/c3os-io/c3os/internal/cmd" "github.com/kairos-io/kairos/internal/cmd"
"github.com/c3os-io/c3os/pkg/utils" "github.com/kairos-io/kairos/pkg/utils"
events "github.com/c3os-io/c3os/sdk/bus" events "github.com/kairos-io/kairos/sdk/bus"
machine "github.com/c3os-io/c3os/pkg/machine" machine "github.com/kairos-io/kairos/pkg/machine"
qr "github.com/mudler/go-nodepair/qrcode" qr "github.com/mudler/go-nodepair/qrcode"
"github.com/mudler/go-pluggable" "github.com/mudler/go-pluggable"
"github.com/pterm/pterm" "github.com/pterm/pterm"

View File

@ -7,9 +7,9 @@ import (
"sync" "sync"
"time" "time"
"github.com/c3os-io/c3os/internal/cmd" "github.com/kairos-io/kairos/internal/cmd"
"github.com/c3os-io/c3os/pkg/machine" "github.com/kairos-io/kairos/pkg/machine"
"github.com/c3os-io/c3os/pkg/utils" "github.com/kairos-io/kairos/pkg/utils"
"github.com/pterm/pterm" "github.com/pterm/pterm"
) )

View File

@ -8,11 +8,11 @@ import (
"os/exec" "os/exec"
"strings" "strings"
events "github.com/c3os-io/c3os/sdk/bus" events "github.com/kairos-io/kairos/sdk/bus"
"github.com/c3os-io/c3os/internal/bus" "github.com/kairos-io/kairos/internal/bus"
"github.com/c3os-io/c3os/pkg/github" "github.com/kairos-io/kairos/pkg/github"
"github.com/c3os-io/c3os/pkg/utils" "github.com/kairos-io/kairos/pkg/utils"
"github.com/mudler/go-pluggable" "github.com/mudler/go-pluggable"
) )

View File

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/c3os-io/c3os/sdk/bus" "github.com/kairos-io/kairos/sdk/bus"
"github.com/mudler/go-pluggable" "github.com/mudler/go-pluggable"
) )

View File

@ -1,7 +0,0 @@
package c3os
import "path"
func BrandingFile(s string) string {
return path.Join("/etc", "c3os", "branding", s)
}

View File

@ -5,8 +5,9 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"github.com/c3os-io/c3os/internal/c3os" "github.com/kairos-io/kairos/internal/kairos"
"github.com/c3os-io/c3os/pkg/utils"
"github.com/kairos-io/kairos/pkg/utils"
"github.com/pterm/pterm" "github.com/pterm/pterm"
) )
@ -16,7 +17,7 @@ func PrintText(f string, banner string) {
} }
func PrintBranding(b []byte) { func PrintBranding(b []byte) {
brandingFile := c3os.BrandingFile("banner") brandingFile := kairos.BrandingFile("banner")
if _, err := os.Stat(brandingFile); err == nil { if _, err := os.Stat(brandingFile); err == nil {
f, err := ioutil.ReadFile(brandingFile) f, err := ioutil.ReadFile(brandingFile)
if err == nil { if err == nil {

View File

@ -0,0 +1,7 @@
package kairos
import "path"
func BrandingFile(s string) string {
return path.Join("/etc", "kairos", "branding", s)
}