aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/sledjchisl/sledjchisl.c125
1 files changed, 91 insertions, 34 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c
index aae3031..189fd2d 100644
--- a/src/sledjchisl/sledjchisl.c
+++ b/src/sledjchisl/sledjchisl.c
@@ -7611,13 +7611,35 @@ static void cleanup(void)
7611} 7611}
7612 7612
7613 7613
7614int scanForConfigs(char **cPaths)
7615{
7616 int result = FALSE, i;
7617 struct stat st;
7618
7619 for (i = 0; cPaths[i]; i++)
7620 {
7621 if (('/' == cPaths[i][0]) || ('~' == cPaths[i][0]))
7622 snprintf(toybuf, sizeof(toybuf), "%s", cPaths[i]);
7623 else
7624 snprintf(toybuf, sizeof(toybuf), "%s/%s", pwd, cPaths[i]);
7625
7626 if (qfile_exist(toybuf))
7627 {
7628 I("Loading configuration file (maybe) - %s", toybuf);
7629 Lua2hashtbl(toybuf, configs, "config");
7630 result = TRUE;
7631 }
7632 }
7633 return result;
7634}
7635
7614//////////////////////////////////////////////////////////////////////////////////////////////////// 7636////////////////////////////////////////////////////////////////////////////////////////////////////
7615// Main function. 7637// Main function.
7616//////////////////////////////////////////////////////////////////////////////////////////////////// 7638////////////////////////////////////////////////////////////////////////////////////////////////////
7617void sledjchisl_main(void) 7639void sledjchisl_main(void)
7618{ 7640{
7619 char *cmd = *toys.optargs; 7641 char *cmd = *toys.optargs;
7620 char *tmp; 7642 char *tmp, *t0, *t1;
7621 struct stat statbuf; 7643 struct stat statbuf;
7622 int status, result, i; 7644 int status, result, i;
7623 void *vd; 7645 void *vd;
@@ -7625,6 +7647,7 @@ void sledjchisl_main(void)
7625 if(FLAG(v)) 7647 if(FLAG(v))
7626 VERBOSE = TRUE; 7648 VERBOSE = TRUE;
7627 7649
7650 V("SledjChisl command - %s", toys.argv[0]);
7628 V("SledjChisl arguments - %d %d", toys.optc, toys.optflags); 7651 V("SledjChisl arguments - %d %d", toys.optc, toys.optflags);
7629 for (i = 0; i < toys.optc; i++) 7652 for (i = 0; i < toys.optc; i++)
7630 V(" argument %d %s", i, toys.optargs[i] ); 7653 V(" argument %d %s", i, toys.optargs[i] );
@@ -7639,8 +7662,6 @@ void sledjchisl_main(void)
7639 V("OpenSSL version: %s", OPENSSL_VERSION_TEXT); 7662 V("OpenSSL version: %s", OPENSSL_VERSION_TEXT);
7640 V("qLibc version: qLibc only git tags for version numbers. Sooo, 2.4.4, unless I forgot to update this."); 7663 V("qLibc version: qLibc only git tags for version numbers. Sooo, 2.4.4, unless I forgot to update this.");
7641 V("toybox version: %s", TOYBOX_VERSION); 7664 V("toybox version: %s", TOYBOX_VERSION);
7642
7643
7644 dbRequests = qlist(0); 7665 dbRequests = qlist(0);
7645 sigatexit(cleanup); 7666 sigatexit(cleanup);
7646 7667
@@ -7704,51 +7725,87 @@ jit library is loaded or the JIT compiler will not be activated.
7704*/ 7725*/
7705 luaL_openlibs(L); // Load Lua libraries. 7726 luaL_openlibs(L); // Load Lua libraries.
7706 7727
7707 // Load the config scripts. 7728/* Load the config scripts.
7708// TODO - should add something like current working directory here. Gets complicated, may have to go up or down a bit. 7729Normally we start in /opt/opensim_SC/current/bin
7730 sledjchisl here is a symlink to ../src/build/toybox/toybox or ../src/build/toybox/generated/unstripped/toybox
7731 So that .sledjChisl.conf.lua is found, which is normally a symlink to ../src/.sledjChisl.conf.lua
7732
7733Other possibilities -
7734 Normally sledjchisl isn't in the path, though it is once our tmux is running.
7735 No doubt someone will put it in the path, so then we can start anywhere.
7736 Someone could run it from a downloaded opensim-SC and run it from that bin, then it's not installed.
7737*/
7709 char *cPaths[] = 7738 char *cPaths[] =
7710 { 7739 {
7711 ".sledjChisl.conf.lua",
7712 "/etc/sledjChisl.conf.lua", 7740 "/etc/sledjChisl.conf.lua",
7713// "/etc/sledjChisl.d/*.lua", 7741// "/etc/sledjChisl.d/*.lua",
7714 "~/.sledjChisl.conf.lua", 7742 "~/.sledjChisl.conf.lua",
7715// "~/.config/sledjChisl/*.lua", 7743// "~/.config/sledjChisl/*.lua",
7716 NULL 7744 NULL
7717 }; 7745 };
7718 struct stat st;
7719 7746
7720 for (i = 0; cPaths[i]; i++) 7747 char *oPaths[] =
7721 { 7748 {
7722 if (('/' == cPaths[i][0]) || ('~' == cPaths[i][0])) 7749 ".sledjChisl.conf.lua",
7723 snprintf(toybuf, sizeof(toybuf), "%s", cPaths[i]); 7750 "./etc/sledjChisl.conf.lua",
7724 else 7751 NULL
7725 snprintf(toybuf, sizeof(toybuf), "%s/%s", pwd, cPaths[i]); 7752 };
7726 7753
7727 if (qfile_exist(toybuf)) 7754 result = scanForConfigs(cPaths);
7755 result = result | scanForConfigs(oPaths);
7756 if (result)
7757 {
7758 if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; V("Setting scRoot = %s", scRoot);}
7759 snprintf(toybuf, sizeof(toybuf), "%s/current/bin", scRoot);
7760 t0 = realpath(pwd, NULL);
7761 t1 = realpath(toybuf, NULL);
7762 if (strcmp(t0, t1) != 0)
7728 { 7763 {
7729 I("Loading configuration file (maybe) - %s", toybuf); 7764 I("Not in the configured scRoot. %s != %s", t0, t1);
7730 Lua2hashtbl(toybuf, configs, "config"); 7765 if (qfile_exist(toybuf))
7766 {
7767 chdir(toybuf);
7768 result = scanForConfigs(cPaths);
7769 result = result | scanForConfigs(oPaths);
7770 }
7771 else
7772 C("The configured scRoot doesn't exist! Might need to actually install this. %s", scRoot);
7731 } 7773 }
7774 free(t1);
7775 }
7776
7777 if (result)
7778 {
7779 DEBUG = configs->getint(configs, "debug");
7780 V("Setting DEBUG = %d", DEBUG);
7781 if ((vd = configs->get (configs, "loadAverageInc", NULL, false)) != NULL) {loadAverageInc = *((float *) vd); V("Setting loadAverageInc = %f", loadAverageInc);}
7782 if ((vd = configs->get (configs, "simTimeOut", NULL, false)) != NULL) {simTimeOut = (int) *((float *) vd); V("Setting simTimeOut = %d", simTimeOut);}
7783 if ((vd = configs->get (configs, "bulkSims", NULL, false)) != NULL) {bulkSims = (int) *((float *) vd); V("Setting bulkSims = %d", bulkSims);}
7784 if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; V("Setting scRoot = %s", scRoot);}
7785 if ((tmp = configs->getstr(configs, "scUser", false)) != NULL) {scUser = tmp; V("Setting scUser = %s", scUser);}
7786 if ((tmp = configs->getstr(configs, "Tconsole", false)) != NULL) {Tconsole = tmp; V("Setting Tconsole = %s", Tconsole);}
7787 if ((tmp = configs->getstr(configs, "Tsocket", false)) != NULL) {Tsocket = tmp; V("Setting Tsocket = %s", Tsocket);}
7788 if ((tmp = configs->getstr(configs, "Ttab", false)) != NULL) {Ttab = tmp; V("Setting Ttab = %s", Ttab);}
7789 if ((tmp = configs->getstr(configs, "backupIARsim", false)) != NULL) {backupIARsim = tmp; V("Setting backupIARsim = %s", backupIARsim);}
7790 if ((tmp = configs->getstr(configs, "webRoot", false)) != NULL) {webRoot = tmp; V("Setting webRoot = %s", webRoot);}
7791 if ((tmp = configs->getstr(configs, "URL", false)) != NULL) {URL = tmp; V("Setting URL = %s", URL);}
7792 if ((vd = configs->get (configs, "seshRenew", NULL, false)) != NULL) {seshRenew = (int) *((float *) vd); V("Setting seshRenew = %d", seshRenew);}
7793 if ((vd = configs->get (configs, "idleTimeOut", NULL, false)) != NULL) {idleTimeOut = (int) *((float *) vd); V("Setting idleTimeOut = %d", idleTimeOut);}
7794 if ((vd = configs->get (configs, "seshTimeOut", NULL, false)) != NULL) {seshTimeOut = (int) *((float *) vd); V("Setting seshTimeOut = %d", seshTimeOut);}
7795 if ((vd = configs->get (configs, "newbieTimeOut", NULL, false)) != NULL) {newbieTimeOut = (int) *((float *) vd); V("Setting newbieTimeOut = %d", newbieTimeOut);}
7796 if ((tmp = configs->getstr(configs, "ToS", false)) != NULL) {ToS = tmp; V("Setting ToS = %s", ToS);}
7797 if ((tmp = configs->getstr(configs, "webIframers", false)) != NULL) {webIframers = tmp; V("Setting webIframers = %s", webIframers);}
7732 } 7798 }
7733 DEBUG = configs->getint(configs, "debug"); 7799 else
7734 V("Setting DEBUG = %d", DEBUG); 7800 C("No sledjChisl.conf.lua found!");
7735 if ((vd = configs->get (configs, "loadAverageInc", NULL, false)) != NULL) {loadAverageInc = *((float *) vd); V("Setting loadAverageInc = %f", loadAverageInc);} 7801
7736 if ((vd = configs->get (configs, "simTimeOut", NULL, false)) != NULL) {simTimeOut = (int) *((float *) vd); V("Setting simTimeOut = %d", simTimeOut);} 7802 snprintf(toybuf, sizeof(toybuf), "%s/current/bin", scRoot);
7737 if ((vd = configs->get (configs, "bulkSims", NULL, false)) != NULL) {bulkSims = (int) *((float *) vd); V("Setting bulkSims = %d", bulkSims);} 7803 t1 = realpath(toybuf, NULL);
7738 if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; V("Setting scRoot = %s", scRoot);} 7804 if (strcmp(t0, t1))
7739 if ((tmp = configs->getstr(configs, "scUser", false)) != NULL) {scUser = tmp; V("Setting scUser = %s", scUser);} 7805 C("scRoot moved unexpectedly, check your sledjChisl.conf.lua files! %s != %s", t0, t1);
7740 if ((tmp = configs->getstr(configs, "Tconsole", false)) != NULL) {Tconsole = tmp; V("Setting Tconsole = %s", Tconsole);} 7806 free(t1);
7741 if ((tmp = configs->getstr(configs, "Tsocket", false)) != NULL) {Tsocket = tmp; V("Setting Tsocket = %s", Tsocket);} 7807 free(t0);
7742 if ((tmp = configs->getstr(configs, "Ttab", false)) != NULL) {Ttab = tmp; V("Setting Ttab = %s", Ttab);} 7808
7743 if ((tmp = configs->getstr(configs, "backupIARsim", false)) != NULL) {backupIARsim = tmp; V("Setting backupIARsim = %s", backupIARsim);}
7744 if ((tmp = configs->getstr(configs, "webRoot", false)) != NULL) {webRoot = tmp; V("Setting webRoot = %s", webRoot);}
7745 if ((tmp = configs->getstr(configs, "URL", false)) != NULL) {URL = tmp; V("Setting URL = %s", URL);}
7746 if ((vd = configs->get (configs, "seshRenew", NULL, false)) != NULL) {seshRenew = (int) *((float *) vd); V("Setting seshRenew = %d", seshRenew);}
7747 if ((vd = configs->get (configs, "idleTimeOut", NULL, false)) != NULL) {idleTimeOut = (int) *((float *) vd); V("Setting idleTimeOut = %d", idleTimeOut);}
7748 if ((vd = configs->get (configs, "seshTimeOut", NULL, false)) != NULL) {seshTimeOut = (int) *((float *) vd); V("Setting seshTimeOut = %d", seshTimeOut);}
7749 if ((vd = configs->get (configs, "newbieTimeOut", NULL, false)) != NULL) {newbieTimeOut = (int) *((float *) vd); V("Setting newbieTimeOut = %d", newbieTimeOut);}
7750 if ((tmp = configs->getstr(configs, "ToS", false)) != NULL) {ToS = tmp; V("Setting ToS = %s", ToS);}
7751 if ((tmp = configs->getstr(configs, "webIframers", false)) != NULL) {webIframers = tmp; V("Setting webIframers = %s", webIframers);}
7752 7809
7753 7810
7754//////////////////////////////////////////////////////////////////////////////////////////////////// 7811////////////////////////////////////////////////////////////////////////////////////////////////////