Use entrypoint directly as AppRun

This removes the intermediate bash script which was running, which
_potentially_ fixes #2.

Since that bash script is no longer setting PATH, the daemon must
manually create the binary path for each sub-process anyway.
This commit is contained in:
Brian Picciano 2023-04-23 16:30:47 +02:00
parent 57f63750f3
commit a1b3ff71b3
7 changed files with 32 additions and 19 deletions

View File

@ -1,4 +0,0 @@
#!/bin/sh
export PATH=$APPDIR/bin
exec entrypoint "$@"

View File

@ -91,19 +91,32 @@ in rec {
'';
};
appDir = pkgs.buildEnv {
appDir = pkgs.stdenv.mkDerivation {
name = "cryptic-net-AppDir";
paths = [
./AppDir
version
dnsmasq
nebula
garage
pkgs.minio-client
entrypoint
src = pkgs.buildEnv {
name = "cryptic-net-AppDir-base";
paths = [
] ++ (if bootstrap != null then [ rootedBootstrap ] else []);
./AppDir
version
dnsmasq
nebula
garage
pkgs.minio-client
entrypoint
] ++ (if bootstrap != null then [ rootedBootstrap ] else []);
};
builder = builtins.toFile "build.sh" ''
source $stdenv/setup
cp -rL "$src" "$out"
chmod +w "$out" -R
cd "$out"
cp ./bin/entrypoint ./AppRun
'';
};
appimagetool = pkgs.callPackage ./nix/appimagetool.nix {};

View File

@ -45,7 +45,7 @@ func dnsmasqPmuxProcConfig(
return pmuxlib.ProcessConfig{
Name: "dnsmasq",
Cmd: "dnsmasq",
Cmd: binPath("dnsmasq"),
Args: []string{"-d", "-C", confPath},
}, nil
}

View File

@ -50,7 +50,7 @@ var subCmdGarageMC = subCmd{
args = args[i:]
}
args = append([]string{"mc"}, args...)
args = append([]string{binPath("mc")}, args...)
var (
mcHostVar = fmt.Sprintf(
@ -92,7 +92,7 @@ var subCmdGarageCLI = subCmd{
}
var (
binPath = filepath.Join(envAppDirPath, "bin/garage")
binPath = binPath("garage")
args = append([]string{"garage"}, subCmdCtx.args...)
cliEnv = append(
os.Environ(),

View File

@ -168,7 +168,7 @@ func garagePmuxProcConfigs(
pmuxProcConfigs = append(pmuxProcConfigs, pmuxlib.ProcessConfig{
Name: fmt.Sprintf("garage-%d", alloc.RPCPort),
Cmd: "garage",
Cmd: binPath("garage"),
Args: []string{"-c", childConfigPath, "server"},
StartAfterFunc: func(ctx context.Context) error {
return waitForNebula(ctx, hostBootstrap)

View File

@ -31,6 +31,10 @@ var (
envDataDirPath = filepath.Join(xdg.DataHome, "cryptic-net")
)
func binPath(name string) string {
return filepath.Join(envAppDirPath, "bin", name)
}
func main() {
logger := mlog.NewLogger(&mlog.LoggerOpts{

View File

@ -111,7 +111,7 @@ func nebulaPmuxProcConfig(
return pmuxlib.ProcessConfig{
Name: "nebula",
Cmd: "nebula",
Cmd: binPath("nebula"),
Args: []string{"-config", nebulaYmlPath},
}, nil
}