guest-cleanup.sh (464B)
1#!/bin/bash 2 3function print_usage() 4{ 5 if [ -n "$2" ]; then 6 echo "Error: $2" 7 echo 8 fi 9 echo "Usage: $1 <scratch dir>" 10} 11 12scratch_dir=$1 13if [ -z "$scratch_dir" ]; then 14 print_usage "$0" 'Scratch dir not given' >&2 15 exit 1 16fi 17 18cd "$scratch_dir/share" || exit 1 19 20mps=(mnt*) 21mp_i=0 22for mp in "${mps[@]}"; do 23 mp_i=$((mp_i + 1)) 24 printf "Unmounting %i/%i...\r" "$mp_i" "${#mps[@]}" 25 26 sudo umount -R "$mp" 27done 28echo 29 30echo 'Done.'