aboutsummaryrefslogtreecommitdiff
path: root/tests/acceptance/virtiofs_submounts.py.data/guest-cleanup.sh
blob: 729cb2d1a5ecc97c99c742dbc67b61837a7b919c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

function print_usage()
{
    if [ -n "$2" ]; then
        echo "Error: $2"
        echo
    fi
    echo "Usage: $1 <scratch dir>"
}

scratch_dir=$1
if [ -z "$scratch_dir" ]; then
    print_usage "$0" 'Scratch dir not given' >&2
    exit 1
fi

cd "$scratch_dir/share" || exit 1

mps=(mnt*)
mp_i=0
for mp in "${mps[@]}"; do
    mp_i=$((mp_i + 1))
    printf "Unmounting %i/%i...\r" "$mp_i" "${#mps[@]}"

    sudo umount -R "$mp"
done
echo

echo 'Done.'