Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Remove logs / empty directories by cleanup_all_vms.sh #160

Merged
merged 1 commit into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ jobs:
fail-fast: false
matrix:
stage:
- windows-server-2012_r2-standard-x64-eval-libvirt
- windows-server-2016-standard-x64-eval-libvirt
- windows-server-2019-standard-x64-eval-libvirt
- my_centos-7-x86_64-libvirt
- my_ubuntu-20.04-server-amd64-libvirt
- my_windows-10-enterprise-x64-eval-libvirt
- windows-10-enterprise-x64-eval-libvirt
- ubuntu-20.04-server-amd64-libvirt
- ubuntu-18.04-server-amd64-libvirt
- ubuntu-16.04-server-amd64-libvirt
- ubuntu-20.04-desktop-amd64-libvirt
- ubuntu-18.04-desktop-amd64-libvirt
- ubuntu-18.04-server-amd64-libvirt
- ubuntu-20.04-desktop-amd64-libvirt
- ubuntu-20.04-server-amd64-libvirt
- windows-10-enterprise-x64-eval-libvirt
- windows-server-2012_r2-standard-x64-eval-libvirt
- windows-server-2016-standard-x64-eval-libvirt
- windows-server-2019-standard-x64-eval-libvirt

steps:
- name: Skip image build if it already exists in Vagrant Cloud
Expand Down Expand Up @@ -113,18 +113,18 @@ jobs:
fail-fast: false
matrix:
stage:
- windows-server-2012_r2-standard-x64-eval-virtualbox
- windows-server-2016-standard-x64-eval-virtualbox
- windows-server-2019-standard-x64-eval-virtualbox
- my_centos-7-x86_64-virtualbox
- my_ubuntu-20.04-server-amd64-virtualbox
- my_windows-10-enterprise-x64-eval-virtualbox
- windows-10-enterprise-x64-eval-virtualbox
- ubuntu-20.04-server-amd64-virtualbox
- ubuntu-18.04-server-amd64-virtualbox
- ubuntu-16.04-server-amd64-virtualbox
- ubuntu-20.04-desktop-amd64-virtualbox
- ubuntu-18.04-desktop-amd64-virtualbox
- ubuntu-18.04-server-amd64-virtualbox
- ubuntu-20.04-desktop-amd64-virtualbox
- ubuntu-20.04-server-amd64-virtualbox
- windows-10-enterprise-x64-eval-virtualbox
- windows-server-2012_r2-standard-x64-eval-virtualbox
- windows-server-2016-standard-x64-eval-virtualbox
- windows-server-2019-standard-x64-eval-virtualbox

steps:
- name: Skip image build if it already exists in Vagrant Cloud
Expand Down
13 changes: 6 additions & 7 deletions tools/cleanup_all_vms.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

LOGDIR=${LOGDIR:-/var/tmp/packer-templates-logs}
PACKER_CACHE_DIR=${PACKER_CACHE_DIR:-/var/tmp/packer_cache}
PACKER_IMAGES_OUTPUT_DIR=${PACKER_IMAGES_OUTPUT_DIR:-/var/tmp/packer-templates-images}
LOGDIR=${LOGDIR:-${PACKER_IMAGES_OUTPUT_DIR}}
TMPDIR=${TMPDIR:-/tmp}

set -euo pipefail
Expand All @@ -24,6 +24,8 @@ if [[ -d "${TMPDIR}" ]]; then
done < <(find "${TMPDIR}" -maxdepth 2 ! -readable -prune -o -type f -name Vagrantfile -printf "%h\0")
fi

echo "*** Remove logs created by vagrant_init_destroy_boxes.sh form \"${LOGDIR}\""
find "${LOGDIR}" -maxdepth 1 -mindepth 1 -name "*-init.log" -delete

echo "*** Remove all PACKER_CACHE_DIR mess (not the iso files)"
find "${PACKER_CACHE_DIR}" -mindepth 1 ! \( -type f -name "*.iso" \) -user "${USER}" -delete -print
Expand All @@ -35,7 +37,6 @@ while IFS= read -r BOX; do
vagrant box remove --force --all "${BOX}"
done < <(vagrant box list | awk '{ print $1 }')


echo "*** Remove all VirtualBox instances"
while IFS= read -r VM; do
VM_ID=$(echo "${VM}" | awk -F '[{}]' '{ print $2 }')
Expand All @@ -50,8 +51,7 @@ while IFS= read -r HDD; do
VBoxManage closemedium disk "${HDD_ID}" --delete
done < <(VBoxManage list hdds | grep '^UUID:')

test -d "${HOME}/VirtualBox VMs" && rm -r -v "${HOME}/VirtualBox VMs"

test -d "${HOME}/VirtualBox VMs" && rm -rvf "${HOME}/VirtualBox VMs"

echo "*** Remove all libvirt instances"
for VM in $(virsh --connect=qemu:///system list --all --name); do
Expand All @@ -62,13 +62,12 @@ for VM in $(virsh --connect=qemu:///system list --all --name); do
virsh --connect=qemu:///system undefine --remove-all-storage "${VM}"
done


if [[ -d "${LOGDIR}" ]]; then
echo "*** Remove directory: ${LOGDIR}"
rm -rf "${LOGDIR}"
rm -rvf "${LOGDIR}"
fi

if [[ -d "${PACKER_IMAGES_OUTPUT_DIR}" ]]; then
echo "*** Remove directory: ${PACKER_IMAGES_OUTPUT_DIR}"
rm -rf "${PACKER_IMAGES_OUTPUT_DIR}"
rm -rvf "${PACKER_IMAGES_OUTPUT_DIR}"
fi
2 changes: 1 addition & 1 deletion vagrant_init_destroy_boxes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o pipefail

BOXES_LIST=${*:-$(find . -maxdepth 1 \( -name "*ubuntu*.box" -o -name "*centos*.box" -o -name "*windows*.box" \) -printf "%f\n" | sort | tr "\n" " ")}
TMPDIR=${TMPDIR:-/tmp}
LOGDIR=${LOGDIR:-/var/tmp/}
LOGDIR=${LOGDIR:-${TMPDIR}}
export VAGRANT_IGNORE_WINRM_PLUGIN=true

vagrant_box_add() {
Expand Down