From d01bbd563e76e0654e8068917d6a5cb19c2f7a40 Mon Sep 17 00:00:00 2001 From: Thibault Richard Date: Fri, 24 May 2019 16:29:09 +0200 Subject: [PATCH] Move directories only if not empty in prepare-fs script Because the globbing (use of * in the mv command) fails when there is no match. --- .../pkg/controller/elasticsearch/initcontainer/script.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/operators/pkg/controller/elasticsearch/initcontainer/script.go b/operators/pkg/controller/elasticsearch/initcontainer/script.go index 63bc757533..12f3d64067 100644 --- a/operators/pkg/controller/elasticsearch/initcontainer/script.go +++ b/operators/pkg/controller/elasticsearch/initcontainer/script.go @@ -100,8 +100,12 @@ var scriptTemplate = template.Must(template.New("").Parse( # to a volume, to be used by the ES container mv_start=$(date +%s) {{range .SharedVolumes.Array}} - echo "Moving {{.EsContainerMountPath}}/* to {{.InitContainerMountPath}}/" - mv {{.EsContainerMountPath}}/* {{.InitContainerMountPath}}/ + if [[ -z "$(ls -A {{.EsContainerMountPath}})" ]]; then + echo "Empty dir {{.EsContainerMountPath}}" + else + echo "Moving {{.EsContainerMountPath}}/* to {{.InitContainerMountPath}}/" + mv {{.EsContainerMountPath}}/* {{.InitContainerMountPath}}/ + fi {{end}} echo "Files copy duration: $(duration $mv_start) sec."