diff --git a/importers/gitpuller.sh b/importers/gitpuller.sh deleted file mode 100755 index 2b37d98ef6d6050dd7c55c024d23ac0b5d2992ca..0000000000000000000000000000000000000000 --- a/importers/gitpuller.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -cd /data/per-user/$USER/$APP/data/www-content && git pull diff --git a/unit-files/nginx-gitpuller@.path b/unit-files/nginx-gitpuller@.path index 3bba8953de38483fd40573314947bb57258e6af0..4ed6246b3c87447b2396865ce1125339ff71d3bb 100644 --- a/unit-files/nginx-gitpuller@.path +++ b/unit-files/nginx-gitpuller@.path @@ -1,2 +1,9 @@ +[Unit] +Description=Start the timer if there is a GITURL file + +# Dependency binding +BindsTo=nginx@%i.service + [Path] PathExists=/data/per-user/%i/nginx/data/GITURL +Unit=nginx-gitpuller@%i.timer diff --git a/unit-files/nginx-gitpuller@.service b/unit-files/nginx-gitpuller@.service index 8670772620b8c0e70d988fe0c629f6db7a840801..7a85e630f7130d2950be7f8b5b7895dcadb363b6 100644 --- a/unit-files/nginx-gitpuller@.service +++ b/unit-files/nginx-gitpuller@.service @@ -1,9 +1,9 @@ [Unit] -Description= git puller +Description=git puller [Service] Type=oneshot -RemainAfterExit=yes -Environment=USER=%i -Environment=APP=nginx -ExecStart=/data/indiehosters/importers/gitpuller.sh +ExecStart=/bin/bash -euxc ' \ + app=`echo %p | cut -d"-" -f1`; \ + cd /data/per-user/%i/$app/data/www-content; \ + git pull' diff --git a/unit-files/nginx-gitpuller@.timer b/unit-files/nginx-gitpuller@.timer index 78faa1e6b7c53e4b35d8a39962efd22cb93273eb..493f351730056e67103b148bbbb7aa58a1fdf2f5 100644 --- a/unit-files/nginx-gitpuller@.timer +++ b/unit-files/nginx-gitpuller@.timer @@ -1,5 +1,8 @@ [Unit] -Description=Run git puller every 10 minutes +Description=Run git puller service every 10 minutes + +# Dependency binding +BindsTo=nginx-gitpuller@%i.path [Timer] OnUnitActiveSec=10min diff --git a/unit-files/nginx@.service b/unit-files/nginx@.service index 48f6485c9a14ce8deb97a6ad37e7192f9d733996..dcd916bd936f0abedc4eb9698d284564708f2e3d 100644 --- a/unit-files/nginx@.service +++ b/unit-files/nginx@.service @@ -5,7 +5,7 @@ Description=%p-%i Requires=docker.service Requires=%p-importer@%i.service Requires=%p-discovery@%i.service -Wants=%p-gitpuller@%i.service +Requires=%p-gitpuller@%i.path # Dependency ordering After=docker.service