From f72859ce7b2d77325b46e7f0703836338b048723 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Thu, 9 Feb 2017 18:34:18 +0900
Subject: [PATCH] stack.erp5: Quote more shell variables.

Prevents a few possible accidental variable expansions and space
susceptibilities.
---
 stack/erp5/buildout.hash.cfg                  |  2 +-
 ...riadb-resiliency-after-import-script.sh.in | 20 +++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/stack/erp5/buildout.hash.cfg b/stack/erp5/buildout.hash.cfg
index b6e464f85..b2497a763 100644
--- a/stack/erp5/buildout.hash.cfg
+++ b/stack/erp5/buildout.hash.cfg
@@ -15,7 +15,7 @@
 # not need these here).
 [mariadb-resiliency-after-import-script]
 filename = instance-mariadb-resiliency-after-import-script.sh.in
-md5sum = 372e5247d0a1514f3406228407b10d77
+md5sum = d9eb111b6c1f3c8c63557a49c2358d09
 
 [template-mariadb]
 filename = instance-mariadb.cfg.in
diff --git a/stack/erp5/instance-mariadb-resiliency-after-import-script.sh.in b/stack/erp5/instance-mariadb-resiliency-after-import-script.sh.in
index ce46ef525..5a478ffa8 100644
--- a/stack/erp5/instance-mariadb-resiliency-after-import-script.sh.in
+++ b/stack/erp5/instance-mariadb-resiliency-after-import-script.sh.in
@@ -12,16 +12,16 @@
 
 set -e
 
-mysql_executable="${binary-wrap-mysql:wrapper-path}"
-mariadb_data_directory="${directory:mariadb-data}"
-mariadb_backup_directory="${directory:mariadb-backup-full}"
-instance_directory="${buildout:directory}"
-pid_file="${my-cnf-parameters:pid-file}"
-binlog_path="${my-cnf-parameters:binlog-path}"
+mysql_executable='${binary-wrap-mysql:wrapper-path}'
+mariadb_data_directory='${directory:mariadb-data}'
+mariadb_backup_directory='${directory:mariadb-backup-full}'
+instance_directory='${buildout:directory}'
+pid_file='${my-cnf-parameters:pid-file}'
+binlog_path='${my-cnf-parameters:binlog-path}'
 
 # Make sure mariadb is not already running
 if [ -e "$pid_file" ]; then
-  pid=$(cat $pid_file) > /dev/null 2>&1
+  pid=$(cat "$pid_file") > /dev/null 2>&1
   if kill -0 "$pid"; then
     echo "Mariadb is already running with pid $pid. Aborting."
     exit 1
@@ -29,11 +29,11 @@ if [ -e "$pid_file" ]; then
 fi
 
 echo "Deleting existing database..."
-rm -r $mariadb_data_directory/* >/dev/null 2>&1 || true
+rm -r "$mariadb_data_directory"/* >/dev/null 2>&1 || true
 
 # $binlog_path can be empty if incremental_backup_retention_days <= -1
 if [ -n "$binlog_path" ]; then
-  new_binlog_directory="$(dirname $binlog_path)"
+  new_binlog_directory="$(dirname "$binlog_path")"
   binlog_index_file="$new_binlog_directory/binlog.index"
   if [ -e "$binlog_index_file" ]; then
     echo "Adapting binlog database to new paths..."
@@ -65,7 +65,7 @@ fi
 
 echo "Importing data..."
 # Use latest dump XXX can contain funny characters
-dump=$(ls -r $mariadb_backup_directory | head -1)
+dump=$(ls -r "$mariadb_backup_directory" | head -1)
 zcat "$mariadb_backup_directory/$dump" | $mysql_executable -u root --socket="$instance_directory/var/run/mariadb.sock"
 RESTORE_EXIT_CODE=$?
 
-- 
2.30.9