From 8f427f601a453de9070f8dbc34fb2724479f315f Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Wed, 9 Mar 2022 01:45:47 +0530 Subject: [PATCH] Adapt script to bash version 3 (#6069) This PR fixes: #6060 Bash version 3 does not have support for associative arrays. Hence during the packaging phase the metadata.ini file created (on osx) isn't in proper format as the script used to generate it i.e., templateConfig.sh made use of associative arrays - which is supported from bash v4 onward. This eventually leads failure to deploy DB on OSX. This PR modifies the script to work on systems using bash v3. --- engine/schema/templateConfig.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/engine/schema/templateConfig.sh b/engine/schema/templateConfig.sh index 891c73db1bb..fb12ad752a2 100644 --- a/engine/schema/templateConfig.sh +++ b/engine/schema/templateConfig.sh @@ -55,28 +55,27 @@ function getChecksum() { function createMetadataFile() { local fileData=$(cat $SOURCEFILE) echo -e "["default"]\nversion = $VERSION.${securityversion}\n" >> $METADATAFILE - for i in "${!templates[@]}" + for template in "${templates[@]}" do - section="$i" - hvName=$(getGenericName $i) + section="${template%%:*}" + hvName=$(getGenericName $section) - templatename="systemvm-${i}-${VERSION}" + templatename="systemvm-${section}-${VERSION}" checksum=$(getChecksum "$fileData" "$VERSION-$hvName") - downloadurl="${templates[$i]}" + downloadurl="${template#*:}" filename=$(echo ${downloadurl##*'/'}) echo -e "["$section"]\ntemplatename = $templatename\nchecksum = $checksum\ndownloadurl = $downloadurl\nfilename = $filename\n" >> $METADATAFILE done } -declare -A templates +declare -a templates getTemplateVersion $1 -templates=( ["kvm"]="https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-kvm.qcow2.bz2" - ["vmware"]="https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-vmware.ova" - ["xenserver"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-xen.vhd.bz2" - ["hyperv"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-hyperv.vhd.zip" - ["lxc"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-kvm.qcow2.bz2" - ["ovm3"]="https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-ovm.raw.bz2" ) - +templates=( "kvm:https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-kvm.qcow2.bz2" + "vmware:https://download.cloudstack.org/systemvm/${CS_VERSION}/systemvmtemplate-$VERSION-vmware.ova" + "xenserver:https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-xen.vhd.bz2" + "hyperv:https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-hyperv.vhd.zip" + "lxc:https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-kvm.qcow2.bz2" + "ovm3:https://download.cloudstack.org/systemvm/$CS_VERSION/systemvmtemplate-$VERSION-ovm.raw.bz2" ) PARENTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/dist/systemvm-templates/" mkdir -p $PARENTPATH