From 78f540b41d0b6a12fadf178336828c3b737af7e4 Mon Sep 17 00:00:00 2001 From: pierreozoux <pierre@ozoux.net> Date: Tue, 4 Nov 2014 15:57:07 +0000 Subject: [PATCH] Fixes #21 - gitpuller working --- importers/gitpuller.sh | 3 --- unit-files/nginx-gitpuller@.path | 7 +++++++ unit-files/nginx-gitpuller@.service | 10 +++++----- unit-files/nginx-gitpuller@.timer | 5 ++++- unit-files/nginx@.service | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) delete mode 100755 importers/gitpuller.sh diff --git a/importers/gitpuller.sh b/importers/gitpuller.sh deleted file mode 100755 index 2b37d98..0000000 --- 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 3bba895..4ed6246 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 8670772..7a85e63 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 78faa1e..493f351 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 48f6485..dcd916b 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 -- GitLab