From a973348598d0f9c2cabe15f3d0133d9e76038388 Mon Sep 17 00:00:00 2001 From: Chris Plock Date: Tue, 7 Nov 2017 08:26:44 -0800 Subject: [PATCH] adding quotes for directories with spaces Signed-off-by: Chris Plock fixing docker run --- install/ansible/install_swarm.sh | 15 +++++++++------ scripts/build.sh | 16 ++++++++-------- scripts/download_ansible_repo.sh | 8 ++++---- scripts/prepare_netplugin_tarball.sh | 8 ++++---- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/install/ansible/install_swarm.sh b/install/ansible/install_swarm.sh index 861225c..3d739ff 100755 --- a/install/ansible/install_swarm.sh +++ b/install/ansible/install_swarm.sh @@ -162,9 +162,12 @@ fi echo "Starting the installer container" image_name="contiv/install:__CONTIV_INSTALL_VERSION__" -install_mount="-v $(pwd)/install:/install:Z" -ansible_mount="-v $(pwd)/ansible:/ansible:Z" -config_mount="-v $src_conf_path:$container_conf_path:Z" -cache_mount="-v $(pwd)/contiv_cache:/var/contiv_cache:Z" -mounts="$install_mount $ansible_mount $cache_mount $config_mount" -docker run --rm --net=host $mounts $image_name sh -c "./install/ansible/install.sh $netmaster_param -a \"$ans_opts\" $install_scheduler -m $contiv_network_mode -d $fwd_mode $aci_param $cluster_param $v2plugin_param" +mounts[0]="-v" +mounts[1]="$(pwd)/install:/install:Z" +mounts[2]="-v" +mounts[3]="$(pwd)/ansible:/ansible:Z" +mounts[4]="-v" +mounts[5]="$src_conf_path:$container_conf_path:Z" +mounts[6]="-v" +mounts[7]="$(pwd)/contiv_cache:/var/contiv_cache:Z" +docker run --rm --net=host "${mounts[@]}" $image_name sh -c "./install/ansible/install.sh $netmaster_param -a \"$ans_opts\" $install_scheduler -m $contiv_network_mode -d $fwd_mode $aci_param $cluster_param $v2plugin_param" diff --git a/scripts/build.sh b/scripts/build.sh index 57a2545..7153039 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -26,8 +26,8 @@ v2plugin_version=${CONTIV_V2PLUGIN_VERSION} # where everything is assembled, always start with a clean dir and clean it up output_tmp_dir="$(mktemp -d)" output_dir="${output_tmp_dir}/contiv-${CONTIV_INSTALLER_VERSION}" -mkdir -p ${output_dir} -trap 'rm -rf ${output_tmp_dir}' EXIT +mkdir -p "${output_dir}" +trap 'rm -rf "${output_tmp_dir}"' EXIT release_dir=release mkdir -p $release_dir @@ -45,7 +45,7 @@ cp -rf scripts/generate-certificate.sh $output_dir/install chmod +x $output_dir/install/genInventoryFile.py chmod +x $output_dir/install/generate-certificate.sh -cp -a ${CONTIV_ARTIFACT_STAGING}/ansible ${output_dir}/ +cp -a "${CONTIV_ARTIFACT_STAGING}/ansible" ${output_dir}/ # Replace versions files=$(find $output_dir -type f -name "*.yaml" -or -name "*.sh" -or -name "*.json") @@ -96,14 +96,14 @@ curl --fail -sL -o $binary_cache/ovs-switch.deb http://mirrors.kernel.org/ubuntu # Copy the netplugin release into the binary cache for "full" installer # Netplugin releases built locally based on a branch are named by their SHA, # but there is a symlink to point to the SHA named tarball by it's branch name -plugin_tball=${CONTIV_ARTIFACT_STAGING}/$CONTIV_NETPLUGIN_TARBALL_NAME +plugin_tball="${CONTIV_ARTIFACT_STAGING}/$CONTIV_NETPLUGIN_TARBALL_NAME" if [[ -L "${plugin_tball}" ]]; then # copy the link (so other processes can find the tarball) and the tarball - target_plugin_tball=$(readlink ${plugin_tball}) - cp -a ${plugin_tball} ${binary_cache}/ - plugin_tball=${CONTIV_ARTIFACT_STAGING}/${target_plugin_tball} + target_plugin_tball="$(readlink "${plugin_tball}")" + cp -a "${plugin_tball}" "${binary_cache}/" + plugin_tball="${CONTIV_ARTIFACT_STAGING}/${target_plugin_tball}" fi -cp ${plugin_tball} ${binary_cache}/ +cp "${plugin_tball}" "${binary_cache}/" env_file=$output_dir/install/ansible/env.json sed -i.bak 's#__AUTH_PROXY_LOCAL_INSTALL__#true#g' "$env_file" diff --git a/scripts/download_ansible_repo.sh b/scripts/download_ansible_repo.sh index 11eae15..4ccae0a 100755 --- a/scripts/download_ansible_repo.sh +++ b/scripts/download_ansible_repo.sh @@ -2,12 +2,12 @@ set -euo pipefail -ANSIBLE_REPO_DIR=${CONTIV_ARTIFACT_STAGING}/ansible +ANSIBLE_REPO_DIR="${CONTIV_ARTIFACT_STAGING}/ansible" -rm -rf $ANSIBLE_REPO_DIR +rm -rf "$ANSIBLE_REPO_DIR" -mkdir -p $ANSIBLE_REPO_DIR $CONTIV_ARTIFACT_STAGING +mkdir -p "$ANSIBLE_REPO_DIR" "$CONTIV_ARTIFACT_STAGING" echo downloading ${CONTIV_ANSIBLE_OWNER}/ansible commit: $CONTIV_ANSIBLE_COMMIT curl --fail -sL https://api.github.com/repos/${CONTIV_ANSIBLE_OWNER}/ansible/tarball/$CONTIV_ANSIBLE_COMMIT \ - | tar --strip-components 1 -C $ANSIBLE_REPO_DIR -z -x + | tar --strip-components 1 -C "$ANSIBLE_REPO_DIR" -z -x diff --git a/scripts/prepare_netplugin_tarball.sh b/scripts/prepare_netplugin_tarball.sh index 77e70b8..067f17b 100755 --- a/scripts/prepare_netplugin_tarball.sh +++ b/scripts/prepare_netplugin_tarball.sh @@ -12,7 +12,7 @@ set -euxo pipefail : ${CONTIV_NETPLUGIN_TARBALL_NAME} # check if defined -mkdir -p $CONTIV_ARTIFACT_STAGING +mkdir -p "$CONTIV_ARTIFACT_STAGING" # check if installer is for a release version of netplugin if [ -z "${NETPLUGIN_BRANCH:-}" ]; then @@ -21,7 +21,7 @@ if [ -z "${NETPLUGIN_BRANCH:-}" ]; then base_url=https://github.com/contiv/netplugin/releases/download netplugin_bundle_name=netplugin-$CONTIV_NETPLUGIN_VERSION.tar.bz2 curl -sL ${base_url}/$CONTIV_NETPLUGIN_VERSION/$netplugin_bundle_name \ - -o ${CONTIV_ARTIFACT_STAGING}/$netplugin_bundle_name + -o "${CONTIV_ARTIFACT_STAGING}/$netplugin_bundle_name" exit fi @@ -47,7 +47,7 @@ BUILD_VERSION=${NETPLUGIN_VERSION} make tar # move the netplugin tarball to the staging directory for the installer mv netplugin-${NETPLUGIN_VERSION}.tar.bz2 \ - ${CONTIV_ARTIFACT_STAGING}/ + "${CONTIV_ARTIFACT_STAGING}/" # create a link so other scripts can find the file without knowing the SHA -cd ${CONTIV_ARTIFACT_STAGING} +cd "${CONTIV_ARTIFACT_STAGING}" ln -sf netplugin-${NETPLUGIN_VERSION}.tar.bz2 $CONTIV_NETPLUGIN_TARBALL_NAME