From c25e8a32c0071a5b3e1ae7bbb1b4dd7be7b54698 Mon Sep 17 00:00:00 2001 From: onefang Date: Fri, 3 Sep 2021 10:38:02 +1000 Subject: Better sledjchisl.conf.lua searching. --- src/sledjchisl/sledjchisl.c | 70 +++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 5269806..da9a7e6 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -8084,12 +8084,36 @@ int scanForConfigs(char **cPaths) snprintf(toybuf, sizeof(toybuf), "%s", cPaths[i]); else snprintf(toybuf, sizeof(toybuf), "%s/%s", pwd, cPaths[i]); - -V("Looking for config file %s", toybuf); + V("Looking for config file %s", toybuf); if (qfile_exist(toybuf)) { + char *tmp; + void *vd; + I("Loading configuration file (maybe) - %s", toybuf); Lua2hashtbl(toybuf, configs, "config"); + DEBUG = configs->getint(configs, "debug"); + V("Setting DEBUG = %d", DEBUG); + if ((vd = configs->get (configs, "loadAverageInc", NULL, false)) != NULL) {loadAverageInc = *((float *) vd); V("Setting loadAverageInc = %f", loadAverageInc);} + if ((vd = configs->get (configs, "simTimeOut", NULL, false)) != NULL) {simTimeOut = (int) *((float *) vd); V("Setting simTimeOut = %d", simTimeOut);} + if ((vd = configs->get (configs, "bulkSims", NULL, false)) != NULL) {bulkSims = (int) *((float *) vd); V("Setting bulkSims = %d", bulkSims);} + if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; V("Setting scRoot = %s", scRoot);} + if ((tmp = configs->getstr(configs, "scUser", false)) != NULL) {scUser = tmp; V("Setting scUser = %s", scUser);} + if ((tmp = configs->getstr(configs, "Tconsole", false)) != NULL) {Tconsole = tmp; V("Setting Tconsole = %s", Tconsole);} + if ((tmp = configs->getstr(configs, "Tsocket", false)) != NULL) {Tsocket = tmp; V("Setting Tsocket = %s", Tsocket);} + if ((tmp = configs->getstr(configs, "Ttab", false)) != NULL) {Ttab = tmp; V("Setting Ttab = %s", Ttab);} + if ((vd = configs->get (configs, "startPort", NULL, false)) != NULL) {startPort = (int) *((float *) vd); V("Setting startPort = %d", startPort);} + if ((tmp = configs->getstr(configs, "backupIARsim", false)) != NULL) {backupIARsim = tmp; V("Setting backupIARsim = %s", backupIARsim);} + if ((tmp = configs->getstr(configs, "rsync", false)) != NULL) {rSync = tmp; V("Setting rsync = %s", rSync);} + if ((vd = configs->getstr(configs, "rsyncPort", false)) != NULL) {rSyncPort = (int) *((float *) vd); V("Setting rsyncPort = %s", rSyncPort);} + if ((tmp = configs->getstr(configs, "webRoot", false)) != NULL) {webRoot = tmp; V("Setting webRoot = %s", webRoot);} + if ((tmp = configs->getstr(configs, "URL", false)) != NULL) {URL = tmp; V("Setting URL = %s", URL);} + if ((vd = configs->get (configs, "seshRenew", NULL, false)) != NULL) {seshRenew = (int) *((float *) vd); V("Setting seshRenew = %d", seshRenew);} + if ((vd = configs->get (configs, "idleTimeOut", NULL, false)) != NULL) {idleTimeOut = (int) *((float *) vd); V("Setting idleTimeOut = %d", idleTimeOut);} + if ((vd = configs->get (configs, "seshTimeOut", NULL, false)) != NULL) {seshTimeOut = (int) *((float *) vd); V("Setting seshTimeOut = %d", seshTimeOut);} + if ((vd = configs->get (configs, "newbieTimeOut", NULL, false)) != NULL) {newbieTimeOut = (int) *((float *) vd); V("Setting newbieTimeOut = %d", newbieTimeOut);} + if ((tmp = configs->getstr(configs, "ToS", false)) != NULL) {ToS = tmp; V("Setting ToS = %s", ToS);} + if ((tmp = configs->getstr(configs, "webIframers", false)) != NULL) {webIframers = tmp; V("Setting webIframers = %s", webIframers);} result = TRUE; } } @@ -8105,7 +8129,6 @@ void sledjchisl_main(void) char *tmp, *t0 = NULL, *t1 = NULL; struct stat statbuf; int status, result, i; - void *vd; if(FLAG(v)) VERBOSE = TRUE; @@ -8211,8 +8234,8 @@ jit library is loaded or the JIT compiler will not be activated. /* Load the config scripts. 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 ./etc/.sledjChisl.conf.lua is found. + current/bin/sledjchisl here is a symlink to ../src/build/toybox/toybox or ../src/build/toybox/generated/unstripped/toybox + 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. @@ -8225,21 +8248,14 @@ Other possibilities - // "/etc/sledjChisl.d/*.lua", "~/.sledjChisl.conf.lua", // "~/.config/sledjChisl/*.lua", - NULL - }; - - char *oPaths[] = - { + "etc/.sledjChisl.conf.lua", ".sledjChisl.conf.lua", - "./etc/.sledjChisl.conf.lua", NULL }; result = scanForConfigs(cPaths); - 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", scRoot); t0 = realpath(pwd, NULL); t1 = realpath(toybuf, NULL); @@ -8255,7 +8271,6 @@ Other possibilities - free(t0); t0 = realpath(pwd, NULL); result = scanForConfigs(cPaths); - result = result | scanForConfigs(oPaths); } else { @@ -8266,32 +8281,7 @@ Other possibilities - free(t1); } - if (result) - { - DEBUG = configs->getint(configs, "debug"); - V("Setting DEBUG = %d", DEBUG); - if ((vd = configs->get (configs, "loadAverageInc", NULL, false)) != NULL) {loadAverageInc = *((float *) vd); V("Setting loadAverageInc = %f", loadAverageInc);} - if ((vd = configs->get (configs, "simTimeOut", NULL, false)) != NULL) {simTimeOut = (int) *((float *) vd); V("Setting simTimeOut = %d", simTimeOut);} - if ((vd = configs->get (configs, "bulkSims", NULL, false)) != NULL) {bulkSims = (int) *((float *) vd); V("Setting bulkSims = %d", bulkSims);} - if ((tmp = configs->getstr(configs, "scRoot", false)) != NULL) {scRoot = tmp; V("Setting scRoot = %s", scRoot);} - if ((tmp = configs->getstr(configs, "scUser", false)) != NULL) {scUser = tmp; V("Setting scUser = %s", scUser);} - if ((tmp = configs->getstr(configs, "Tconsole", false)) != NULL) {Tconsole = tmp; V("Setting Tconsole = %s", Tconsole);} - if ((tmp = configs->getstr(configs, "Tsocket", false)) != NULL) {Tsocket = tmp; V("Setting Tsocket = %s", Tsocket);} - if ((tmp = configs->getstr(configs, "Ttab", false)) != NULL) {Ttab = tmp; V("Setting Ttab = %s", Ttab);} - if ((vd = configs->get (configs, "startPort", NULL, false)) != NULL) {startPort = (int) *((float *) vd); V("Setting startPort = %d", startPort);} - if ((tmp = configs->getstr(configs, "backupIARsim", false)) != NULL) {backupIARsim = tmp; V("Setting backupIARsim = %s", backupIARsim);} - if ((tmp = configs->getstr(configs, "rsync", false)) != NULL) {rSync = tmp; V("Setting rsync = %s", rSync);} - if ((vd = configs->getstr(configs, "rsyncPort", false)) != NULL) {rSyncPort = (int) *((float *) vd); V("Setting rsyncPort = %s", rSyncPort);} - if ((tmp = configs->getstr(configs, "webRoot", false)) != NULL) {webRoot = tmp; V("Setting webRoot = %s", webRoot);} - if ((tmp = configs->getstr(configs, "URL", false)) != NULL) {URL = tmp; V("Setting URL = %s", URL);} - if ((vd = configs->get (configs, "seshRenew", NULL, false)) != NULL) {seshRenew = (int) *((float *) vd); V("Setting seshRenew = %d", seshRenew);} - if ((vd = configs->get (configs, "idleTimeOut", NULL, false)) != NULL) {idleTimeOut = (int) *((float *) vd); V("Setting idleTimeOut = %d", idleTimeOut);} - if ((vd = configs->get (configs, "seshTimeOut", NULL, false)) != NULL) {seshTimeOut = (int) *((float *) vd); V("Setting seshTimeOut = %d", seshTimeOut);} - if ((vd = configs->get (configs, "newbieTimeOut", NULL, false)) != NULL) {newbieTimeOut = (int) *((float *) vd); V("Setting newbieTimeOut = %d", newbieTimeOut);} - if ((tmp = configs->getstr(configs, "ToS", false)) != NULL) {ToS = tmp; V("Setting ToS = %s", ToS);} - if ((tmp = configs->getstr(configs, "webIframers", false)) != NULL) {webIframers = tmp; V("Setting webIframers = %s", webIframers);} - } - else + if (!result) { C("No sledjChisl.conf.lua found!"); goto finished; -- cgit v1.1