From 1a64deeb894dc95e2645a75771732c6cc53a79ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Wed, 4 Oct 2023 01:35:06 +0200 Subject: Squash changes containing private information There were a lot of changes since the previous commit, but a lot of them contained personnal information about users. All thos changes got stashed into a single commit (history is kept in a different place) and private information was moved in a separate private repository --- modules/webapps/webstats/default.nix | 80 ------------------------------------ 1 file changed, 80 deletions(-) delete mode 100644 modules/webapps/webstats/default.nix (limited to 'modules/webapps/webstats/default.nix') diff --git a/modules/webapps/webstats/default.nix b/modules/webapps/webstats/default.nix deleted file mode 100644 index e873af2..0000000 --- a/modules/webapps/webstats/default.nix +++ /dev/null @@ -1,80 +0,0 @@ -{ lib, pkgs, config, ... }: -let - name = "goaccess"; - cfg = config.services.webstats; -in { - options.services.webstats = { - dataDir = lib.mkOption { - type = lib.types.path; - default = "/var/lib/${name}"; - description = '' - The directory where Goaccess stores its data. - ''; - }; - sites = lib.mkOption { - type = lib.types.listOf (lib.types.submodule { - options = { - conf = lib.mkOption { - type = lib.types.nullOr lib.types.path; - default = null; - description = '' - use custom goaccess configuration file instead of the - default one. - ''; - }; - name = lib.mkOption { - type = lib.types.str; - description = '' - Domain name. Corresponds to the Apache file name and the - folder name in which the state will be saved. - ''; - }; - }; - }); - default = []; - description = "Sites to generate stats"; - }; - }; - - config = lib.mkIf (builtins.length cfg.sites > 0) { - users.users.root.packages = [ - pkgs.goaccess - ]; - - services.cron = { - enable = true; - systemCronJobs = let - stats = domain: conf: let - config = if builtins.isNull conf - then pkgs.runCommand "goaccess.conf" { - dbPath = "${cfg.dataDir}/${domain}"; - } "substituteAll ${./goaccess.conf} $out" - else conf; - d = pkgs.writeScriptBin "stats-${domain}" '' - #!${pkgs.stdenv.shell} - set -e - shopt -s nullglob - TMPFILE=$(mktemp) - trap "rm -f $TMPFILE" EXIT - - mkdir -p ${cfg.dataDir}/${domain} - for i in /var/log/httpd/access-${domain}*.gz; do - 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}"; - allStats = sites: pkgs.writeScript "stats" '' - #!${pkgs.stdenv.shell} - - mkdir -p ${cfg.dataDir} - ${builtins.concatStringsSep "\n" (map (v: stats v.name v.conf) sites)} - ''; - in - [ - "5 0 * * * root ${allStats cfg.sites}" - ]; - }; - }; -} -- cgit v1.2.3