Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.json not working state-less #5033

Closed
DarkxPunk opened this issue Mar 10, 2023 · 7 comments · Fixed by #6031
Closed

config.json not working state-less #5033

DarkxPunk opened this issue Mar 10, 2023 · 7 comments · Fixed by #6031
Labels

Comments

@DarkxPunk
Copy link

DarkxPunk commented Mar 10, 2023

I am using MariaDB attempting to start state-less. If I choose to use a mini config, I can start MeshCentral, but it loads none of the config. If I put my full config back and expressly tell it to load the config from the database, it still fails to load my config.

With mini config: node node_modules/meshcentral --debug --showall - I get the list with the top most being the config
With full config: node node_modules/meshcentral --debug --showall - I get the list with the top most being the config

If I choose to wipe out the meshcentral-data folder and tell it to start from the database, it says all the certificates are missing...

My guess, it isn't actually loading everything on to the database, and then it can't read it?

Thanks for any help!

  • OS: AlmaLinux 8
  • Virtualization: CloudLinux
  • Network: WAN on my cPanel server, rever proxied, ssl offloaded
  • Version: 1.1.4
  • Node: 16.19.1

Full config

{
  "$schema": "https://raw.githubusercontent.com/Ylianst/MeshCentral/master/meshcentral-config-schema.json",
  "__comment1__": "This is a simple configuration file, all values and sections that start with underscore (_) are ignored. Edit a section and remove the _ in front of the name. Refer to the user's guide for details.",
  "__comment2__": "See node_modules/meshcentral/sample-config-advanced.json for a more advanced example.",
  "settings": {
    "_cert": "sub.domian.tld",
    "WANonly": true,
    "_LANonly": true,
    "sessionKey": null,
    "port": 4443,
    "aliasPort": 443,
    "redirPort": 8080,
    "redirAliasPort": 80,
    "tlsOffload": "127.0.0.1",
    "trustedProxy": "127.0.0.1",
    "LoadConfigFromDB": "myKey",
    "mariaDB": {
      "host": "127.0.0.1",
      "user": "db_meshcentral",
      "port": 3306,
      "password": "myPassword",
      "database": "db_meshcentral"
    },
    "exactPorts": true,
    "webRTC": true,
    "_selfUpdate": true,
    "_cleanNpmCacheOnUpdate": true,
    "_allowHighQualityDesktop": true,
    "webPush": {
      "email": "example@domain.tld"
    },
    "_autoBackup": {
      
    }
  },
  "domains": {
    "": {
      "title": "My Remote Support Portal",
      "_titlePicture": "",
      "_loginPicture": "",
      "_minify": true,
      "_newAccounts": true,
      "_userNameIsEmail": true,
      "_welcomeText": "",
      "_welcomePicture": "",
      "_meshMessengerTitle": "",
      "_meshMessengerPicture": "",
      "_footer": "",
      "_loginfooter": "",
      "certUrl": "https://sub.domain.tld/",
      "_smtp": {
        "host": "mail.domain.tld",
        "port": "465",
        "from": "example@domain.tld",
        "tls": true,
        "auth": {
          "clientId": "",
          "clientSecret": "",
          "refreshToken": ""
        },
        "tlscertcheck": true,
        "tlsstrict": true,
        "verifyemail": true
      }
    }
  },
  "_smtp": {
    "host": "mail.domain.tld",
    "port": 465,
    "from": "example@domain.tld",
    "tls": true,
    "tlscertcheck": true,
    "tlsstrict": true,
    "verifyemail": true
  }
}

Mini config

{
  "settings": {
    "LoadConfigFromDB": "myKey",
    "mariaDB": {
      "user": "db_meshcentral",
      "password": "myPassword",
      "port": 3306,
      "host": "127.0.0.1",
      "database": "db_meshcentral"
    }
  }
}
@si458
Copy link
Collaborator

si458 commented Jan 15, 2024

are you still having this issue?
have you tried readon the docs and trying there examples?
https://ylianst.github.io/MeshCentral/meshcentral/#running-state-less

@DarkxPunk
Copy link
Author

DarkxPunk commented Apr 10, 2024

Yes I am still having the issue, I attempted today to simply load the config from the db using the mini config and it simply won't load. I reverted back to the full config and it works as expected.

I originally configured it following the #running-state-less section. So the config is loaded into the DB. It simply will not read the config from it when using the mini config. It does for sure connect and read from the DB when using the full config.

@si458 si458 added bug and removed question labels Apr 10, 2024
@si458
Copy link
Collaborator

si458 commented Apr 10, 2024

Never tried the stateless mode, so will add to my to-do list and gave a look see what's going on 👍

@si458
Copy link
Collaborator

si458 commented Apr 15, 2024

ok this is how i got it running...

  1. get it up and running using ur mysql db and config.json,
  2. once all running stop meshcentral
  3. run node node_modules/meshcentral --dbpushconfigfiles '*' --configkey SECRETKEYCHANGEITANDDONTFORGETIT
  4. let it push your meshcentral-data to your mysqldb
  5. once finished, rename config.json to config.json.bk (backup incase of anything)
  6. create new config.json inside of meshcentral-data with the following
{
    "$schema": "https://raw.githubusercontent.com/Ylianst/MeshCentral/master/meshcentral-config-schema.json",
    "settings": {
      "mySQL": {
        "host": "dbhost",
        "port": 3306,
        "user": "dbuser",
        "password": "dbpass",
        "database": "dbdb"
      }
    }
  }
  1. then run node node_modules/meshcentral --loadconfigfromdb SECRETKEYCHANGEITANDDONTFORGETIT

how you actually edit your config.json in the DB i have no idea as its encrypted with you
SECRETKEYCHANGEITANDDONTFORGETIT

@DarkxPunk
Copy link
Author

So I am using mariaDB but with mariaDB and the config.json file it loads correctly. If I remove the mariaDB then it breaks, so I know it is communicating. Uploading the config.json to DB works fine, but if I use settings similar to yours (but for mariaDB) it simply does not load up. If I put the full config.json back, it loads as expected.

It would be great to solve this, but since I am using this in production now I don't know how enthused I am to mess around too much with it.

@si458
Copy link
Collaborator

si458 commented Apr 15, 2024

@DarkxPunk dont worry im looking into it for you 👍
i have it working for mysql but you sadly still need a config.json 😞
HOWEVER
i have just managed to get it working by using arguments only so you dont need a config.json!
--mysql mysql://user:pass@127.0.0.1:3306/db
this already works if you use mongodb as it has an argument --mongodb
just sadly --mysql and --mariadb are missing but im working on it now!

@si458
Copy link
Collaborator

si458 commented Apr 15, 2024

ok ive done a PR, this will add --mysql and --mariadb to the runtime arguments
so you dont need to specify the inside your config.json

im still not sure why you cant get it working as it seems to work perfectly fine here?
my steps up here work a treat #5033 (comment) ?

also the is no value LoadConfigFromDB inside config.json so its best to remove it from there
as you are suppose to use --loadconfigfromdb KEYHERE when you run meshcentral instead at the command line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants