]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - nixops/modules/websites/tools/tools/wallabag.nix
Move cache clearing of php applications to preStart systemd
[perso/Immae/Config/Nix.git] / nixops / modules / websites / tools / tools / wallabag.nix
index 0cacad329762b0bbb9fdb9f2f2b878e033f3f5a0..f145bf332cf748345d5c750ba8a7ceac89fd494f 100644 (file)
@@ -119,15 +119,6 @@ let
     activationScript = ''
       install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
         ${varDir}/var ${varDir}/data/db ${varDir}/assets/images
-      if [ ! -f "${varDir}/currentWebappDir" -o \
-          "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
-        pushd ${webappDir} > /dev/null
-        $wrapperDir/sudo -u wwwrun ./bin/console --env=prod cache:clear
-        rm -rf /var/lib/wallabag/var/cache/pro_
-        $wrapperDir/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction
-        popd > /dev/null
-        echo -n "${webappDir}" > ${varDir}/currentWebappDir
-      fi
       '';
     webRoot = "${webappDir}/web";
     # Domain migration: Table wallabag_entry contains whole
@@ -169,6 +160,20 @@ let
         '';
     };
     phpFpm = rec {
+      preStart = ''
+        if [ ! -f "${varDir}/currentWebappDir" -o \
+            ! -f "${varDir}/currentKey" -o \
+            "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \
+            || ! sha512sum -c --status ${varDir}/currentKey; then
+          pushd ${webappDir} > /dev/null
+          /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod cache:clear
+          rm -rf /var/lib/wallabag/var/cache/pro_
+          /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction
+          popd > /dev/null
+          echo -n "${webappDir}" > ${varDir}/currentWebappDir
+          sha512sum /run/keys/webapps/tools-wallabag > ${varDir}/currentKey
+        fi
+        '';
       serviceDeps = [ "postgresql.service" "openldap.service" "tools-wallabag-key.service" ];
       basedir = builtins.concatStringsSep ":" [ webappDir "/run/keys/webapps/tools-wallabag" varDir ];
       socket = "/var/run/phpfpm/wallabag.sock";