From 8ef47c1617219d8498cf0ab81d0d864e1b1fbf14 Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 27 Aug 2021 20:27:57 +1000 Subject: Make sure we can run sledjchisl most places. Mostly by CDing to scRoot first. --- src/sledjchisl/sledjchisl.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index fcd8b99..6a45d82 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -1527,7 +1527,7 @@ simList *getSims() if (!qfile_exist(newPath)) { char *cmd = xmprintf("sed -E" - " -e 's#\\[Const]#\\[Const] ; fakeVariableCozOpenSim='' ; pushd ../current/bin; ./sledjchisl $1 `basename $0`; popd ; exit 0#'" + " -e 's#\\[Const]#\\[Const] ; fakeVariableCozOpenSim='' ; sledjchisl $1 `basename $0`; exit 0#'" " -e 's/mysim=\"[[:digit:]]*\"/mysim=\"%s\"/'" " -e 's/sim\\$\\{Const\\|mysim\\}/\\$\\{Const\\|mysim\\}/g'" " -e '/\\[Startup\\]/d'" @@ -1834,7 +1834,7 @@ void prepSims(simData *simd, char *sim, char *type, int count, int window, int p } 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' -n '%s' -t '%s:%d'", scRoot, type, Tconsole, window); if (2 <= panes) doTmuxCmd("split-window -hp 50 -d -t '%s:%d.0'", Tconsole, window); if (4 <= panes) @@ -1907,7 +1907,7 @@ void startSim(simData *simd, char *sim, char *type, int count, int window, int p { I("Tmux tab [%d:%s](pane %d) tmux ID %s, from %s/sim%d - %s is starting.", window, type, pane, simd->paneID, scTemp, count, simd->name); doTmuxCmd("select-pane -t %s:%s -T '%s'", Tconsole, simd->paneID, simd->tab); - snprintf(toybuf, sizeof(toybuf), "mono OpenSim.exe -inidirectory=%s/sim%d", scTemp, count); + snprintf(toybuf, sizeof(toybuf), "cd %s/current/bin; mono OpenSim.exe -inidirectory=%s/sim%d", scRoot, scTemp, count); sendTmuxCmd(simd->paneID, toybuf); if (0 == ourSims->doIt) { @@ -8232,9 +8232,9 @@ jit library is loaded or the JIT compiler will not be activated. luaL_openlibs(L); // Load Lua libraries. /* Load the config scripts. -Normally we start in /opt/opensim_SC/current/bin +Normally we start in /opt/opensim_SC sledjchisl here is a symlink to ../src/build/toybox/toybox or ../src/build/toybox/generated/unstripped/toybox - So that .sledjChisl.conf.lua is found, which is normally a symlink to ../src/.sledjChisl.conf.lua + So that ./etc/.sledjChisl.conf.lua is found. Other possibilities - Normally sledjchisl isn't in the path, though it is once our tmux is running. @@ -8253,16 +8253,16 @@ Other possibilities - char *oPaths[] = { ".sledjChisl.conf.lua", - "./etc/sledjChisl.conf.lua", + "./etc/.sledjChisl.conf.lua", NULL }; result = scanForConfigs(cPaths); - result = result | scanForConfigs(oPaths); + result = result || scanForConfigs(oPaths); if (result) { if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; V("Setting scRoot = %s", scRoot);} - snprintf(toybuf, sizeof(toybuf), "%s/current/bin", scRoot); + snprintf(toybuf, sizeof(toybuf), "%s", scRoot); t0 = realpath(pwd, NULL); t1 = realpath(toybuf, NULL); if (strcmp(t0, t1) != 0) @@ -8319,7 +8319,7 @@ Other possibilities - goto finished; } - snprintf(toybuf, sizeof(toybuf), "%s/current/bin", scRoot); + snprintf(toybuf, sizeof(toybuf), "%s", scRoot); t1 = realpath(toybuf, NULL); if ((NULL != t0) && (strcmp(t0, t1))) C("scRoot moved unexpectedly, check your sledjChisl.conf.lua files! %s != %s", t0, t1); @@ -8457,7 +8457,6 @@ Build the OpenSim. V("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. Earlier code also tries to ensure this. if (!isTmux) { // Let's see if the proper tmux server is even running. i = shellMe("%s %s/%s -q list-sessions 2>/dev/null | grep -q %s:", Tcmd, scRun, Tsocket, Tconsole); @@ -8483,7 +8482,7 @@ Build the OpenSim. 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' \\; " + "new-session -d -x 256 -y 420 -s %s -n '%s' bash -c 'export PATH=%s:$PATH; /usr/bin/valgrind --leak-check=full sledjchisl %s; cd %s; 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' " @@ -8491,10 +8490,16 @@ Build the OpenSim. // 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'" + "spawn-fcgi -n -u %s -s %s/sledjchisl.socket -M 0666 -G www-data -- /usr/bin/valgrind --leak-check=full sledjchisl %s; " + "cd %s; bash'" , - pre, Tcmd, scRun, Tsocket, scBin, Tconsole, Ttab, scBin, scRoot, Tconsole, Tconsole, Tconsole, scBin, scUser, scRun, scBin, scRoot); + pre, Tcmd, scRun, Tsocket, scBin, + Tconsole, Ttab, scBin, FLAG(v) ? "-v" : "", scRoot, + Tconsole, + Tconsole, + Tconsole, + scBin, + scUser, scRun, FLAG(v) ? "-v" : "", scRoot); free(pre); if (shellMeFail(toybuf)) E("tmux new-session command failed! %s", toybuf); @@ -8756,7 +8761,7 @@ Create the /opt/opensim-SC directory structure. if (shellMeFail("chmod ug=rwx,o= %s", scCache)) C("Can't set proper permissions for %s", scCache); if (shellMeFail("chmod -fR a=r,ug=rw,a+X %s", scData)) C("Can't set proper permissions for %s", scData); if (shellMeFail("chmod -fR a=r,ug=rw,a+X %s", scEtc)) C("Can't set proper permissions for %s", scEtc); - if (shellMeFail("chmod u=rw,go= %s/.sledjChisl.conf.lua", scEtc)) C("Can't set proper permissions for %s/.sledjChisl.conf.lua", scEtc); + if (shellMeFail("chmod u=rw,g=r,o= %s/.sledjChisl.conf.lua", scEtc)) C("Can't set proper permissions for %s/.sledjChisl.conf.lua", scEtc); if (shellMeFail("chmod g+s %s", scEtc)) C("Can't set proper permissions for %s", scEtc); if (shellMeFail("chmod a+x %s/*.shini", scEtc)) C("Can't set proper permissions for %s/*.shini", scEtc); if (shellMeFail("chmod -fR a=r,ug=rw,a+X %s", scLib)) C("Can't set proper permissions for %s", scLib); @@ -8782,11 +8787,11 @@ Create the /opt/opensim-SC directory structure. free(tmp); free(newPath); - char *c = xmprintf("cd %s/current/bin", scRoot); + char *c = xmprintf("cd %s", scRoot); I("ROBUST is starting up."); sendTmuxCmd("@0.%1", c); free(c); - c = xmprintf("mono Robust.exe -inidirectory=%s/config/ROBUST", scRoot); + c = xmprintf("cd %s/current/bin; mono Robust.exe -inidirectory=%s/config/ROBUST", scRoot, scRoot); sendTmuxCmd("@0.%1", c); free(c); doTmuxCmd("select-pane -t @0.%%1 -T 'ROBUST'", Tcmd, scRun, Tsocket); -- cgit v1.1