]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - virtual/eldiron.nix
Try to fix goaccess cron not running
[perso/Immae/Config/Nix.git] / virtual / eldiron.nix
index 3f2ba27886f188a9712cdacdced60c79789ce7ba..b9dba3f79b3d91ba3ccf3f4dc28257c9e7209858 100644 (file)
@@ -8,7 +8,7 @@
     with import ../libs.nix;
     let
         mypkgs = pkgs.callPackage ./packages.nix {
-          inherit checkEnv fetchedGitPrivate fetchedGithub;
+          inherit checkEnv fetchedGit fetchedGitPrivate fetchedGithub;
         };
     in
   {
         '';
     in [
       pkgs.telnet
+      pkgs.htop
       pkgs.vim
       pkgs.goaccess
       occ
     ];
 
+    # FIXME: doesn't work with httpd?
+    security.acme.preliminarySelfsigned = true;
     security.acme.certs = {
-      # /!\ To create a new certificate, add first the domain to an
-      # existing certificate, deploy, and then use it in httpd.
+      # FIXME: /!\ To create a new certificate, create it before using
+      # it in httpd
       "eldiron" = {
         webroot = "/var/lib/acme/acme-challenge";
         email = "ismael@bouya.org";
         postRun = ''
           systemctl reload httpd.service
         '';
+        allowKeysForGroup = true;
         extraDomains = {
           "db-1.immae.eu" = null;
           "git.immae.eu" = null;
           "www.piedsjaloux.fr" = null;
         };
       };
-      # "connexionswing" = {
-      #   webroot = "/var/lib/acme/acme-challenge";
-      #   email = "ismael@bouya.org";
-      #   domain = "connexionswing.com";
-      #   plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ];
-      #   postRun = ''
-      #     systemctl reload httpd.service
-      #   '';
-      #   extraDomains = {
-      #     "www.connexionswing.com" = null;
-      #     "sandetludo.com" = null;
-      #     "www.sandetludo.com" = null;
-      #   };
-      # };
+      "chloe" = {
+        webroot = "/var/lib/acme/acme-challenge";
+        email = "ismael@bouya.org";
+        domain = "osteopathe-cc.fr";
+        plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ];
+        postRun = ''
+          systemctl reload httpd.service
+        '';
+        extraDomains = {
+          "www.osteopathe-cc.fr" = null;
+        };
+      };
+      "connexionswing" = {
+        webroot = "/var/lib/acme/acme-challenge";
+        email = "ismael@bouya.org";
+        domain = "connexionswing.com";
+        plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ];
+        postRun = ''
+          systemctl reload httpd.service
+        '';
+        extraDomains = {
+          "www.connexionswing.com" = null;
+          "sandetludo.com" = null;
+          "www.sandetludo.com" = null;
+        };
+      };
     };
 
     services.openssh.extraConfig = ''
       adminPubkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXqRbiHw7QoHADNIEuo4nUT9fSOIEBMdJZH0bkQAxXyJFyCM1IMz0pxsHV0wu9tdkkr36bPEUj2aV5bkYLBN6nxcV2Y49X8bjOSCPfx3n6Own1h+NeZVBj4ZByrFmqCbTxUJIZ2bZKcWOFncML39VmWdsVhNjg0X4NBBehqXRIKr2gt3E/ESAxTYJFm0BnU0baciw9cN0bsRGqvFgf5h2P48CIAfwhVcGmPQnnAwabnosYQzRWxR0OygH5Kd8mePh6FheIRIigfXsDO8f/jdxwut8buvNIf3m5EBr3tUbTsvM+eV3M5vKGt7sk8T64DVtepTSdOOWtp+47ktsnHOMh immae@immae.eu";
     };
 
-    services.ympd = mypkgs.ympd.config // { enable = true; };
+    services.ympd = mypkgs.ympd.config // { enable = false; };
 
     services.phpfpm = {
+      # FIXME: move session files to separate dirs
       # /!\ phppackage is used in nextcloud configuation
       phpOptions = ''
+        session.save_path = "/var/lib/php/sessions"
+        session.gc_maxlifetime = 60*60*24*15
+        session.cache_expire = 60*24*30
         ; For nextcloud
         extension=${pkgs.phpPackages.redis}/lib/php/extensions/redis.so
         ; For nextcloud
         aten_prod = mypkgs.aten_prod.phpFpm.pool;
         nextcloud = mypkgs.nextcloud.phpFpm.pool;
         mantisbt = mypkgs.mantisbt.phpFpm.pool;
+        ttrss = mypkgs.ttrss.phpFpm.pool;
+        roundcubemail = mypkgs.roundcubemail.phpFpm.pool;
       };
     };
 
       aten_dev  = mypkgs.aten_dev.activationScript;
       aten_prod = mypkgs.aten_prod.activationScript;
       nextcloud = mypkgs.nextcloud.activationScript;
+      ttrss = mypkgs.ttrss.activationScript;
+      roundcubemail = mypkgs.roundcubemail.activationScript;
       httpd = ''
         install -d -m 0755 /var/lib/acme/acme-challenge
+        install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions
+        install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions/adminer
+        install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions/mantisbt
+        install -d -m 0750 -o wwwrun -g wwwrun /var/lib/php/sessions/ttrss
         '';
       redis = ''
         mkdir -p /run/redis
           fi
         '';
       };
+      # FIXME: initial sync
       goaccess = ''
         mkdir -p /var/lib/goaccess
         mkdir -p /var/lib/goaccess/aten.pro
         mkdir -p /var/lib/goaccess/ludivinecassal.com
         mkdir -p /var/lib/goaccess/piedsjaloux.fr
+        mkdir -p /var/lib/goaccess/osteopathe-cc.fr
+        mkdir -p /var/lib/goaccess/connexionswing.com
         '';
     };
 
       basePath = "${mypkgs.git.web.varDir}/repositories";
     };
 
+    # FIXME: logrotate
     services.httpd = let
       withConf = domain: {
         enableSSL = true;
         mypkgs.ympd.apache.modules ++
         mypkgs.git.web.apache.modules ++
         mypkgs.mantisbt.apache.modules ++
+        mypkgs.ttrss.apache.modules ++
+        mypkgs.roundcubemail.apache.modules ++
         pkgs.lib.lists.flatten (pkgs.lib.attrsets.mapAttrsToList (n: v: v.modules) apacheConfig) ++
         [ "macro" ]);
       extraConfig = builtins.concatStringsSep "\n"
           extraConfig = builtins.concatStringsSep "\n" [
             mypkgs.adminer.apache.vhostConf
             mypkgs.ympd.apache.vhostConf
+            mypkgs.ttrss.apache.vhostConf
+            mypkgs.roundcubemail.apache.vhostConf
           ];
         })
         (withConf "eldiron" // {
             mypkgs.connexionswing_dev.apache.vhostConf
           ];
         })
+        (withConf "connexionswing" // {
+          hostName = "connexionswing.com";
+          serverAliases = [ "sandetludo.com" "www.connexionswing.com" "www.sandetludo.com" ];
+          documentRoot = mypkgs.connexionswing_prod.webRoot;
+          extraConfig = builtins.concatStringsSep "\n" [
+            mypkgs.connexionswing_prod.apache.vhostConf
+          ];
+        })
         (withConf "eldiron" // {
           hostName = "ludivine.immae.eu";
           documentRoot = mypkgs.ludivinecassal_dev.webRoot;
             mypkgs.chloe_dev.apache.vhostConf
           ];
         })
-        (withConf "eldiron" // {
+        (withConf "chloe" // {
           hostName = "osteopathe-cc.fr";
           serverAliases = [ "www.osteopathe-cc.fr" ];
           documentRoot = mypkgs.chloe_prod.webRoot;
     ];
 
     # FIXME: backup
+    # Nextcloud: 14
     services.redis = rec {
       enable = true;
       bind = "127.0.0.1";
     services.cron = {
       enable = true;
       systemCronJobs = let
-        stats = domain: conf: "${pkgs.gnused}/bin/sed -n '/\\['$(LC_ALL=C ${pkgs.coreutils}/bin/date -d yesterday +'%d\\/%b\\/%Y')'/ p' /var/log/httpd/access_log-${domain} | ${pkgs.goaccess}/bin/goaccess -o /var/lib/goaccess/${domain}/index.html -p ${conf}";
+        stats = domain: conf: let
+          d = pkgs.writeScriptBin "stats-${domain}" "${pkgs.gnused}/bin/sed -n '/\\['$(LC_ALL=C ${pkgs.coreutils}/bin/date -d yesterday +'%d\\/%b\\/%Y')'/ p' /var/log/httpd/access_log-${domain} | ${pkgs.goaccess}/bin/goaccess -o /var/lib/goaccess/${domain}/index.html -p ${conf}";
+          in "${d}/bin/stats-${domain}";
+      # FIXME: running several goaccess simultaneously seems to be
+      # bugged?
       in [
         "5 0 * * * root ${stats "aten.pro" ./packages/aten_goaccess.conf}"
-        "5 0 * * * root ${stats "ludivinecassal.com" ./packages/ludivinecassal_goaccess.conf}"
-        "5 0 * * * root ${stats "piedsjaloux.fr" ./packages/piedsjaloux_goaccess.conf}"
+        "6 0 * * * root ${stats "ludivinecassal.com" ./packages/ludivinecassal_goaccess.conf}"
+        "7 0 * * * root ${stats "piedsjaloux.fr" ./packages/piedsjaloux_goaccess.conf}"
+        "8 0 * * * root ${stats "osteopathe-cc.fr" ./packages/chloe_goaccess.conf}"
+        "9 0 * * * root ${stats "connexionswing.com" ./packages/connexionswing_goaccess.conf}"
         ];
     };
+
+    systemd.services.tt-rss = {
+      description = "Tiny Tiny RSS feeds update daemon";
+      serviceConfig = {
+        User = "wwwrun";
+        ExecStart = "${pkgs.php}/bin/php ${mypkgs.ttrss.webRoot}/update.php --daemon";
+        StandardOutput = "syslog";
+        StandardError = "syslog";
+        PermissionsStartOnly = true;
+      };
+
+      wantedBy = [ "multi-user.target" ];
+      requires = ["postgresql.service"];
+      after = ["network.target" "postgresql.service"];
+    };
   };
 }