summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2019-02-18 22:55:49 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-02-18 22:55:49 +0000
commit9cf9d8cdd3a8fd7d4d425f7051122d0ac8af2bbd (patch)
tree83d1e0b41e4b08124d86f264b80df7d7831fa2a1 /tools
parent0bb4c74e7f2d008b015d5453a1be88ae807b1f9b (diff)
downloadvyos-cloud-init-9cf9d8cdd3a8fd7d4d425f7051122d0ac8af2bbd.tar.gz
vyos-cloud-init-9cf9d8cdd3a8fd7d4d425f7051122d0ac8af2bbd.zip
This is to fix https://bugs.launchpad.net/cloud-init/+bug/1812676
Diffstat (limited to 'tools')
-rwxr-xr-xtools/cloud-init-per8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/cloud-init-per b/tools/cloud-init-per
index 7d6754b6..eae3e93f 100755
--- a/tools/cloud-init-per
+++ b/tools/cloud-init-per
@@ -38,7 +38,7 @@ fi
[ "$1" = "-h" -o "$1" = "--help" ] && { Usage ; exit 0; }
[ $# -ge 3 ] || { Usage 1>&2; exit 1; }
freq=$1
-name=$2
+name=${2/-/_}
shift 2;
[ "${name#*/}" = "${name}" ] || fail "name cannot contain a /"
@@ -53,6 +53,12 @@ esac
[ -d "${sem%/*}" ] || mkdir -p "${sem%/*}" ||
fail "failed to make directory for ${sem}"
+# Rename legacy sem files with dashes in their names. Do not overwrite existing
+# sem files to prevent clobbering those which may have been created from calls
+# outside of cloud-init.
+sem_legacy="${sem/_/-}"
+[ "$sem" != "$sem_legacy" -a -e "$sem_legacy" ] && mv -n "$sem_legacy" "$sem"
+
[ "$freq" != "always" -a -e "$sem" ] && exit 0
"$@"
ret=$?