aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/sledjchisl
diff options
context:
space:
mode:
authoronefang2021-08-25 18:15:47 +1000
committeronefang2021-08-25 18:15:47 +1000
commit6f2e562e405cb63261f848b23a4aa2851a9601a4 (patch)
tree9e947d34ad66b7b8c6fd03fe694db5ff628d4cde /src/sledjchisl
parentMore work on gitAR code. (diff)
downloadopensim-SC-6f2e562e405cb63261f848b23a4aa2851a9601a4.zip
opensim-SC-6f2e562e405cb63261f848b23a4aa2851a9601a4.tar.gz
opensim-SC-6f2e562e405cb63261f848b23a4aa2851a9601a4.tar.bz2
opensim-SC-6f2e562e405cb63261f848b23a4aa2851a9601a4.tar.xz
New sledjchisl pane layout.
Diffstat (limited to 'src/sledjchisl')
-rw-r--r--src/sledjchisl/sledjchisl.c78
1 files 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)
1342 q1 = q0->v.t->get(q0->v.t, "type", NULL, false); if (NULL != q1) type = q1->v.s; 1342 q1 = q0->v.t->get(q0->v.t, "type", NULL, false); if (NULL != q1) type = q1->v.s;
1343 if (0 == panes) 1343 if (0 == panes)
1344 { 1344 {
1345 pane = 2; 1345 pane = 3;
1346 window = 0; 1346 window = 0;
1347 type = Ttab; 1347 type = Ttab;
1348 } 1348 }
@@ -1815,7 +1815,11 @@ void prepSims(simData *simd, char *sim, char *type, int count, int window, int p
1815 1815
1816 // Make sure all tmux windows and panes are startned. 1816 // Make sure all tmux windows and panes are startned.
1817 if (0 == panes) 1817 if (0 == panes)
1818 doTmuxCmd("split-window -hp 50 -d -t '%s:0.1'", Tconsole); 1818 {
1819// doTmuxCmd("split-window -hp 50 -d -t '%s:0.0'", Tconsole);
1820// doTmuxCmd("split-window -vp 50 -d -t '%s:0.1'", Tconsole);
1821// doTmuxCmd("split-window -vp 50 -d -t '%s:0.0'", Tconsole);
1822 }
1819 else if (0 == pane) 1823 else if (0 == pane)
1820 { 1824 {
1821 doTmuxCmd("new-window -dc '%s/current/bin' -n '%s' -t '%s:%d'", scRoot, type, Tconsole, window); 1825 doTmuxCmd("new-window -dc '%s/current/bin' -n '%s' -t '%s:%d'", scRoot, type, Tconsole, window);
@@ -8264,36 +8268,42 @@ Build the OpenSim.
8264 { 8268 {
8265 if (0 != WEXITSTATUS(i)) // No such session, create it. 8269 if (0 != WEXITSTATUS(i)) // No such session, create it.
8266 { 8270 {
8271 char *pre = xmprintf("sudo -Hu %s ", scUser);
8272
8267 memset(toybuf, 0, sizeof(toybuf)); 8273 memset(toybuf, 0, sizeof(toybuf));
8268 if (strcmp(pw->pw_name, scUser) == 0) 8274 if (strcmp(pw->pw_name, scUser) == 0)
8269 { 8275 {
8270 I("Not running inside the proper tmux server, starting it."); 8276 I("Not running inside the proper tmux server, starting it.");
8271 snprintf(toybuf, sizeof(toybuf), 8277 pre = xmprintf("");
8272 // Set x,y to huge values, to work around an OpenSim bug.
8273 // bash -c "bash -c '...; bash'" coz sudo, su, runuser, and start-stop-daemon insist. Pffft
8274 // Double the export PATH='%s:$PATH coz tmux sucks at that.
8275 "bash -c \"%s %s/%s set-option -g default-command 'export PATH=%s:$PATH; bash'\\; "
8276 "new-session -d -x 256 -y 420 -s %s -n '%s' \\; "
8277 "split-window -vp 50 -t '%s:' bash -c 'export PATH=%s:$PATH; /usr/bin/valgrind --leak-check=full ./sledjchisl; cd %s/current/bin; bash'\"",
8278 Tcmd, scRun, Tsocket, scBin, Tconsole, Ttab, Tconsole, scBin, scBin, scRoot);
8279 } 8278 }
8280 else 8279 else
8281 { 8280 {
8282 I("Not running inside the proper tmux server, starting it with sudo."); 8281 I("Not running inside the proper tmux server, starting it with sudo.");
8283 // 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. 8282 // 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.
8284 // 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. 8283 // 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.
8285 snprintf(toybuf, sizeof(toybuf), 8284 pre = xmprintf("sudo -Hu %s ", scUser);
8286 // Set x,y to huge values, to work around an OpenSim bug.
8287 "sudo -Hu %s %s %s/%s set-option -g default-command 'export PATH=%s:$PATH; bash'\\; "
8288 "new-session -d -x 256 -y 420 -s %s -n '%s' \\; "
8289 "split-window -vp 50 -t '%s:' bash -c 'export PATH=%s:$PATH; /usr/bin/valgrind --leak-check=full ./sledjchisl; cd %s/current/bin; bash'",
8290 scUser, Tcmd, scRun, Tsocket, scBin, Tconsole, Ttab, Tconsole, scBin, scRoot);
8291 } 8285 }
8286 snprintf(toybuf, sizeof(toybuf),
8287 "%s %s %s/%s set-option -g default-command 'export PATH=%s:$PATH; bash'\\; "
8288 // Set x,y to huge values, to work around an OpenSim bug.
8289 "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' \\; "
8290 "split-window -vp 50 -d -t '%s:0.0' \\; "
8291 "split-window -hp 50 -d -t '%s:0.1' \\; "
8292 "split-window -hp 50 -d -t '%s:0.0' "
8293 // TODO - remove this once we handle the fcgi stuff ourselves.
8294 // 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.
8295 // TODO - BIG SECURITY HOLE???
8296 "bash -c 'export PATH=%s:$PATH; "
8297 "spawn-fcgi -n -u %s -s %s/sledjchisl.socket -M 0666 -G www-data -- /usr/bin/valgrind --leak-check=full sledjchisl; "
8298 "cd %s/current/bin; bash'"
8299 ,
8300 pre, Tcmd, scRun, Tsocket, scBin, Tconsole, Ttab, scBin, scRoot, Tconsole, Tconsole, Tconsole, scBin, scUser, scRun, scBin, scRoot);
8301 free(pre);
8292 if (shellMeFail(toybuf)) 8302 if (shellMeFail(toybuf))
8293 E("tmux new-session command failed! %s", toybuf); 8303 E("tmux new-session command failed! %s", toybuf);
8294 else 8304 else
8295 { 8305 {
8296 if (shellMeFail("%s %s/%s select-pane -t 1 -T 'SledjChisl'", Tcmd, scRun, Tsocket)) 8306 if (shellMeFail("%s %s/%s select-pane -t 1 -T 'SledjChisl' \\; select-pane -t @0.%%3 -T 'FCGI web server'", Tcmd, scRun, Tsocket))
8297 E("tmux select-pane command failed!"); 8307 E("tmux select-pane command failed!");
8298 } 8308 }
8299 // toybox argument parsing is half working. 8309 // toybox argument parsing is half working.
@@ -8574,22 +8584,20 @@ Create the /opt/opensim-SC directory structure.
8574 // Start ROBUST or join the tmux session, or just figure out where the sims are running in tmux. 8584 // Start ROBUST or join the tmux session, or just figure out where the sims are running in tmux.
8575 if ((START == currentMode) && !checkSimIsRunning("ROBUST")) 8585 if ((START == currentMode) && !checkSimIsRunning("ROBUST"))
8576 { 8586 {
8577 char *d = xmprintf("%s.{right}", Ttab);
8578 char *c = xmprintf("cd %s/current/bin", scRoot); 8587 char *c = xmprintf("cd %s/current/bin", scRoot);
8579 8588
8580 I("ROBUST is starting up."); 8589 I("ROBUST is starting up.");
8581 sendTmuxCmd(d, c); 8590 sendTmuxCmd("@0.%1", c);
8582 free(c); 8591 free(c);
8583 c = xmprintf("mono Robust.exe -inidirectory=%s/config/ROBUST", scRoot); 8592 c = xmprintf("mono Robust.exe -inidirectory=%s/config/ROBUST", scRoot);
8584 sendTmuxCmd(d, c); 8593 sendTmuxCmd("@0.%1", c);
8585 free(c); 8594 free(c);
8586 doTmuxCmd("select-pane -t 0 -T 'ROBUST'", Tcmd, scRun, Tsocket); 8595 doTmuxCmd("select-pane -t @0.%%1 -T 'ROBUST'", Tcmd, scRun, Tsocket);
8587 8596
8588 // Create all the tmux windows, panes, and temporary .ini files coz OpenSim sucketh. 8597 // Create all the tmux windows, panes, and temporary .ini files coz OpenSim sucketh.
8589 forEachSim("Prepping", prepSims, NULL); 8598 forEachSim("Prepping", prepSims, NULL);
8590 waitTmuxText(d, "INITIALIZATION COMPLETE FOR ROBUST"); 8599 waitTmuxText("@0.%1", "INITIALIZATION COMPLETE FOR ROBUST");
8591 I("ROBUST is done starting up."); 8600 I("ROBUST is done starting up.");
8592 free(d);
8593 } 8601 }
8594 else if ((0 == toys.optc) && (checkSimIsRunning("ROBUST"))) 8602 else if ((0 == toys.optc) && (checkSimIsRunning("ROBUST")))
8595 { 8603 {
@@ -8625,14 +8633,14 @@ Create the /opt/opensim-SC directory structure.
8625 { 8633 {
8626 if (checkSimIsRunning("ROBUST")) 8634 if (checkSimIsRunning("ROBUST"))
8627 { 8635 {
8628 sendTmuxCmd("@0.%0", "quit"); 8636 sendTmuxCmd("@0.%1", "quit");
8629 while (checkSimIsRunning("ROBUST")) 8637 while (checkSimIsRunning("ROBUST"))
8630 usleep(100000); 8638 usleep(100000);
8631 usleep(100000); 8639 usleep(100000);
8632 sendTmuxCmd("@0.%0", "exit"); 8640 sendTmuxCmd("@0.%1", "exit");
8633 usleep(100000); 8641 usleep(100000);
8634 sendTmuxCmd("@0.%0", "exit"); 8642 sendTmuxCmd("@0.%1", "exit");
8635 I("ROBUST has stopped in tmux ID @0.%%0."); 8643 I("ROBUST has stopped in tmux ID @0.%%1.");
8636 } 8644 }
8637 8645
8638 if (FLAG(a)) 8646 if (FLAG(a))
@@ -8676,22 +8684,6 @@ Create the /opt/opensim-SC directory structure.
8676 } 8684 }
8677 } 8685 }
8678 } 8686 }
8679 else if (START == currentMode)
8680 {
8681 if (checkSimIsRunning("ROBUST") && (NULL == ourSims->target))
8682 {
8683 // TODO - remove this once we handle the fcgi stuff ourselves.
8684 I("Starting the web stuff.");
8685 // 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.
8686 // TODO - BIG SECURITY HOLE???
8687 char *c = xmprintf("spawn-fcgi -n -u %s -s %s/sledjchisl.socket -M 0666 -G www-data -- /usr/bin/valgrind --leak-check=full sledjchisl",
8688 scUser, scRun, scRoot);
8689 sendTmuxCmd(Ttab, c);
8690 free(c);
8691 }
8692 else
8693 I("NOT Starting the web stuff.");
8694 }
8695 } 8687 }
8696 else 8688 else
8697 { 8689 {