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,8 +91,11 @@ in rec {
''; '';
}; };
appDir = pkgs.buildEnv { appDir = pkgs.stdenv.mkDerivation {
name = "cryptic-net-AppDir"; name = "cryptic-net-AppDir";
src = pkgs.buildEnv {
name = "cryptic-net-AppDir-base";
paths = [ paths = [
./AppDir ./AppDir
@ -106,6 +109,16 @@ in rec {
] ++ (if bootstrap != null then [ rootedBootstrap ] else []); ] ++ (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 {}; appimagetool = pkgs.callPackage ./nix/appimagetool.nix {};
appImage = pkgs.stdenv.mkDerivation { appImage = pkgs.stdenv.mkDerivation {

View File

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

View File

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

View File

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

View File

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

View File

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