Embed default daemon.yml directly in entrypoint

This commit is contained in:
Brian Picciano 2024-09-24 11:22:00 +02:00
parent 64fdba0a48
commit 31af39ce4c
7 changed files with 13 additions and 31 deletions

View File

@ -51,13 +51,13 @@ in
inherit pkgbuild; inherit pkgbuild;
src = appImage; src = appImage;
appDir = ../../../AppDir; defaultDaemonYml = ../../../go/daemon/daecommon/daemon.yml;
systemdService = ../isle.service; systemdService = ../isle.service;
dontUnpack = true; dontUnpack = true;
buildPhase = '' buildPhase = ''
mkdir -p root/etc/isle/ mkdir -p root/etc/isle/
cp "$appDir"/etc/daemon.yml root/etc/isle/daemon.yml cp "$defaultDaemonYml" root/etc/isle/daemon.yml
mkdir -p root/usr/lib/sysusers.d/ mkdir -p root/usr/lib/sysusers.d/
cat >root/usr/lib/sysusers.d/isle.conf <<EOF cat >root/usr/lib/sysusers.d/isle.conf <<EOF

View File

@ -23,12 +23,6 @@ func StateDirPath(dataDirPath string) string {
return filepath.Join(dataDirPath, "bootstrap.json") return filepath.Join(dataDirPath, "bootstrap.json")
} }
// AppDirPath returns the path within the AppDir where an embedded bootstrap
// file might be found.
func AppDirPath(appDirPath string) string {
return filepath.Join(appDirPath, "share/bootstrap.json")
}
// CreationParams are general parameters used when creating a new network. These // CreationParams are general parameters used when creating a new network. These
// are available to all hosts within the network via their bootstrap files. // are available to all hosts within the network via their bootstrap files.
type CreationParams struct { type CreationParams struct {

View File

@ -41,7 +41,7 @@ var subCmdDaemon = subCmd{
} }
if *dumpConfig { if *dumpConfig {
return daecommon.CopyDefaultConfig(os.Stdout, envAppDirPath) return daecommon.CopyDefaultConfig(os.Stdout)
} }
logLevel := mlog.LevelFromString(*logLevelStr) logLevel := mlog.LevelFromString(*logLevelStr)

View File

@ -90,7 +90,7 @@ var subCmdGarageMC = subCmd{
*keyID, *keySecret, s3APIAddr, *keyID, *keySecret, s3APIAddr,
) )
binPath = filepath.Join(envAppDirPath, "bin/mc") binPath = binPath("mc")
cliEnv = append( cliEnv = append(
os.Environ(), os.Environ(),
mcHostVar, mcHostVar,

View File

@ -1,15 +1,17 @@
package daecommon package daecommon
import ( import (
"bytes"
"fmt" "fmt"
"io" "io"
"isle/bootstrap" "isle/bootstrap"
"isle/toolkit" "isle/toolkit"
"net" "net"
"os" "os"
"path/filepath"
"strconv" "strconv"
_ "embed"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
@ -19,9 +21,8 @@ const (
DeprecatedNetworkID = "_" // DEPRECATED DeprecatedNetworkID = "_" // DEPRECATED
) )
func defaultConfigPath(appDirPath string) string { //go:embed daemon.yml
return filepath.Join(appDirPath, "etc", "daemon.yml") var defaultConfigB []byte
}
type ConfigTun struct { type ConfigTun struct {
Device string `yaml:"device"` Device string `yaml:"device"`
@ -180,22 +181,9 @@ func (c Config) Validate() error {
// CopyDefaultConfig copies the daemon config file embedded in the AppDir into // CopyDefaultConfig copies the daemon config file embedded in the AppDir into
// the given io.Writer. // the given io.Writer.
func CopyDefaultConfig(into io.Writer, appDirPath string) error { func CopyDefaultConfig(into io.Writer) error {
_, err := io.Copy(into, bytes.NewReader(defaultConfigB))
defaultConfigPath := defaultConfigPath(appDirPath) return err
f, err := os.Open(defaultConfigPath)
if err != nil {
return fmt.Errorf("opening daemon config at %q: %w", defaultConfigPath, err)
}
defer f.Close()
if _, err := io.Copy(into, f); err != nil {
return fmt.Errorf("copying daemon config from %q: %w", defaultConfigPath, err)
}
return nil
} }
// LoadConfig loads the daemon config from userConfigPath. // LoadConfig loads the daemon config from userConfigPath.

View File

@ -8,7 +8,7 @@
pname = "nebula"; pname = "nebula";
# If this changes, remember to change: # If this changes, remember to change:
# - the AppDir/etc/daemon.yml vpn.firewall docs # - the go/daemon/daecommon/daemon.yml vpn.firewall docs
# - the version imported in go-workspace # - the version imported in go-workspace
version = "1.6.1"; version = "1.6.1";