From 18118096b5646eafe4676557d7a89eb2edefa205 Mon Sep 17 00:00:00 2001 From: Guillaume Berche Date: Sun, 1 Oct 2023 23:21:57 +0200 Subject: [PATCH] Addition of add-sparse-env-var-to-agent-sv.bash Contributes to https://github.com/orange-cloudfoundry/paas-templates/issues/2060 Still need testing [skip ci] --- .../bin/add-sparse-env-var-to-agent-sv.bash | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 jobs/k3s-agent/templates/bin/add-sparse-env-var-to-agent-sv.bash diff --git a/jobs/k3s-agent/templates/bin/add-sparse-env-var-to-agent-sv.bash b/jobs/k3s-agent/templates/bin/add-sparse-env-var-to-agent-sv.bash new file mode 100755 index 00000000..f208a58f --- /dev/null +++ b/jobs/k3s-agent/templates/bin/add-sparse-env-var-to-agent-sv.bash @@ -0,0 +1,19 @@ +#!/bin/bash + +set -x +set -e + +#TODO: test whether the bosh job indeed runs as vcap, if running as root, we can remove next line +[ $(id -u) -eq 0 ] || exec sudo $0 $@ + +if ! grep TAR_OPTIONS /etc/sv/agent/run ; then + echo "patching /etc/sv/agent/run to inject TAR_OPTIONS as a workaround for https://github.com/orange-cloudfoundry/paas-templates/issues/2060" + # substitute 3rd line with new export + # more about this syntax at https://stackoverflow.com/a/9533736/1484823 + sed -i.orig '3s/$^export TAR_OPTIONS=" --sparse "/' + #FIXME: check that the creation of a backup file /etc/sv/agent/run.orig is ignored by sv + # if not, replace -i.orig flag by -i flag +else + echo "/etc/sv/agent/run already contains TAR_OPTIONS" +fi +! diff /etc/sv/agent/run /etc/sv/agent/run.orig \ No newline at end of file