mirror of
https://github.com/owntracks/recorder.git
synced 2026-08-23 11:26:16 +00:00
ocat: [NEW] $OCAT_STORAGEDIR or --storage (defaults to ./store)
This commit is contained in:
@@ -12,8 +12,8 @@ endif
|
||||
|
||||
all: ot-recorder ocat
|
||||
|
||||
ot-recorder: ot-recorder.c json.o utarray.h utstring.h geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o config.h udata.h misc.o util.o
|
||||
$(CC) $(CFLAGS) ot-recorder.c -o ot-recorder json.o geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o misc.o util.o $(LIBS)
|
||||
ot-recorder: ot-recorder.c json.o utarray.h utstring.h geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o config.h udata.h misc.o util.o storage.o
|
||||
$(CC) $(CFLAGS) ot-recorder.c -o ot-recorder json.o geo.o geohash.o mkpath.o file.o safewrite.o base64.o ghash.o misc.o util.o storage.o $(LIBS)
|
||||
|
||||
geo.o: geo.h geo.c udata.h Makefile config.mk config.h
|
||||
geohash.o: geohash.h geohash.c udata.h Makefile config.mk
|
||||
@@ -29,7 +29,7 @@ ocat: ocat.o storage.o json.o geohash.o ghash.o mkpath.o util.o
|
||||
$(CC) $(CFLAGS) -o ocat ocat.o storage.o json.o geohash.o ghash.o mkpath.o util.o $(LIBS)
|
||||
|
||||
ocat.o: ocat.c storage.h
|
||||
storage.o: storage.c storage.h config.h
|
||||
storage.o: storage.c storage.h config.h util.h
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
@@ -13,7 +13,7 @@ We took a number of decisions for the design of the recorder and its utilities:
|
||||
|
||||
## Storage
|
||||
|
||||
As mentioned earlier, data is stored in files, and these files are relative to `STORAGEDIR` (compiled into the programs). In particular, the following directory structure can exist, whereby directories are created as needed by the _recorder_:
|
||||
As mentioned earlier, data is stored in files, and these files are relative to `STORAGEDIR` (compiled into the programs or specified as an option). In particular, the following directory structure can exist, whereby directories are created as needed by the _recorder_:
|
||||
|
||||
* `cards/`, optional, contain user cards.
|
||||
* `ghash/`, unless disabled, reverse Geo data is collected in files named after the geohash in directories named with the first three characters of the geohash.
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
/*
|
||||
* This is the top-level directory you create; ot-recorder
|
||||
* stores files below this hierarchy and creates directories
|
||||
* therin by itself. Note that the user running `ot-recorder'
|
||||
* must be granted write access (rwx)
|
||||
*/
|
||||
|
||||
#define STORAGEDIR "/path/to/store"
|
||||
|
||||
/*
|
||||
* 1 => 5,009.4km x 4,992.6km
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <time.h>
|
||||
#include "udata.h"
|
||||
|
||||
extern char STORAGEDIR[];
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE (1)
|
||||
# define FALSE (0)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "json.h"
|
||||
#include "storage.h"
|
||||
#include "util.h"
|
||||
#include "misc.h"
|
||||
|
||||
typedef enum {
|
||||
TABULAR = 0,
|
||||
@@ -123,6 +124,7 @@ void usage(char *prog)
|
||||
printf(" tabular\n");
|
||||
printf(" --last -L JSON object with last users\n");
|
||||
printf(" --killdata requires -u and -d\n");
|
||||
printf(" --storage -S storage dir (./store)\n");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
@@ -154,6 +156,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if ((p = getenv("OCAT_STORAGEDIR")) != NULL) {
|
||||
strcpy(STORAGEDIR, p);
|
||||
}
|
||||
|
||||
time(&now);
|
||||
|
||||
while (1) {
|
||||
@@ -165,6 +171,7 @@ int main(int argc, char **argv)
|
||||
{ "from", required_argument, 0, 'F'},
|
||||
{ "to", required_argument, 0, 'T'},
|
||||
{ "format", required_argument, 0, 'f'},
|
||||
{ "storage", required_argument, 0, 'S'},
|
||||
{ "last", no_argument, 0, 'L'},
|
||||
{ "killdata", no_argument, 0, 'K'},
|
||||
{0, 0, 0, 0}
|
||||
@@ -188,6 +195,9 @@ int main(int argc, char **argv)
|
||||
case 'F':
|
||||
time_from = strdup(optarg);
|
||||
break;
|
||||
case 'S':
|
||||
strcpy(STORAGEDIR, optarg);
|
||||
break;
|
||||
case 'T':
|
||||
time_to = strdup(optarg);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user