1#!/bin/sh
2# umount all mountpoints of an existing alpine chroot.
3
4set -e
5
6if [ $# -lt 1 ]; then
7 echo "USAGE: ${0##*/} CHROOT..." 1>&2
8 exit 1
9fi
10
11if [ $(id -u) -ne 0 ]; then
12 echo "${0##*/} has to be started as root." 1>&2
13 exit 1
14fi
15
16for chroot in $@; do
17 for mountpoint in /dev /sys /run /proc; do
18 busybox mountpoint -q "${chroot}/${mountpoint}" && \
19 umount -l "${chroot}/${mountpoint}"
20 done
21
22 for mountpoint in $(mount | cut -d " " -f3 | grep "^${chroot}"); do
23 umount -l "${mountpoint}"
24 done
25done