m 2 nginx/euer*: prepare folders if they do not exist
This commit is contained in:
parent
699822f572
commit
f02a96efb2
@ -5,14 +5,40 @@ let
|
|||||||
sec = toString <secrets>;
|
sec = toString <secrets>;
|
||||||
ssl_cert = "${sec}/wildcard.krebsco.de.crt";
|
ssl_cert = "${sec}/wildcard.krebsco.de.crt";
|
||||||
ssl_key = "${sec}/wildcard.krebsco.de.key";
|
ssl_key = "${sec}/wildcard.krebsco.de.key";
|
||||||
hostname = krebs.build.host.name;
|
hostname = config.krebs.build.host.name;
|
||||||
|
user = config.services.nginx.user;
|
||||||
|
group = config.services.nginx.group;
|
||||||
|
external-ip = head config.krebs.build.host.nets.internet.addrs4;
|
||||||
|
internal-ip = head config.krebs.build.host.nets.retiolum.addrs4;
|
||||||
|
base-dir = "/var/www/blog.euer";
|
||||||
in {
|
in {
|
||||||
|
# Prepare Blog directory
|
||||||
|
systemd.services.prepare-euer-blog = {
|
||||||
|
wantedBy = [ "local-fs.target" ];
|
||||||
|
before = [ "nginx.service" ];
|
||||||
|
serviceConfig = {
|
||||||
|
# do nothing if the base dir already exists
|
||||||
|
ExecStart = pkgs.writeScript "prepare-euer-blog-service" ''
|
||||||
|
#!/bin/sh
|
||||||
|
if ! test -d "${base-dir}" ;then
|
||||||
|
mkdir -p "${base-dir}"
|
||||||
|
chown ${user}:${group} "${base-dir}"
|
||||||
|
chmod 700 "${base-dir}"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
Type = "oneshot";
|
||||||
|
RemainAfterExit = "yes";
|
||||||
|
TimeoutSec = "0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
krebs.nginx = {
|
krebs.nginx = {
|
||||||
enable = mkDefault true;
|
enable = mkDefault true;
|
||||||
servers = {
|
servers = {
|
||||||
euer-blog = {
|
euer-blog = {
|
||||||
listen = [ "80" "443 ssl" ];
|
listen = [ "${external-ip}:80" "${external-ip}:443 ssl"
|
||||||
server-names = [ "euer.krebsco.de" "euer.blog.krebsco.de" "blog.${hostname}" ];
|
"${internal-ip}:80" "${internal-ip}:443 ssl" ];
|
||||||
|
server-names = [ "euer.krebsco.de" "blog.euer.krebsco.de" "blog.${hostname}" ];
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_buffers 4 32k;
|
gzip_buffers 4 32k;
|
||||||
@ -22,7 +48,7 @@ in {
|
|||||||
default_type text/plain;
|
default_type text/plain;
|
||||||
'';
|
'';
|
||||||
locations = singleton (nameValuePair "/" ''
|
locations = singleton (nameValuePair "/" ''
|
||||||
root /var/www/euer.blog/;
|
root ${base-dir};
|
||||||
'');
|
'');
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -51,18 +51,21 @@ in {
|
|||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = pkgs.writeScript "prepare-tw-service" ''
|
ExecStart = pkgs.writeScript "prepare-tw-service" ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
mkdir -p "${wiki-dir}" "${backup-dir}"
|
if ! test -d "${base-dir}" ;then
|
||||||
|
mkdir -p "${wiki-dir}" "${backup-dir}"
|
||||||
|
|
||||||
# write the base configuration
|
# write the base configuration
|
||||||
cat > "${base-cfg}" <<EOF
|
cat > "${base-cfg}" <<EOF
|
||||||
[users]
|
[users]
|
||||||
$(cat "${tw-pass-file}")
|
$(cat "${tw-pass-file}")
|
||||||
[directories]
|
[directories]
|
||||||
backupdir = ${backup-dir}
|
backupdir = ${backup-dir}
|
||||||
savedir = ${wiki-dir}
|
savedir = ${wiki-dir}
|
||||||
EOF
|
EOF
|
||||||
chown -R ${user}:${group} "${base-dir}"
|
|
||||||
chmod 700 -R "${base-dir}"
|
chown -R ${user}:${group} "${base-dir}"
|
||||||
|
chmod 700 -R "${base-dir}"
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
RemainAfterExit = "yes";
|
RemainAfterExit = "yes";
|
||||||
|
Loading…
Reference in New Issue
Block a user