diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-06-01 12:22:13 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-06-01 12:22:13 +0200 |
commit | 4360f70d7a9966593d9e04043fa0a75defc094e0 (patch) | |
tree | 57e7a062754c823c9f91f13742b9b7de08937097 | |
parent | 02d6e977e309355ae728422e26063090e8a2f193 (diff) | |
download | Nix-4360f70d7a9966593d9e04043fa0a75defc094e0.tar.gz Nix-4360f70d7a9966593d9e04043fa0a75defc094e0.tar.zst Nix-4360f70d7a9966593d9e04043fa0a75defc094e0.zip |
Add phpFpm prestart script to lib
-rw-r--r-- | lib/private/default.nix | 13 | ||||
-rw-r--r-- | modules/private/websites/aten/builder.nix | 24 | ||||
-rw-r--r-- | modules/private/websites/connexionswing/builder.nix | 24 | ||||
-rw-r--r-- | modules/private/websites/florian/builder_app.nix | 24 | ||||
-rw-r--r-- | modules/private/websites/ludivinecassal/builder.nix | 24 | ||||
-rw-r--r-- | modules/private/websites/piedsjaloux/builder.nix | 24 | ||||
-rw-r--r-- | modules/private/websites/tools/tools/wallabag.nix | 28 |
7 files changed, 81 insertions, 80 deletions
diff --git a/lib/private/default.nix b/lib/private/default.nix index c7d753a..b04f7b3 100644 --- a/lib/private/default.nix +++ b/lib/private/default.nix | |||
@@ -17,4 +17,17 @@ | |||
17 | echo | 17 | echo |
18 | } | 18 | } |
19 | ''; | 19 | ''; |
20 | |||
21 | phpFpmPreStart = { app, varDir, keyFiles, actions }: '' | ||
22 | if [ ! -f "${varDir}/currentWebappDir" -o \ | ||
23 | ! -f "${varDir}/currentKey" -o \ | ||
24 | "${app}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \ | ||
25 | || ! sha512sum -c --status ${varDir}/currentKey; then | ||
26 | pushd ${app} > /dev/null | ||
27 | ${builtins.concatStringsSep "\n " actions} | ||
28 | popd > /dev/null | ||
29 | echo -n "${app}" > ${varDir}/currentWebappDir | ||
30 | sha512sum ${builtins.concatStringsSep " " keyFiles} > ${varDir}/currentKey | ||
31 | fi | ||
32 | ''; | ||
20 | } | 33 | } |
diff --git a/modules/private/websites/aten/builder.nix b/modules/private/websites/aten/builder.nix index 9a2e1a7..83a8f70 100644 --- a/modules/private/websites/aten/builder.nix +++ b/modules/private/websites/aten/builder.nix | |||
@@ -1,18 +1,16 @@ | |||
1 | { apacheUser, apacheGroup, aten, lib, config }: rec { | 1 | { apacheUser, apacheGroup, aten, lib, mylibs, config }: rec { |
2 | app = aten.override { inherit (config) environment; }; | 2 | app = aten.override { inherit (config) environment; }; |
3 | phpFpm = rec { | 3 | phpFpm = rec { |
4 | preStart = '' | 4 | preStart = mylibs.phpFpmPreStart { |
5 | if [ ! -f "${app.varDir}/currentWebappDir" -o \ | 5 | inherit app; |
6 | ! -f "${app.varDir}/currentKey" -o \ | 6 | inherit (app) varDir; |
7 | "${app}" != "$(cat ${app.varDir}/currentWebappDir 2>/dev/null)" ] \ | 7 | keyFiles = [ |
8 | || ! sha512sum -c --status ${app.varDir}/currentKey; then | 8 | "/var/secrets/webapps/${app.environment}-aten" |
9 | pushd ${app} > /dev/null | 9 | ]; |
10 | /run/wrappers/bin/sudo -u ${apacheUser} APP_ENV=${app.environment} ./bin/console --env=${app.environment} cache:clear --no-warmup | 10 | actions = [ |
11 | popd > /dev/null | 11 | "/run/wrappers/bin/sudo -u ${apacheUser} APP_ENV=${app.environment} ./bin/console --env=${app.environment} cache:clear --no-warmup" |
12 | echo -n "${app}" > ${app.varDir}/currentWebappDir | 12 | ]; |
13 | sha512sum /var/secrets/webapps/${app.environment}-aten > ${app.varDir}/currentKey | 13 | }; |
14 | fi | ||
15 | ''; | ||
16 | serviceDeps = [ "postgresql.service" ]; | 14 | serviceDeps = [ "postgresql.service" ]; |
17 | socket = "/var/run/phpfpm/aten-${app.environment}.sock"; | 15 | socket = "/var/run/phpfpm/aten-${app.environment}.sock"; |
18 | pool = '' | 16 | pool = '' |
diff --git a/modules/private/websites/connexionswing/builder.nix b/modules/private/websites/connexionswing/builder.nix index b4b04cb..004b979 100644 --- a/modules/private/websites/connexionswing/builder.nix +++ b/modules/private/websites/connexionswing/builder.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { apacheUser, apacheGroup, connexionswing, pkgs, phpPackages, config }: | 1 | { apacheUser, apacheGroup, connexionswing, pkgs, phpPackages, mylibs, config }: |
2 | rec { | 2 | rec { |
3 | app = connexionswing.override { inherit (config) environment; }; | 3 | app = connexionswing.override { inherit (config) environment; }; |
4 | keys = [{ | 4 | keys = [{ |
@@ -31,18 +31,16 @@ rec { | |||
31 | ''; | 31 | ''; |
32 | }]; | 32 | }]; |
33 | phpFpm = rec { | 33 | phpFpm = rec { |
34 | preStart = '' | 34 | preStart = mylibs.phpFpmPreStart { |
35 | if [ ! -f "${app.varDir}/currentWebappDir" -o \ | 35 | inherit app; |
36 | ! -f "${app.varDir}/currentKey" -o \ | 36 | inherit (app) varDir; |
37 | "${app}" != "$(cat ${app.varDir}/currentWebappDir 2>/dev/null)" ] \ | 37 | keyFiles = [ |
38 | || ! sha512sum -c --status ${app.varDir}/currentKey; then | 38 | "/var/secrets/webapps/${app.environment}-connexionswing" |
39 | pushd ${app} > /dev/null | 39 | ]; |
40 | /run/wrappers/bin/sudo -u ${apacheUser} ./bin/console --env=${app.environment} cache:clear --no-warmup | 40 | actions = [ |
41 | popd > /dev/null | 41 | "/run/wrappers/bin/sudo -u ${apacheUser} ./bin/console --env=${app.environment} cache:clear --no-warmup" |
42 | echo -n "${app}" > ${app.varDir}/currentWebappDir | 42 | ]; |
43 | sha512sum /var/secrets/webapps/${app.environment}-connexionswing > ${app.varDir}/currentKey | 43 | }; |
44 | fi | ||
45 | ''; | ||
46 | serviceDeps = [ "mysql.service" ]; | 44 | serviceDeps = [ "mysql.service" ]; |
47 | socket = "/var/run/phpfpm/connexionswing-${app.environment}.sock"; | 45 | socket = "/var/run/phpfpm/connexionswing-${app.environment}.sock"; |
48 | phpConfig = '' | 46 | phpConfig = '' |
diff --git a/modules/private/websites/florian/builder_app.nix b/modules/private/websites/florian/builder_app.nix index e521f6e..c12663a 100644 --- a/modules/private/websites/florian/builder_app.nix +++ b/modules/private/websites/florian/builder_app.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { apacheUser, apacheGroup, tellesflorian, config }: | 1 | { apacheUser, apacheGroup, tellesflorian, mylibs, config }: |
2 | rec { | 2 | rec { |
3 | app = tellesflorian.override { inherit (config) environment; }; | 3 | app = tellesflorian.override { inherit (config) environment; }; |
4 | keys = [ | 4 | keys = [ |
@@ -33,18 +33,16 @@ rec { | |||
33 | } | 33 | } |
34 | ]; | 34 | ]; |
35 | phpFpm = rec { | 35 | phpFpm = rec { |
36 | preStart = '' | 36 | preStart = mylibs.phpFpmPreStart { |
37 | if [ ! -f "${app.varDir}/currentWebappDir" -o \ | 37 | inherit app; |
38 | ! -f "${app.varDir}/currentKey" -o \ | 38 | inherit (app) varDir; |
39 | "${app}" != "$(cat ${app.varDir}/currentWebappDir 2>/dev/null)" ] \ | 39 | keyFiles = [ |
40 | || ! sha512sum -c --status ${app.varDir}/currentKey; then | 40 | "/var/secrets/webapps/${app.environment}-tellesflorian" |
41 | pushd ${app} > /dev/null | 41 | ]; |
42 | /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=${app.environment} cache:clear --no-warmup | 42 | actions = [ |
43 | popd > /dev/null | 43 | "/run/wrappers/bin/sudo -u wwwrun ./bin/console --env=${app.environment} cache:clear --no-warmup" |
44 | echo -n "${app}" > ${app.varDir}/currentWebappDir | 44 | ]; |
45 | sha512sum /var/secrets/webapps/${app.environment}-tellesflorian > ${app.varDir}/currentKey | 45 | }; |
46 | fi | ||
47 | ''; | ||
48 | serviceDeps = [ "mysql.service" ]; | 46 | serviceDeps = [ "mysql.service" ]; |
49 | socket = "/var/run/phpfpm/floriantelles-${app.environment}.sock"; | 47 | socket = "/var/run/phpfpm/floriantelles-${app.environment}.sock"; |
50 | pool = '' | 48 | pool = '' |
diff --git a/modules/private/websites/ludivinecassal/builder.nix b/modules/private/websites/ludivinecassal/builder.nix index 3167bce..e2a0f19 100644 --- a/modules/private/websites/ludivinecassal/builder.nix +++ b/modules/private/websites/ludivinecassal/builder.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { apacheUser, apacheGroup, config, ludivinecassal, pkgs, ruby, sass, imagemagick }: | 1 | { apacheUser, apacheGroup, config, ludivinecassal, mylibs, pkgs, ruby, sass, imagemagick }: |
2 | rec { | 2 | rec { |
3 | app = ludivinecassal.override { inherit (config) environment; }; | 3 | app = ludivinecassal.override { inherit (config) environment; }; |
4 | varDir = "/var/lib/ludivinecassal_${app.environment}"; | 4 | varDir = "/var/lib/ludivinecassal_${app.environment}"; |
@@ -39,18 +39,16 @@ rec { | |||
39 | ''; | 39 | ''; |
40 | }]; | 40 | }]; |
41 | phpFpm = rec { | 41 | phpFpm = rec { |
42 | preStart = '' | 42 | preStart = mylibs.phpFpmPreStart { |
43 | if [ ! -f "${app.varDir}/currentWebappDir" -o \ | 43 | inherit app; |
44 | ! -f "${app.varDir}/currentKey" -o \ | 44 | inherit (app) varDir; |
45 | "${app}" != "$(cat ${app.varDir}/currentWebappDir 2>/dev/null)" ] \ | 45 | keyFiles = [ |
46 | || ! sha512sum -c --status ${app.varDir}/currentKey; then | 46 | "/var/secrets/webapps/${app.environment}-ludivinecassal" |
47 | pushd ${app} > /dev/null | 47 | ]; |
48 | /run/wrappers/bin/sudo -u ${apacheUser} ./bin/console --env=${app.environment} cache:clear --no-warmup | 48 | actions = [ |
49 | popd > /dev/null | 49 | "/run/wrappers/bin/sudo -u ${apacheUser} ./bin/console --env=${app.environment} cache:clear --no-warmup" |
50 | echo -n "${app}" > ${app.varDir}/currentWebappDir | 50 | ]; |
51 | sha512sum /var/secrets/webapps/${app.environment}-ludivinecassal > ${app.varDir}/currentKey | 51 | }; |
52 | fi | ||
53 | ''; | ||
54 | serviceDeps = [ "mysql.service" ]; | 52 | serviceDeps = [ "mysql.service" ]; |
55 | socket = "/var/run/phpfpm/ludivinecassal-${app.environment}.sock"; | 53 | socket = "/var/run/phpfpm/ludivinecassal-${app.environment}.sock"; |
56 | pool = '' | 54 | pool = '' |
diff --git a/modules/private/websites/piedsjaloux/builder.nix b/modules/private/websites/piedsjaloux/builder.nix index 9fcc8fb..d9a78b3 100644 --- a/modules/private/websites/piedsjaloux/builder.nix +++ b/modules/private/websites/piedsjaloux/builder.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { apacheUser, apacheGroup, piedsjaloux, config, pkgs, lib, texlive, imagemagick }: | 1 | { apacheUser, apacheGroup, piedsjaloux, config, pkgs, lib, mylibs, texlive, imagemagick }: |
2 | rec { | 2 | rec { |
3 | app = piedsjaloux.override { inherit (config) environment; }; | 3 | app = piedsjaloux.override { inherit (config) environment; }; |
4 | varDir = "/var/lib/piedsjaloux_${app.environment}"; | 4 | varDir = "/var/lib/piedsjaloux_${app.environment}"; |
@@ -27,18 +27,16 @@ rec { | |||
27 | ''; | 27 | ''; |
28 | }]; | 28 | }]; |
29 | phpFpm = rec { | 29 | phpFpm = rec { |
30 | preStart = '' | 30 | preStart = mylibs.phpFpmPreStart { |
31 | if [ ! -f "${app.varDir}/currentWebappDir" -o \ | 31 | inherit app; |
32 | ! -f "${app.varDir}/currentKey" -o \ | 32 | inherit (app) varDir; |
33 | "${app}" != "$(cat ${app.varDir}/currentWebappDir 2>/dev/null)" ] \ | 33 | keyFiles = [ |
34 | || ! sha512sum -c --status ${app.varDir}/currentKey; then | 34 | "/var/secrets/webapps/${app.environment}-piedsjaloux" |
35 | pushd ${app} > /dev/null | 35 | ]; |
36 | /run/wrappers/bin/sudo -u ${apacheUser} ./bin/console --env=${app.environment} cache:clear --no-warmup | 36 | actions = [ |
37 | popd > /dev/null | 37 | "/run/wrappers/bin/sudo -u ${apacheUser} ./bin/console --env=${app.environment} cache:clear --no-warmup" |
38 | echo -n "${app}" > ${app.varDir}/currentWebappDir | 38 | ]; |
39 | sha512sum /var/secrets/webapps/${app.environment}-piedsjaloux > ${app.varDir}/currentKey | 39 | }; |
40 | fi | ||
41 | ''; | ||
42 | serviceDeps = [ "mysql.service" ]; | 40 | serviceDeps = [ "mysql.service" ]; |
43 | socket = "/var/run/phpfpm/piedsjaloux-${app.environment}.sock"; | 41 | socket = "/var/run/phpfpm/piedsjaloux-${app.environment}.sock"; |
44 | pool = '' | 42 | pool = '' |
diff --git a/modules/private/websites/tools/tools/wallabag.nix b/modules/private/websites/tools/tools/wallabag.nix index d6e5882..ba755e4 100644 --- a/modules/private/websites/tools/tools/wallabag.nix +++ b/modules/private/websites/tools/tools/wallabag.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { env, wallabag }: | 1 | { env, wallabag, mylibs }: |
2 | rec { | 2 | rec { |
3 | varDir = "/var/lib/wallabag"; | 3 | varDir = "/var/lib/wallabag"; |
4 | keys = [{ | 4 | keys = [{ |
@@ -110,20 +110,18 @@ rec { | |||
110 | ''; | 110 | ''; |
111 | }; | 111 | }; |
112 | phpFpm = rec { | 112 | phpFpm = rec { |
113 | preStart = '' | 113 | preStart = mylibs.phpFpmPreStart { |
114 | if [ ! -f "${varDir}/currentWebappDir" -o \ | 114 | app = webappDir; |
115 | ! -f "${varDir}/currentKey" -o \ | 115 | inherit varDir; |
116 | "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \ | 116 | keyFiles = [ |
117 | || ! sha512sum -c --status ${varDir}/currentKey; then | 117 | "/var/secrets/webapps/tools-wallabag" |
118 | pushd ${webappDir} > /dev/null | 118 | ]; |
119 | /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod cache:clear | 119 | actions = [ |
120 | rm -rf /var/lib/wallabag/var/cache/pro_ | 120 | "/run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod cache:clear" |
121 | /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction | 121 | "rm -rf /var/lib/wallabag/var/cache/pro_" |
122 | popd > /dev/null | 122 | "/run/wrappers/bin/sudo -u wwwrun ./bin/console --env=prod doctrine:migrations:migrate --no-interaction" |
123 | echo -n "${webappDir}" > ${varDir}/currentWebappDir | 123 | ]; |
124 | sha512sum /var/secrets/webapps/tools-wallabag > ${varDir}/currentKey | 124 | }; |
125 | fi | ||
126 | ''; | ||
127 | serviceDeps = [ "postgresql.service" "openldap.service" ]; | 125 | serviceDeps = [ "postgresql.service" "openldap.service" ]; |
128 | basedir = builtins.concatStringsSep ":" [ webappDir "/var/secrets/webapps/tools-wallabag" varDir ]; | 126 | basedir = builtins.concatStringsSep ":" [ webappDir "/var/secrets/webapps/tools-wallabag" varDir ]; |
129 | socket = "/var/run/phpfpm/wallabag.sock"; | 127 | socket = "/var/run/phpfpm/wallabag.sock"; |