move to zerolog
This commit is contained in:
16
bootstrap.go
16
bootstrap.go
@ -4,12 +4,13 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
config "novit.tech/direktil/pkg/bootstrapconfig"
|
||||
)
|
||||
|
||||
@ -27,14 +28,14 @@ func bootstrap(cfg *config.Config) {
|
||||
sysCfgPath := filepath.Join(baseDir, "config.yaml")
|
||||
|
||||
if _, err := os.Stat(sysCfgPath); os.IsNotExist(err) {
|
||||
log.Printf("bootstrap %q does not exist", bootVersion)
|
||||
log.Warn().Msgf("bootstrap %q does not exist", bootVersion)
|
||||
|
||||
seed := cfg.Bootstrap.Seed
|
||||
if seed == "" {
|
||||
fatalf("boostrap seed not defined, admin required")
|
||||
}
|
||||
|
||||
log.Printf("seeding bootstrap from %s", seed)
|
||||
log.Info().Str("from", seed).Msgf("seeding bootstrap")
|
||||
|
||||
err = os.MkdirAll(baseDir, 0700)
|
||||
if err != nil {
|
||||
@ -72,7 +73,7 @@ func bootstrap(cfg *config.Config) {
|
||||
fatalf("seeding failed: %v", err)
|
||||
}
|
||||
|
||||
log.Print("unpacking bootstrap file")
|
||||
log.Info().Msg("unpacking bootstrap file")
|
||||
run("tar", "xvf", bootstrapFile, "-C", baseDir)
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ func bootstrap(cfg *config.Config) {
|
||||
|
||||
// mounts are v2+
|
||||
for _, mount := range sysCfg.Mounts {
|
||||
log.Print("mount ", mount.Dev, " to system's ", mount.Path)
|
||||
log.Info().Str("source", mount.Dev).Str("target", mount.Path).Msg("mount")
|
||||
|
||||
path := filepath.Join("/system", mount.Path)
|
||||
|
||||
@ -108,15 +109,16 @@ func bootstrap(cfg *config.Config) {
|
||||
|
||||
// setup root user
|
||||
if ph := sysCfg.RootUser.PasswordHash; ph != "" {
|
||||
log.Print("setting root's password")
|
||||
log.Info().Msg("setting root's password")
|
||||
setUserPass("root", ph)
|
||||
}
|
||||
if ak := sysCfg.RootUser.AuthorizedKeys; len(ak) != 0 {
|
||||
log.Print("setting root's authorized keys")
|
||||
log.Info().Msg("setting root's authorized keys")
|
||||
setAuthorizedKeys(ak)
|
||||
}
|
||||
|
||||
// update-ca-certificates
|
||||
log.Info().Msg("updating CA certifices")
|
||||
run("chroot", "/system", "update-ca-certificates")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user