]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add surveillance for papa
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 1 May 2019 11:49:37 +0000 (13:49 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 1 May 2019 13:44:24 +0000 (15:44 +0200)
nixops/modules/websites/default.nix
nixops/modules/websites/ftp/papa.nix [new file with mode: 0644]

index b0bc7a43c104e36b6d6e369245d40c1deacd9297..6a0a19fe32f8ebcacee0032b9ead1c0442c00ad2 100644 (file)
@@ -117,6 +117,7 @@ in
     ./ftp/florian.nix
     ./ftp/denisejerome.nix
     ./ftp/leila.nix
+    ./ftp/papa.nix
     ./ftp/immae.nix
     ./ftp/release.nix
     ./ftp/temp.nix
@@ -214,6 +215,7 @@ in
     services.myWebsites.Nassime.production.enable = cfg.production.enable;
     services.myWebsites.Florian.production.enable = cfg.production.enable;
     services.myWebsites.Leila.production.enable = cfg.production.enable;
+    services.myWebsites.Papa.production.enable = cfg.production.enable;
     services.myWebsites.DeniseJerome.production.enable = cfg.production.enable;
     services.myWebsites.Emilia.production.enable = cfg.production.enable;
     services.myWebsites.Capitaines.production.enable = cfg.production.enable;
diff --git a/nixops/modules/websites/ftp/papa.nix b/nixops/modules/websites/ftp/papa.nix
new file mode 100644 (file)
index 0000000..ca1aabe
--- /dev/null
@@ -0,0 +1,55 @@
+{ lib, pkgs, config, myconfig, mylibs, ... }:
+let
+    cfg = config.services.myWebsites.Papa;
+    varDir = "/var/lib/ftp/papa";
+in {
+  options.services.myWebsites.Papa = {
+    production = {
+      enable = lib.mkEnableOption "enable Papa's website";
+    };
+  };
+
+  config = lib.mkIf cfg.production.enable {
+    security.acme.certs."ftp".extraDomains."surveillance.maison.bbc.bouya.org" = null;
+    security.acme.certs."papa" = config.services.myCertificates.certConfig // {
+      domain = "surveillance.maison.bbc.bouya.org";
+    };
+
+    services.cron = {
+      systemCronJobs = let
+        script = pkgs.writeScript "cleanup-papa" ''
+          #!${pkgs.stdenv.shell}
+          d=$(date -d "7 days ago" +%Y%m%d)
+          for i in /var/lib/ftp/papa/*/20[0-9][0-9][0-9][0-9][0-9][0-9]; do
+            if [ "$d" -gt $(basename $i) ]; then
+              rm -rf "$i"
+            fi
+          done
+          '';
+      in
+        [
+        ''
+          0 6 * * * wwwrun ${script}
+        ''
+      ];
+    };
+
+    services.myWebsites.production.vhostConfs.papa = {
+      certName    = "papa";
+      hosts       = [ "surveillance.maison.bbc.bouya.org" ];
+      root        = varDir;
+      extraConfig = [
+        ''
+        Use Apaxy "${varDir}" "title .duplicity-ignore"
+        <Directory ${varDir}>
+          Use LDAPConnect
+          Options Indexes
+          AllowOverride None
+          Require ldap-group   cn=surveillance.maison.bbc.bouya.org,cn=httpd,ou=services,dc=immae,dc=eu
+        </Directory>
+          ''
+      ];
+    };
+  };
+}
+