From e6ddb3bd9e8992bba6aef63ac9db5701649e564f Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 30 Jul 2021 08:08:00 +1000 Subject: Put the grids own bin directory in the path. --- src/sledjchisl/sledjchisl.c | 48 ++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index b81a054..16876f0 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -7032,9 +7032,11 @@ jit library is loaded or the JIT compiler will not be activated. isTmux = TRUE; } else - I("Not running inside the proper tmux server, starting it. %s == %s", eTMUX, toybuf); + I("Not running inside the proper tmux server. %s == %s", eTMUX, toybuf); } +// Note this block of code assumes we are running inside current/bin. Which RunIt.sh does for us. +// TODO - get rid of RunIt.sh as well. if (!isTmux) { // Let's see if the proper tmux server is even running. memset(toybuf, 0, sizeof(toybuf)); @@ -7047,17 +7049,21 @@ jit library is loaded or the JIT compiler will not be activated. memset(toybuf, 0, sizeof(toybuf)); if (strcmp(pw->pw_name, scUser) == 0) { + I("Not running inside the proper tmux server, starting it."); snprintf(toybuf, sizeof(toybuf), - "%s %s/%s new-session -d -s %s -n '%s' \\; split-window -vp 50 -t '%s:' bash -c '/usr/bin/valgrind --leak-check=full ./sledjchisl; cd %s; bash'", - Tcmd, scRun, Tsocket, Tconsole, Ttab, Tconsole, scRoot); + "export PATH='%s:$PATH'; %s %s/%s new-session -d -s %s -n '%s' bash -c 'export PATH=%s:$PATH; bash' \\; split-window -vp 50 -t '%s:' " + "bash -c 'export PATH=%s:$PATH; /usr/bin/valgrind --leak-check=full ./sledjchisl; cd %s; bash'", + scBin, Tcmd, scRun, Tsocket, Tconsole, Ttab, scBin, Tconsole, scBin, scBin, scRoot); } else { + I("Not running inside the proper tmux server, starting it with sudo."); // The sudo is only so that the session is owned by opensim, otherwise it's owned by whoever ran this script, which is a likely security hole. // After the session is created, we rely on the scRun directory to be group sticky, so that anyone in the opensim group can attach to the tmux socket. snprintf(toybuf, sizeof(toybuf), - "sudo -Hu %s %s %s/%s new-session -d -s %s -n '%s' \\; split-window -vp 50 -t '%s:' bash -c '/usr/bin/valgrind --leak-check=full ./sledjchisl; cd %s; bash'", - scUser, Tcmd, scRun, Tsocket, Tconsole, Ttab, Tconsole, scRoot); + "sudo -Hu %s %s %s/%s new-session -d -s %s -n '%s' bash -c 'export PATH=%s:$PATH; bash' \\; split-window -vp 50 -t '%s:' " + "bash -c 'export PATH=%s:$PATH; /usr/bin/valgrind --leak-check=full ./sledjchisl; cd %s; bash'", + scUser, Tcmd, scRun, Tsocket, Tconsole, Ttab, scBin, Tconsole, scBin, scRoot); } i = system(toybuf); if (!WIFEXITED(i)) @@ -7107,6 +7113,14 @@ jit library is loaded or the JIT compiler will not be activated. if ((! qfile_exist(tmp)) && (! qfile_mkdir(tmp, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP, true))) C("Unable to create path %s", tmp); free(tmp); + char *newPath = xmprintf("%s/current/bin/sledjchisl", scRoot); + tmp = xmprintf("%s/sledjchisl", scBin); + I("Symlinking %s to %s", newPath, tmp); + if (0 != symlink(newPath, tmp)) + perror_msg("Symlinking %s to %s", newPath, tmp); + free(tmp); + free(newPath); + //////////////////////////////////////////////////////////////////////////////////////////////////// // Other start up stuff. @@ -7785,24 +7799,25 @@ sims = -- Note these are .shini / tmux tab short names. char *newPath = xmprintf("%s/sim%d/%s.ini", scTemp, count, nm); // Coz OpenSim. char *cmd; + // The bash invocations are so that the PATH is properly propagated. if (0 == panes) - doTmuxCmd("split-window -hp 50 -d -t '%s:0.1'", Tconsole); + doTmuxCmd("split-window -hp 50 -d -t '%s:0.1' bash", Tconsole); else if (0 == pane) { - doTmuxCmd("new-window -dc '%s/current/bin' -n '%s' -t '%s:%d'", scRoot, type, Tconsole, window); + doTmuxCmd("new-window -dc '%s/current/bin' -n '%s' -t '%s:%d' bash", scRoot, type, Tconsole, window); if (2 <= panes) - doTmuxCmd("split-window -hp 50 -d -t '%s:%d.0'", Tconsole, window); + doTmuxCmd("split-window -hp 50 -d -t '%s:%d.0' bash", Tconsole, window); if (4 <= panes) { - doTmuxCmd("split-window -vp 50 -d -t '%s:%d.1'", Tconsole, window); - doTmuxCmd("split-window -vp 50 -d -t '%s:%d.0'", Tconsole, window); + doTmuxCmd("split-window -vp 50 -d -t '%s:%d.1' bash", Tconsole, window); + doTmuxCmd("split-window -vp 50 -d -t '%s:%d.0' bash", Tconsole, window); } if (8 <= panes) { - doTmuxCmd("split-window -hp 50 -d -t '%s:%d.3'", Tconsole, window); - doTmuxCmd("split-window -hp 50 -d -t '%s:%d.2'", Tconsole, window); - doTmuxCmd("split-window -hp 50 -d -t '%s:%d.1'", Tconsole, window); - doTmuxCmd("split-window -hp 50 -d -t '%s:%d.0'", Tconsole, window); + doTmuxCmd("split-window -hp 50 -d -t '%s:%d.3' bash", Tconsole, window); + doTmuxCmd("split-window -hp 50 -d -t '%s:%d.2' bash", Tconsole, window); + doTmuxCmd("split-window -hp 50 -d -t '%s:%d.1' bash", Tconsole, window); + doTmuxCmd("split-window -hp 50 -d -t '%s:%d.0' bash", Tconsole, window); } /* TODO - IDs={ @@ -7995,10 +8010,11 @@ nextSim: // Start up the web stuff. TODO - remove this once we handle the fcgi stuff ourselves. I("Starting the web stuff."); char *d = xmprintf("%s.{bottom}", Ttab); +// TODO - not sure why this needs to start in current/src. char *c = xmprintf("cd %s/current/src;" " spawn-fcgi -n -u %s -s %s/sledjchisl.socket -M 0660 -G www-data -- " - "/usr/bin/valgrind --leak-check=full build/toybox/generated/unstripped/toybox sledjchisl", - scRoot, scUser, scCache); + "/usr/bin/valgrind --leak-check=full sledjchisl; cd %s; bash'", + scRoot, scUser, scCache, scRoot); sendTmuxCmd(d, c); free(c); free(d); -- cgit v1.1