From 6f2e562e405cb63261f848b23a4aa2851a9601a4 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 25 Aug 2021 18:15:47 +1000 Subject: New sledjchisl pane layout. --- src/sledjchisl/sledjchisl.c | 78 ++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 43 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index e076654..ab81ee1 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -1342,7 +1342,7 @@ void forEachSim(char *verb, simFunction func, simFunction not) q1 = q0->v.t->get(q0->v.t, "type", NULL, false); if (NULL != q1) type = q1->v.s; if (0 == panes) { - pane = 2; + pane = 3; window = 0; type = Ttab; } @@ -1815,7 +1815,11 @@ void prepSims(simData *simd, char *sim, char *type, int count, int window, int p // Make sure all tmux windows and panes are startned. if (0 == panes) - doTmuxCmd("split-window -hp 50 -d -t '%s:0.1'", Tconsole); + { +// doTmuxCmd("split-window -hp 50 -d -t '%s:0.0'", Tconsole); +// doTmuxCmd("split-window -vp 50 -d -t '%s:0.1'", Tconsole); +// doTmuxCmd("split-window -vp 50 -d -t '%s:0.0'", Tconsole); + } else if (0 == pane) { doTmuxCmd("new-window -dc '%s/current/bin' -n '%s' -t '%s:%d'", scRoot, type, Tconsole, window); @@ -8264,36 +8268,42 @@ Build the OpenSim. { if (0 != WEXITSTATUS(i)) // No such session, create it. { + char *pre = xmprintf("sudo -Hu %s ", scUser); + 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), - // Set x,y to huge values, to work around an OpenSim bug. - // bash -c "bash -c '...; bash'" coz sudo, su, runuser, and start-stop-daemon insist. Pffft - // Double the export PATH='%s:$PATH coz tmux sucks at that. - "bash -c \"%s %s/%s set-option -g default-command 'export PATH=%s:$PATH; bash'\\; " - "new-session -d -x 256 -y 420 -s %s -n '%s' \\; " - "split-window -vp 50 -t '%s:' bash -c 'export PATH=%s:$PATH; /usr/bin/valgrind --leak-check=full ./sledjchisl; cd %s/current/bin; bash'\"", - Tcmd, scRun, Tsocket, scBin, Tconsole, Ttab, Tconsole, scBin, scBin, scRoot); + pre = xmprintf(""); } 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), - // Set x,y to huge values, to work around an OpenSim bug. - "sudo -Hu %s %s %s/%s set-option -g default-command 'export PATH=%s:$PATH; bash'\\; " - "new-session -d -x 256 -y 420 -s %s -n '%s' \\; " - "split-window -vp 50 -t '%s:' bash -c 'export PATH=%s:$PATH; /usr/bin/valgrind --leak-check=full ./sledjchisl; cd %s/current/bin; bash'", - scUser, Tcmd, scRun, Tsocket, scBin, Tconsole, Ttab, Tconsole, scBin, scRoot); + pre = xmprintf("sudo -Hu %s ", scUser); } + snprintf(toybuf, sizeof(toybuf), + "%s %s %s/%s set-option -g default-command 'export PATH=%s:$PATH; bash'\\; " + // Set x,y to huge values, to work around an OpenSim bug. + "new-session -d -x 256 -y 420 -s %s -n '%s' bash -c 'export PATH=%s:$PATH; /usr/bin/valgrind --leak-check=full ./sledjchisl; cd %s/current/bin; bash' \\; " + "split-window -vp 50 -d -t '%s:0.0' \\; " + "split-window -hp 50 -d -t '%s:0.1' \\; " + "split-window -hp 50 -d -t '%s:0.0' " + // TODO - remove this once we handle the fcgi stuff ourselves. + // Make the FCGI socket world read / write, coz we can't set it to group www-data, since -G only works for root, and we ain't root. + // TODO - BIG SECURITY HOLE??? + "bash -c 'export PATH=%s:$PATH; " + "spawn-fcgi -n -u %s -s %s/sledjchisl.socket -M 0666 -G www-data -- /usr/bin/valgrind --leak-check=full sledjchisl; " + "cd %s/current/bin; bash'" + , + pre, Tcmd, scRun, Tsocket, scBin, Tconsole, Ttab, scBin, scRoot, Tconsole, Tconsole, Tconsole, scBin, scUser, scRun, scBin, scRoot); + free(pre); if (shellMeFail(toybuf)) E("tmux new-session command failed! %s", toybuf); else { - if (shellMeFail("%s %s/%s select-pane -t 1 -T 'SledjChisl'", Tcmd, scRun, Tsocket)) + if (shellMeFail("%s %s/%s select-pane -t 1 -T 'SledjChisl' \\; select-pane -t @0.%%3 -T 'FCGI web server'", Tcmd, scRun, Tsocket)) E("tmux select-pane command failed!"); } // toybox argument parsing is half working. @@ -8574,22 +8584,20 @@ Create the /opt/opensim-SC directory structure. // Start ROBUST or join the tmux session, or just figure out where the sims are running in tmux. if ((START == currentMode) && !checkSimIsRunning("ROBUST")) { - char *d = xmprintf("%s.{right}", Ttab); char *c = xmprintf("cd %s/current/bin", scRoot); I("ROBUST is starting up."); - sendTmuxCmd(d, c); + sendTmuxCmd("@0.%1", c); free(c); c = xmprintf("mono Robust.exe -inidirectory=%s/config/ROBUST", scRoot); - sendTmuxCmd(d, c); + sendTmuxCmd("@0.%1", c); free(c); - doTmuxCmd("select-pane -t 0 -T 'ROBUST'", Tcmd, scRun, Tsocket); + doTmuxCmd("select-pane -t @0.%%1 -T 'ROBUST'", Tcmd, scRun, Tsocket); // Create all the tmux windows, panes, and temporary .ini files coz OpenSim sucketh. forEachSim("Prepping", prepSims, NULL); - waitTmuxText(d, "INITIALIZATION COMPLETE FOR ROBUST"); + waitTmuxText("@0.%1", "INITIALIZATION COMPLETE FOR ROBUST"); I("ROBUST is done starting up."); - free(d); } else if ((0 == toys.optc) && (checkSimIsRunning("ROBUST"))) { @@ -8625,14 +8633,14 @@ Create the /opt/opensim-SC directory structure. { if (checkSimIsRunning("ROBUST")) { - sendTmuxCmd("@0.%0", "quit"); + sendTmuxCmd("@0.%1", "quit"); while (checkSimIsRunning("ROBUST")) usleep(100000); usleep(100000); - sendTmuxCmd("@0.%0", "exit"); + sendTmuxCmd("@0.%1", "exit"); usleep(100000); - sendTmuxCmd("@0.%0", "exit"); - I("ROBUST has stopped in tmux ID @0.%%0."); + sendTmuxCmd("@0.%1", "exit"); + I("ROBUST has stopped in tmux ID @0.%%1."); } if (FLAG(a)) @@ -8676,22 +8684,6 @@ Create the /opt/opensim-SC directory structure. } } } - else if (START == currentMode) - { - if (checkSimIsRunning("ROBUST") && (NULL == ourSims->target)) - { - // TODO - remove this once we handle the fcgi stuff ourselves. - I("Starting the web stuff."); - // Make the FCGI socket world read / write, coz we can't set it to group www-data, since -G only works for root, and we ain't root. - // TODO - BIG SECURITY HOLE??? - char *c = xmprintf("spawn-fcgi -n -u %s -s %s/sledjchisl.socket -M 0666 -G www-data -- /usr/bin/valgrind --leak-check=full sledjchisl", - scUser, scRun, scRoot); - sendTmuxCmd(Ttab, c); - free(c); - } - else - I("NOT Starting the web stuff."); - } } else { -- cgit v1.1