You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB

  1. --- a/src/daemon.c
  2. +++ b/src/daemon.c
  3. @@ -252,6 +252,7 @@ void initdstate(DSTATE *s)
  4. s->sync = 0;
  5. s->forcesave = 0;
  6. s->noadd = 0;
  7. + s->noexit = 0;
  8. s->initdb = 0;
  9. s->iflisthash = 0;
  10. s->cfgfile[0] = '\0';
  11. @@ -282,6 +283,9 @@ void preparedatabase(DSTATE *s)
  12. }
  13. if (s->noadd) {
  14. + if (s->noexit) {
  15. + return;
  16. + }
  17. printf("No interfaces found in database, exiting.\n");
  18. exit(EXIT_FAILURE);
  19. }
  20. @@ -300,6 +304,9 @@ void preparedatabase(DSTATE *s)
  21. }
  22. if (!addinterfaces(s) && s->dbifcount == 0) {
  23. + if (s->noexit) {
  24. + return;
  25. + }
  26. printf("Nothing to do, exiting.\n");
  27. exit(EXIT_FAILURE);
  28. }
  29. --- a/src/daemon.h
  30. +++ b/src/daemon.h
  31. @@ -4,7 +4,7 @@
  32. typedef struct {
  33. int updateinterval, saveinterval;
  34. short running, dodbsave, rundaemon;
  35. - short dbsaved, showhelp, sync, forcesave, noadd, initdb;
  36. + short dbsaved, showhelp, sync, forcesave, noadd, noexit, initdb;
  37. short bootdetected, cleanuphour, dbretrycount;
  38. uint32_t iflisthash;
  39. uint64_t dbifcount;
  40. --- a/src/vnstatd.c
  41. +++ b/src/vnstatd.c
  42. @@ -249,6 +249,7 @@ void showhelp(void)
  43. printf(" --config <config file> select used config file\n");
  44. printf(" --noadd prevent startup if database has no interfaces\n");
  45. printf(" --alwaysadd [mode] automatically start monitoring all new interfaces\n");
  46. + printf(" --noexit keep running even when database has no interfaces\n");
  47. printf(" --initdb create empty database and exit\n\n");
  48. printf("See also \"man vnstatd\".\n");
  49. @@ -322,6 +323,8 @@ void parseargs(DSTATE *s, int argc, char
  50. } else {
  51. cfg.alwaysadd = 1;
  52. }
  53. + } else if (strcmp(argv[currentarg], "--noexit") == 0) {
  54. + s->noexit = 1;
  55. } else if (strcmp(argv[currentarg], "--initdb") == 0) {
  56. s->initdb = 1;
  57. s->showhelp = 0;