1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-14 11:23:57 +02:00
openwrt-packages/net/vnstat2/patches/100-noexit.patch
Jan Hoffmann 10a8054925
vnstat2: update to version 2.9
Signed-off-by: Jan Hoffmann <jan@3e8.eu>
(cherry picked from commit 948f0d29cc)
2022-02-18 23:25:59 +01:00

61 lines
1.8 KiB
Diff

--- a/src/daemon.c
+++ b/src/daemon.c
@@ -252,6 +252,7 @@ void initdstate(DSTATE *s)
s->sync = 0;
s->forcesave = 0;
s->noadd = 0;
+ s->noexit = 0;
s->initdb = 0;
s->iflisthash = 0;
s->cfgfile[0] = '\0';
@@ -282,6 +283,9 @@ void preparedatabase(DSTATE *s)
}
if (s->noadd) {
+ if (s->noexit) {
+ return;
+ }
printf("No interfaces found in database, exiting.\n");
exit(EXIT_FAILURE);
}
@@ -300,6 +304,9 @@ void preparedatabase(DSTATE *s)
}
if (!addinterfaces(s) && s->dbifcount == 0) {
+ if (s->noexit) {
+ return;
+ }
printf("Nothing to do, exiting.\n");
exit(EXIT_FAILURE);
}
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -4,7 +4,7 @@
typedef struct {
int updateinterval, saveinterval;
short running, dodbsave, rundaemon;
- short dbsaved, showhelp, sync, forcesave, noadd, initdb;
+ short dbsaved, showhelp, sync, forcesave, noadd, noexit, initdb;
short bootdetected, cleanuphour, dbretrycount;
uint32_t iflisthash;
uint64_t dbifcount;
--- a/src/vnstatd.c
+++ b/src/vnstatd.c
@@ -249,6 +249,7 @@ void showhelp(void)
printf(" --config <config file> select used config file\n");
printf(" --noadd prevent startup if database has no interfaces\n");
printf(" --alwaysadd [mode] automatically start monitoring all new interfaces\n");
+ printf(" --noexit keep running even when database has no interfaces\n");
printf(" --initdb create empty database and exit\n\n");
printf("See also \"man vnstatd\".\n");
@@ -322,6 +323,8 @@ void parseargs(DSTATE *s, int argc, char
} else {
cfg.alwaysadd = 1;
}
+ } else if (strcmp(argv[currentarg], "--noexit") == 0) {
+ s->noexit = 1;
} else if (strcmp(argv[currentarg], "--initdb") == 0) {
s->initdb = 1;
s->showhelp = 0;