aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authoronefang2021-08-27 20:27:57 +1000
committeronefang2021-08-27 20:27:57 +1000
commit8ef47c1617219d8498cf0ab81d0d864e1b1fbf14 (patch)
tree0dd9e228fb97e74b9272cd04921aede23c67e696 /src
parentWrite actual update and builh sledjchisl commands. (diff)
downloadopensim-SC-8ef47c1617219d8498cf0ab81d0d864e1b1fbf14.zip
opensim-SC-8ef47c1617219d8498cf0ab81d0d864e1b1fbf14.tar.gz
opensim-SC-8ef47c1617219d8498cf0ab81d0d864e1b1fbf14.tar.bz2
opensim-SC-8ef47c1617219d8498cf0ab81d0d864e1b1fbf14.tar.xz
Make sure we can run sledjchisl most places.
Mostly by CDing to scRoot first.
Diffstat (limited to 'src')
-rw-r--r--src/sledjchisl/sledjchisl.c39
1 files 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()
1527 if (!qfile_exist(newPath)) 1527 if (!qfile_exist(newPath))
1528 { 1528 {
1529 char *cmd = xmprintf("sed -E" 1529 char *cmd = xmprintf("sed -E"
1530 " -e 's#\\[Const]#\\[Const] ; fakeVariableCozOpenSim='' ; pushd ../current/bin; ./sledjchisl $1 `basename $0`; popd ; exit 0#'" 1530 " -e 's#\\[Const]#\\[Const] ; fakeVariableCozOpenSim='' ; sledjchisl $1 `basename $0`; exit 0#'"
1531 " -e 's/mysim=\"[[:digit:]]*\"/mysim=\"%s\"/'" 1531 " -e 's/mysim=\"[[:digit:]]*\"/mysim=\"%s\"/'"
1532 " -e 's/sim\\$\\{Const\\|mysim\\}/\\$\\{Const\\|mysim\\}/g'" 1532 " -e 's/sim\\$\\{Const\\|mysim\\}/\\$\\{Const\\|mysim\\}/g'"
1533 " -e '/\\[Startup\\]/d'" 1533 " -e '/\\[Startup\\]/d'"
@@ -1834,7 +1834,7 @@ void prepSims(simData *simd, char *sim, char *type, int count, int window, int p
1834 } 1834 }
1835 else if (0 == pane) 1835 else if (0 == pane)
1836 { 1836 {
1837 doTmuxCmd("new-window -dc '%s/current/bin' -n '%s' -t '%s:%d'", scRoot, type, Tconsole, window); 1837 doTmuxCmd("new-window -dc '%s' -n '%s' -t '%s:%d'", scRoot, type, Tconsole, window);
1838 if (2 <= panes) 1838 if (2 <= panes)
1839 doTmuxCmd("split-window -hp 50 -d -t '%s:%d.0'", Tconsole, window); 1839 doTmuxCmd("split-window -hp 50 -d -t '%s:%d.0'", Tconsole, window);
1840 if (4 <= panes) 1840 if (4 <= panes)
@@ -1907,7 +1907,7 @@ void startSim(simData *simd, char *sim, char *type, int count, int window, int p
1907 { 1907 {
1908 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); 1908 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);
1909 doTmuxCmd("select-pane -t %s:%s -T '%s'", Tconsole, simd->paneID, simd->tab); 1909 doTmuxCmd("select-pane -t %s:%s -T '%s'", Tconsole, simd->paneID, simd->tab);
1910 snprintf(toybuf, sizeof(toybuf), "mono OpenSim.exe -inidirectory=%s/sim%d", scTemp, count); 1910 snprintf(toybuf, sizeof(toybuf), "cd %s/current/bin; mono OpenSim.exe -inidirectory=%s/sim%d", scRoot, scTemp, count);
1911 sendTmuxCmd(simd->paneID, toybuf); 1911 sendTmuxCmd(simd->paneID, toybuf);
1912 if (0 == ourSims->doIt) 1912 if (0 == ourSims->doIt)
1913 { 1913 {
@@ -8232,9 +8232,9 @@ jit library is loaded or the JIT compiler will not be activated.
8232 luaL_openlibs(L); // Load Lua libraries. 8232 luaL_openlibs(L); // Load Lua libraries.
8233 8233
8234/* Load the config scripts. 8234/* Load the config scripts.
8235Normally we start in /opt/opensim_SC/current/bin 8235Normally we start in /opt/opensim_SC
8236 sledjchisl here is a symlink to ../src/build/toybox/toybox or ../src/build/toybox/generated/unstripped/toybox 8236 sledjchisl here is a symlink to ../src/build/toybox/toybox or ../src/build/toybox/generated/unstripped/toybox
8237 So that .sledjChisl.conf.lua is found, which is normally a symlink to ../src/.sledjChisl.conf.lua 8237 So that ./etc/.sledjChisl.conf.lua is found.
8238 8238
8239Other possibilities - 8239Other possibilities -
8240 Normally sledjchisl isn't in the path, though it is once our tmux is running. 8240 Normally sledjchisl isn't in the path, though it is once our tmux is running.
@@ -8253,16 +8253,16 @@ Other possibilities -
8253 char *oPaths[] = 8253 char *oPaths[] =
8254 { 8254 {
8255 ".sledjChisl.conf.lua", 8255 ".sledjChisl.conf.lua",
8256 "./etc/sledjChisl.conf.lua", 8256 "./etc/.sledjChisl.conf.lua",
8257 NULL 8257 NULL
8258 }; 8258 };
8259 8259
8260 result = scanForConfigs(cPaths); 8260 result = scanForConfigs(cPaths);
8261 result = result | scanForConfigs(oPaths); 8261 result = result || scanForConfigs(oPaths);
8262 if (result) 8262 if (result)
8263 { 8263 {
8264 if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; V("Setting scRoot = %s", scRoot);} 8264 if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; V("Setting scRoot = %s", scRoot);}
8265 snprintf(toybuf, sizeof(toybuf), "%s/current/bin", scRoot); 8265 snprintf(toybuf, sizeof(toybuf), "%s", scRoot);
8266 t0 = realpath(pwd, NULL); 8266 t0 = realpath(pwd, NULL);
8267 t1 = realpath(toybuf, NULL); 8267 t1 = realpath(toybuf, NULL);
8268 if (strcmp(t0, t1) != 0) 8268 if (strcmp(t0, t1) != 0)
@@ -8319,7 +8319,7 @@ Other possibilities -
8319 goto finished; 8319 goto finished;
8320 } 8320 }
8321 8321
8322 snprintf(toybuf, sizeof(toybuf), "%s/current/bin", scRoot); 8322 snprintf(toybuf, sizeof(toybuf), "%s", scRoot);
8323 t1 = realpath(toybuf, NULL); 8323 t1 = realpath(toybuf, NULL);
8324 if ((NULL != t0) && (strcmp(t0, t1))) 8324 if ((NULL != t0) && (strcmp(t0, t1)))
8325 C("scRoot moved unexpectedly, check your sledjChisl.conf.lua files! %s != %s", t0, t1); 8325 C("scRoot moved unexpectedly, check your sledjChisl.conf.lua files! %s != %s", t0, t1);
@@ -8457,7 +8457,6 @@ Build the OpenSim.
8457 V("Not running inside the proper tmux server. %s == %s", eTMUX, toybuf); 8457 V("Not running inside the proper tmux server. %s == %s", eTMUX, toybuf);
8458 } 8458 }
8459 8459
8460// 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.
8461 if (!isTmux) 8460 if (!isTmux)
8462 { // Let's see if the proper tmux server is even running. 8461 { // Let's see if the proper tmux server is even running.
8463 i = shellMe("%s %s/%s -q list-sessions 2>/dev/null | grep -q %s:", Tcmd, scRun, Tsocket, Tconsole); 8462 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.
8483 snprintf(toybuf, sizeof(toybuf), 8482 snprintf(toybuf, sizeof(toybuf),
8484 "%s %s %s/%s set-option -g default-command 'export PATH=%s:$PATH; bash'\\; " 8483 "%s %s %s/%s set-option -g default-command 'export PATH=%s:$PATH; bash'\\; "
8485 // Set x,y to huge values, to work around an OpenSim bug. 8484 // Set x,y to huge values, to work around an OpenSim bug.
8486 "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' \\; " 8485 "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' \\; "
8487 "split-window -vp 50 -d -t '%s:0.0' \\; " 8486 "split-window -vp 50 -d -t '%s:0.0' \\; "
8488 "split-window -hp 50 -d -t '%s:0.1' \\; " 8487 "split-window -hp 50 -d -t '%s:0.1' \\; "
8489 "split-window -hp 50 -d -t '%s:0.0' " 8488 "split-window -hp 50 -d -t '%s:0.0' "
@@ -8491,10 +8490,16 @@ Build the OpenSim.
8491 // 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. 8490 // 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.
8492 // TODO - BIG SECURITY HOLE??? 8491 // TODO - BIG SECURITY HOLE???
8493 "bash -c 'export PATH=%s:$PATH; " 8492 "bash -c 'export PATH=%s:$PATH; "
8494 "spawn-fcgi -n -u %s -s %s/sledjchisl.socket -M 0666 -G www-data -- /usr/bin/valgrind --leak-check=full sledjchisl; " 8493 "spawn-fcgi -n -u %s -s %s/sledjchisl.socket -M 0666 -G www-data -- /usr/bin/valgrind --leak-check=full sledjchisl %s; "
8495 "cd %s/current/bin; bash'" 8494 "cd %s; bash'"
8496 , 8495 ,
8497 pre, Tcmd, scRun, Tsocket, scBin, Tconsole, Ttab, scBin, scRoot, Tconsole, Tconsole, Tconsole, scBin, scUser, scRun, scBin, scRoot); 8496 pre, Tcmd, scRun, Tsocket, scBin,
8497 Tconsole, Ttab, scBin, FLAG(v) ? "-v" : "", scRoot,
8498 Tconsole,
8499 Tconsole,
8500 Tconsole,
8501 scBin,
8502 scUser, scRun, FLAG(v) ? "-v" : "", scRoot);
8498 free(pre); 8503 free(pre);
8499 if (shellMeFail(toybuf)) 8504 if (shellMeFail(toybuf))
8500 E("tmux new-session command failed! %s", toybuf); 8505 E("tmux new-session command failed! %s", toybuf);
@@ -8756,7 +8761,7 @@ Create the /opt/opensim-SC directory structure.
8756 if (shellMeFail("chmod ug=rwx,o= %s", scCache)) C("Can't set proper permissions for %s", scCache); 8761 if (shellMeFail("chmod ug=rwx,o= %s", scCache)) C("Can't set proper permissions for %s", scCache);
8757 if (shellMeFail("chmod -fR a=r,ug=rw,a+X %s", scData)) C("Can't set proper permissions for %s", scData); 8762 if (shellMeFail("chmod -fR a=r,ug=rw,a+X %s", scData)) C("Can't set proper permissions for %s", scData);
8758 if (shellMeFail("chmod -fR a=r,ug=rw,a+X %s", scEtc)) C("Can't set proper permissions for %s", scEtc); 8763 if (shellMeFail("chmod -fR a=r,ug=rw,a+X %s", scEtc)) C("Can't set proper permissions for %s", scEtc);
8759 if (shellMeFail("chmod u=rw,go= %s/.sledjChisl.conf.lua", scEtc)) C("Can't set proper permissions for %s/.sledjChisl.conf.lua", scEtc); 8764 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);
8760 if (shellMeFail("chmod g+s %s", scEtc)) C("Can't set proper permissions for %s", scEtc); 8765 if (shellMeFail("chmod g+s %s", scEtc)) C("Can't set proper permissions for %s", scEtc);
8761 if (shellMeFail("chmod a+x %s/*.shini", scEtc)) C("Can't set proper permissions for %s/*.shini", scEtc); 8766 if (shellMeFail("chmod a+x %s/*.shini", scEtc)) C("Can't set proper permissions for %s/*.shini", scEtc);
8762 if (shellMeFail("chmod -fR a=r,ug=rw,a+X %s", scLib)) C("Can't set proper permissions for %s", scLib); 8767 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.
8782 free(tmp); 8787 free(tmp);
8783 free(newPath); 8788 free(newPath);
8784 8789
8785 char *c = xmprintf("cd %s/current/bin", scRoot); 8790 char *c = xmprintf("cd %s", scRoot);
8786 I("ROBUST is starting up."); 8791 I("ROBUST is starting up.");
8787 sendTmuxCmd("@0.%1", c); 8792 sendTmuxCmd("@0.%1", c);
8788 free(c); 8793 free(c);
8789 c = xmprintf("mono Robust.exe -inidirectory=%s/config/ROBUST", scRoot); 8794 c = xmprintf("cd %s/current/bin; mono Robust.exe -inidirectory=%s/config/ROBUST", scRoot, scRoot);
8790 sendTmuxCmd("@0.%1", c); 8795 sendTmuxCmd("@0.%1", c);
8791 free(c); 8796 free(c);
8792 doTmuxCmd("select-pane -t @0.%%1 -T 'ROBUST'", Tcmd, scRun, Tsocket); 8797 doTmuxCmd("select-pane -t @0.%%1 -T 'ROBUST'", Tcmd, scRun, Tsocket);