-{ lib, pkgs, config, mylibs, ... }:
+{ lib, pkgs, config, ... }:
let
name = "goaccess";
cfg = config.services.webstats;
'';
};
name = lib.mkOption {
- type = lib.types.string;
+ type = lib.types.str;
description = ''
Domain name. Corresponds to the Apache file name and the
folder name in which the state will be saved.
};
config = lib.mkIf (builtins.length cfg.sites > 0) {
+ services.duplyBackup.profiles.goaccess = {
+ rootDir = cfg.dataDir;
+ };
users.users.root.packages = [
pkgs.goaccess
];
#!${pkgs.stdenv.shell}
set -e
shopt -s nullglob
- date_regex=$(LC_ALL=C date -d yesterday +'%d\/%b\/%Y')
TMPFILE=$(mktemp)
trap "rm -f $TMPFILE" EXIT
mkdir -p ${cfg.dataDir}/${domain}
- cat /var/log/httpd/access-${domain}.log | sed -n "/\\[$date_regex/ p" > $TMPFILE
for i in /var/log/httpd/access-${domain}*.gz; do
- zcat "$i" | sed -n "/\\[$date_regex/ p" >> $TMPFILE
+ zcat "$i" >> $TMPFILE
done
+ cat /var/log/httpd/access-${domain}.log > $TMPFILE
${pkgs.goaccess}/bin/goaccess $TMPFILE --no-progress -o ${cfg.dataDir}/${domain}/index.html -p ${config}
'';
in "${d}/bin/stats-${domain}";