From dfd9229ad20d0ff724ce5ccf45161c8eb5e2c9e5 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 5 Oct 2017 10:01:09 +0100 Subject: xci: scripts: build-dib-os.sh: chmod and chown files using sudo Some of the files may be owned by root so we need to ensure that everything is reset properly. Moreover, only clean the image files for the one we are building. Change-Id: I45b78db6715534187f19d9f513e8288fd076cb6b Signed-off-by: Markos Chandras --- xci/scripts/vm/build-dib-os.sh | 8 ++++++-- xci/scripts/vm/start-new-vm.sh | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'xci/scripts') diff --git a/xci/scripts/vm/build-dib-os.sh b/xci/scripts/vm/build-dib-os.sh index 7547d40e..7688ee6e 100755 --- a/xci/scripts/vm/build-dib-os.sh +++ b/xci/scripts/vm/build-dib-os.sh @@ -24,17 +24,21 @@ fi # Prepare new working directory dib_workdir="${XCI_CACHE_DIR:-${HOME}/.cache/opnfv_xci_deploy}/clean_vm/images" [[ ! -d $dib_workdir ]] && mkdir -p $dib_workdir -chmod 777 -R $dib_workdir # Record our information uid=$(id -u) gid=$(id -g) +sudo chmod 777 -R $dib_workdir +sudo chown $uid:$gid -R $dib_workdir + echo "Getting the latest docker image..." eval $docker_cmd pull hwoarang/docker-dib-xci:latest # Get rid of stale files -rm -rf $dib_workdir/*.qcow2 $dib_workdir/*.sha256.txt $dib_workdir/*.d +rm -rf $dib_workdir/${ONE_DISTRO}.qcow2 \ + $dib_workdir/${ONE_DISTRO}.sha256.txt \ + $dib_workdir/${ONE_DISTRO}.d echo "Initiating dib build..." eval $docker_cmd run --name ${docker_name} \ --rm --privileged=true -e ONE_DISTRO=${ONE_DISTRO} \ diff --git a/xci/scripts/vm/start-new-vm.sh b/xci/scripts/vm/start-new-vm.sh index 4ad41f64..a1f4080e 100755 --- a/xci/scripts/vm/start-new-vm.sh +++ b/xci/scripts/vm/start-new-vm.sh @@ -110,6 +110,11 @@ sudo systemctl -q start docker echo "Preparing XCI cache..." mkdir -p ${XCI_CACHE_DIR}/ ${XCI_CACHE_DIR}/clean_vm/images/ +# Record our information +uid=$(id -u) +gid=$(id -g) +sudo chmod 777 -R $XCI_CACHE_DIR/clean_vm/images/ +sudo chown $uid:$gid -R $XCI_CACHE_DIR/clean_vm/images/ if ${XCI_BUILD_CLEAN_VM_OS}; then echo "Building new ${OS} image..." @@ -132,6 +137,9 @@ fi # Doesn't matter if we just built an image or got one from artifacts. In both # cases there should be a copy in the cache so copy it over. sudo rm -f ${BASE_PATH}/${OS}.qcow2 +# Fix perms again... +sudo chmod 777 -R $XCI_CACHE_DIR/clean_vm/images/ +sudo chown $uid:$gid -R $XCI_CACHE_DIR/clean_vm/images/ cp ${XCI_CACHE_DIR}/clean_vm/images/${OS}.qcow2 ${BASE_PATH}/ declare -r OS_IMAGE_FILE=${OS}.qcow2 -- cgit 1.2.3-korg