From 669e28e826aeb2546837b9a4aa79a84cac515440 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20de=20Saint=20Martin?= <cedric.dsm@tiolive.com>
Date: Wed, 3 Dec 2014 13:03:41 +0000
Subject: [PATCH] slaprunner: importer script: use variables.

Allow to lint/edit/develop more easily the bash script without having tons of template parameters.
---
 .../template/runner-import.sh.jinja2          | 20 ++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/software/slaprunner/template/runner-import.sh.jinja2 b/software/slaprunner/template/runner-import.sh.jinja2
index d4631b5f5..56badee6d 100644
--- a/software/slaprunner/template/runner-import.sh.jinja2
+++ b/software/slaprunner/template/runner-import.sh.jinja2
@@ -2,6 +2,7 @@
 LC_ALL=C
 export LC_ALL
 umask 077
+srv_directory={{ directory['srv'] }}
 restore_element () {
   backup_path=$1
   restore_path=$2
@@ -18,23 +19,24 @@ restore_element () {
 
 write_backup_proof () {
   cd {{ directory['backup'] }}
-  find -type f ! -name backup.signature ! -wholename "./rdiff-backup-data/*" -print0 | xargs -P4 -0 sha256sum  | LC_ALL=C sort -k 66 > {{ directory['srv'] }}/proof.signature
-  diff -ruw {{ directory['backup'] }} {{ directory['srv'] }}/proof.signature > {{ directory['srv'] }}/backup.diff
+  find -type f ! -name backup.signature ! -wholename "./rdiff-backup-data/*" -print0 | xargs -P4 -0 sha256sum  | LC_ALL=C sort -k 66 > $srv_directory/proof.signature
+  diff -ruw {{ directory['backup'] }} $srv_directory/proof.signature > $srv_directory/backup.diff
 }
 
-# For now we just make the diff before 
+# For now we just make the diff before
 write_backup_proof
 
-restore_element {{ directory['backup'] }}/runner/ {{ directory['srv'] }}/runner  instance project  proxy.db
+restore_element {{ directory['backup'] }}/runner/ $srv_directory/runner  instance project  proxy.db
 restore_element  {{ directory['backup'] }}/etc/ {{ directory['etc'] }} config.json ssh
 cp -r {{ directory['backup'] }}/etc/.??* {{ directory['etc'] }};
 {{ curl_binary }} --insecure -vg6L --max-time 5  {{ backend_url }}/isSRReady;
 
-if [ -e  {{ directory['srv'] }}/runner-import-restore ]; then
-  touch {{ directory['srv'] }}/runner-import-restore
-  chmod +x {{ directory['srv'] }}/runner-import-restore
+if [ -e  $srv_directory/runner-import-restore ]; then
+  touch $srv_directory/runner-import-restore
+  chmod +x $srv_directory/runner-import-restore
 fi
 
-# Invoke arbitrary script to perform specific restauration 
+# Invoke arbitrary script to perform specific restoration
 # procedure.
-{{ directory['srv'] }}/runner-import-restore
+$srv_directory/runner-import-restore
+
-- 
2.30.9